blob: 1750c64eca9664ed5727fb47ccda53333a04c5e7 [file] [log] [blame]
Prabir Pradhan29c95332018-11-14 20:14:11 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Prabir Pradhan48108662022-09-09 21:22:04 +000017#pragma once
Prabir Pradhan29c95332018-11-14 20:14:11 -080018
Christine Franks46d8a1e2022-01-05 16:11:48 -080019#include <android/os/IInputConstants.h>
Prabir Pradhan28efc192019-11-05 01:10:04 +000020#include <input/DisplayViewport.h>
Prabir Pradhan29c95332018-11-14 20:14:11 -080021#include <input/Input.h>
22#include <input/InputDevice.h>
Prabir Pradhan29c95332018-11-14 20:14:11 -080023#include <input/VelocityControl.h>
24#include <input/VelocityTracker.h>
Nathaniel R. Lewiscacd69a2019-08-12 22:07:00 +000025#include <stddef.h>
Michael Wrighta9cf4192022-12-01 23:46:39 +000026#include <ui/Rotation.h>
Nathaniel R. Lewiscacd69a2019-08-12 22:07:00 +000027#include <unistd.h>
Prabir Pradhan28efc192019-11-05 01:10:04 +000028#include <utils/Errors.h>
Prabir Pradhan29c95332018-11-14 20:14:11 -080029#include <utils/RefBase.h>
Prabir Pradhan29c95332018-11-14 20:14:11 -080030
Siarhei Vishniakouc6f61192019-07-23 18:12:31 +000031#include <optional>
32#include <set>
Siarhei Vishniakou8158e7e2018-10-15 14:28:20 -070033#include <unordered_map>
Prabir Pradhan29c95332018-11-14 20:14:11 -080034#include <vector>
35
Nathaniel R. Lewiscacd69a2019-08-12 22:07:00 +000036#include "PointerControllerInterface.h"
37#include "VibrationElement.h"
38
Prabir Pradhan29c95332018-11-14 20:14:11 -080039// Maximum supported size of a vibration pattern.
40// Must be at least 2.
41#define MAX_VIBRATE_PATTERN_SIZE 100
42
Prabir Pradhan29c95332018-11-14 20:14:11 -080043namespace android {
44
Prabir Pradhan28efc192019-11-05 01:10:04 +000045// --- InputReaderInterface ---
46
47/* The interface for the InputReader shared library.
48 *
49 * Manages one or more threads that process raw input events and sends cooked event data to an
50 * input listener.
51 *
52 * The implementation must guarantee thread safety for this interface. However, since the input
53 * listener is NOT thread safe, all calls to the listener must happen from the same thread.
54 */
Siarhei Vishniakou18050092021-09-01 13:32:49 -070055class InputReaderInterface {
56public:
Prabir Pradhan29c95332018-11-14 20:14:11 -080057 InputReaderInterface() { }
58 virtual ~InputReaderInterface() { }
59
Prabir Pradhan29c95332018-11-14 20:14:11 -080060 /* Dumps the state of the input reader.
61 *
62 * This method may be called on any thread (usually by the input manager). */
63 virtual void dump(std::string& dump) = 0;
64
Prabir Pradhan28efc192019-11-05 01:10:04 +000065 /* Called by the heartbeat to ensures that the reader has not deadlocked. */
Prabir Pradhan29c95332018-11-14 20:14:11 -080066 virtual void monitor() = 0;
67
68 /* Returns true if the input device is enabled. */
69 virtual bool isInputDeviceEnabled(int32_t deviceId) = 0;
70
Prabir Pradhan28efc192019-11-05 01:10:04 +000071 /* Makes the reader start processing events from the kernel. */
72 virtual status_t start() = 0;
73
74 /* Makes the reader stop processing any more events. */
75 virtual status_t stop() = 0;
Prabir Pradhan29c95332018-11-14 20:14:11 -080076
77 /* Gets information about all input devices.
78 *
79 * This method may be called on any thread (usually by the input manager).
80 */
Chris Ye98d3f532020-10-01 21:48:59 -070081 virtual std::vector<InputDeviceInfo> getInputDevices() const = 0;
Prabir Pradhan29c95332018-11-14 20:14:11 -080082
83 /* Query current input state. */
84 virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask,
85 int32_t scanCode) = 0;
86 virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask,
87 int32_t keyCode) = 0;
88 virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask,
89 int32_t sw) = 0;
90
Vaibhav Devmuraricbba14c2022-10-10 16:54:49 +000091 virtual void addKeyRemapping(int32_t deviceId, int32_t fromKeyCode,
92 int32_t toKeyCode) const = 0;
93
Philip Junker4af3b3d2021-12-14 10:36:55 +010094 virtual int32_t getKeyCodeForKeyLocation(int32_t deviceId, int32_t locationKeyCode) const = 0;
95
Prabir Pradhan29c95332018-11-14 20:14:11 -080096 /* Toggle Caps Lock */
97 virtual void toggleCapsLockState(int32_t deviceId) = 0;
98
99 /* Determine whether physical keys exist for the given framework-domain key codes. */
100 virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask,
Siarhei Vishniakou74007942022-06-13 13:57:47 -0700101 const std::vector<int32_t>& keyCodes, uint8_t* outFlags) = 0;
Prabir Pradhan29c95332018-11-14 20:14:11 -0800102
103 /* Requests that a reconfiguration of all input devices.
104 * The changes flag is a bitfield that indicates what has changed and whether
105 * the input devices must all be reopened. */
106 virtual void requestRefreshConfiguration(uint32_t changes) = 0;
107
108 /* Controls the vibrator of a particular input device. */
Chris Ye87143712020-11-10 05:05:58 +0000109 virtual void vibrate(int32_t deviceId, const VibrationSequence& sequence, ssize_t repeat,
110 int32_t token) = 0;
Prabir Pradhan29c95332018-11-14 20:14:11 -0800111 virtual void cancelVibrate(int32_t deviceId, int32_t token) = 0;
Arthur Hungc23540e2018-11-29 20:42:11 +0800112
Chris Ye87143712020-11-10 05:05:58 +0000113 virtual bool isVibrating(int32_t deviceId) = 0;
114
115 virtual std::vector<int32_t> getVibratorIds(int32_t deviceId) = 0;
Kim Low03ea0352020-11-06 12:45:07 -0800116 /* Get battery level of a particular input device. */
117 virtual std::optional<int32_t> getBatteryCapacity(int32_t deviceId) = 0;
118 /* Get battery status of a particular input device. */
119 virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId) = 0;
Prabir Pradhane287ecd2022-09-07 21:18:05 +0000120 /* Get the device path for the battery of an input device. */
121 virtual std::optional<std::string> getBatteryDevicePath(int32_t deviceId) = 0;
Chris Ye87143712020-11-10 05:05:58 +0000122
Siarhei Vishniakou1983a712021-06-04 19:27:09 +0000123 virtual std::vector<InputDeviceLightInfo> getLights(int32_t deviceId) = 0;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800124
Siarhei Vishniakou1983a712021-06-04 19:27:09 +0000125 virtual std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) = 0;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800126
Arthur Hungc23540e2018-11-29 20:42:11 +0800127 /* Return true if the device can send input events to the specified display. */
128 virtual bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) = 0;
Chris Yef59a2f42020-10-16 12:55:26 -0700129
130 /* Enable sensor in input reader mapper. */
131 virtual bool enableSensor(int32_t deviceId, InputDeviceSensorType sensorType,
132 std::chrono::microseconds samplingPeriod,
133 std::chrono::microseconds maxBatchReportLatency) = 0;
134
135 /* Disable sensor in input reader mapper. */
136 virtual void disableSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0;
137
138 /* Flush sensor data in input reader mapper. */
139 virtual void flushSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800140
141 /* Set color for the light */
142 virtual bool setLightColor(int32_t deviceId, int32_t lightId, int32_t color) = 0;
143 /* Set player ID for the light */
144 virtual bool setLightPlayerId(int32_t deviceId, int32_t lightId, int32_t playerId) = 0;
145 /* Get light color */
146 virtual std::optional<int32_t> getLightColor(int32_t deviceId, int32_t lightId) = 0;
147 /* Get light player ID */
148 virtual std::optional<int32_t> getLightPlayerId(int32_t deviceId, int32_t lightId) = 0;
Prabir Pradhanb54ffb22022-10-27 18:03:34 +0000149
150 /* Get the Bluetooth address of an input device, if known. */
151 virtual std::optional<std::string> getBluetoothAddress(int32_t deviceId) const = 0;
Vaibhav Devmurari5fc7d852023-03-17 18:43:33 +0000152
153 /* Sysfs node change reported. Recreate device if required to incorporate the new sysfs nodes */
154 virtual void sysfsNodeChanged(const std::string& sysfsNodePath) = 0;
Prabir Pradhan29c95332018-11-14 20:14:11 -0800155};
156
Prabir Pradhan28efc192019-11-05 01:10:04 +0000157// --- InputReaderConfiguration ---
Prabir Pradhan29c95332018-11-14 20:14:11 -0800158
159/*
160 * Input reader configuration.
161 *
162 * Specifies various options that modify the behavior of the input reader.
163 */
164struct InputReaderConfiguration {
165 // Describes changes that have occurred.
166 enum {
Harry Cuttsa546ba82023-01-13 17:21:00 +0000167 // The mouse pointer speed changed.
Prabir Pradhan29c95332018-11-14 20:14:11 -0800168 CHANGE_POINTER_SPEED = 1 << 0,
169
170 // The pointer gesture control changed.
171 CHANGE_POINTER_GESTURE_ENABLEMENT = 1 << 1,
172
173 // The display size or orientation changed.
174 CHANGE_DISPLAY_INFO = 1 << 2,
175
176 // The visible touches option changed.
177 CHANGE_SHOW_TOUCHES = 1 << 3,
178
179 // The keyboard layouts must be reloaded.
180 CHANGE_KEYBOARD_LAYOUTS = 1 << 4,
181
182 // The device name alias supplied by the may have changed for some devices.
183 CHANGE_DEVICE_ALIAS = 1 << 5,
184
185 // The location calibration matrix changed.
186 CHANGE_TOUCH_AFFINE_TRANSFORMATION = 1 << 6,
187
188 // The presence of an external stylus has changed.
189 CHANGE_EXTERNAL_STYLUS_PRESENCE = 1 << 7,
190
191 // The pointer capture mode has changed.
192 CHANGE_POINTER_CAPTURE = 1 << 8,
193
194 // The set of disabled input devices (disabledDevices) has changed.
195 CHANGE_ENABLED_STATE = 1 << 9,
196
Ambrus Weisz7bc23bf2022-10-04 13:13:07 +0000197 // The device type has been updated.
198 CHANGE_DEVICE_TYPE = 1 << 10,
199
Zixuan Qufecb6062022-11-12 04:44:31 +0000200 // The keyboard layout association has changed.
201 CHANGE_KEYBOARD_LAYOUT_ASSOCIATION = 1 << 11,
202
Prabir Pradhan7aa7ff02022-12-21 21:05:38 +0000203 // The stylus button reporting configurations has changed.
204 CHANGE_STYLUS_BUTTON_REPORTING = 1 << 12,
205
Harry Cuttsa546ba82023-01-13 17:21:00 +0000206 // The touchpad settings changed.
207 CHANGE_TOUCHPAD_SETTINGS = 1 << 13,
208
Prabir Pradhan29c95332018-11-14 20:14:11 -0800209 // All devices must be reopened.
210 CHANGE_MUST_REOPEN = 1 << 31,
211 };
212
213 // Gets the amount of time to disable virtual keys after the screen is touched
214 // in order to filter out accidental virtual key presses due to swiping gestures
215 // or taps near the edge of the display. May be 0 to disable the feature.
216 nsecs_t virtualKeyQuietTime;
217
218 // The excluded device names for the platform.
219 // Devices with these names will be ignored.
220 std::vector<std::string> excludedDeviceNames;
221
Siarhei Vishniakou8158e7e2018-10-15 14:28:20 -0700222 // The associations between input ports and display ports.
223 // Used to determine which DisplayViewport should be tied to which InputDevice.
224 std::unordered_map<std::string, uint8_t> portAssociations;
225
Zixuan Qufecb6062022-11-12 04:44:31 +0000226 // The associations between input device physical port locations and display unique ids.
Christine Franks1ba71cc2021-04-07 14:37:42 -0700227 // Used to determine which DisplayViewport should be tied to which InputDevice.
228 std::unordered_map<std::string, std::string> uniqueIdAssociations;
229
Ambrus Weisz7bc23bf2022-10-04 13:13:07 +0000230 // The associations between input device ports device types.
231 // This is used to determine which device type and source should be tied to which InputDevice.
232 std::unordered_map<std::string, std::string> deviceTypeAssociations;
233
Zixuan Qufecb6062022-11-12 04:44:31 +0000234 // The map from the input device physical port location to the input device layout info.
235 // Can be used to determine the layout of the keyboard device.
236 std::unordered_map<std::string, KeyboardLayoutInfo> keyboardLayoutAssociations;
237
Garfield Tan888a6a42020-01-09 11:39:16 -0800238 // The suggested display ID to show the cursor.
239 int32_t defaultPointerDisplayId;
240
Prabir Pradhan29c95332018-11-14 20:14:11 -0800241 // Velocity control parameters for mouse pointer movements.
242 VelocityControlParameters pointerVelocityControlParameters;
243
244 // Velocity control parameters for mouse wheel movements.
245 VelocityControlParameters wheelVelocityControlParameters;
246
247 // True if pointer gestures are enabled.
248 bool pointerGesturesEnabled;
249
250 // Quiet time between certain pointer gesture transitions.
251 // Time to allow for all fingers or buttons to settle into a stable state before
252 // starting a new gesture.
253 nsecs_t pointerGestureQuietInterval;
254
255 // The minimum speed that a pointer must travel for us to consider switching the active
256 // touch pointer to it during a drag. This threshold is set to avoid switching due
257 // to noise from a finger resting on the touch pad (perhaps just pressing it down).
258 float pointerGestureDragMinSwitchSpeed; // in pixels per second
259
260 // Tap gesture delay time.
261 // The time between down and up must be less than this to be considered a tap.
262 nsecs_t pointerGestureTapInterval;
263
264 // Tap drag gesture delay time.
265 // The time between the previous tap's up and the next down must be less than
266 // this to be considered a drag. Otherwise, the previous tap is finished and a
267 // new tap begins.
268 //
269 // Note that the previous tap will be held down for this entire duration so this
270 // interval must be shorter than the long press timeout.
271 nsecs_t pointerGestureTapDragInterval;
272
273 // The distance in pixels that the pointer is allowed to move from initial down
274 // to up and still be called a tap.
275 float pointerGestureTapSlop; // in pixels
276
277 // Time after the first touch points go down to settle on an initial centroid.
278 // This is intended to be enough time to handle cases where the user puts down two
279 // fingers at almost but not quite exactly the same time.
280 nsecs_t pointerGestureMultitouchSettleInterval;
281
282 // The transition from PRESS to SWIPE or FREEFORM gesture mode is made when
283 // at least two pointers have moved at least this far from their starting place.
284 float pointerGestureMultitouchMinDistance; // in pixels
285
286 // The transition from PRESS to SWIPE gesture mode can only occur when the
287 // cosine of the angle between the two vectors is greater than or equal to than this value
288 // which indicates that the vectors are oriented in the same direction.
289 // When the vectors are oriented in the exactly same direction, the cosine is 1.0.
290 // (In exactly opposite directions, the cosine is -1.0.)
291 float pointerGestureSwipeTransitionAngleCosine;
292
293 // The transition from PRESS to SWIPE gesture mode can only occur when the
294 // fingers are no more than this far apart relative to the diagonal size of
295 // the touch pad. For example, a ratio of 0.5 means that the fingers must be
296 // no more than half the diagonal size of the touch pad apart.
297 float pointerGestureSwipeMaxWidthRatio;
298
299 // The gesture movement speed factor relative to the size of the display.
300 // Movement speed applies when the fingers are moving in the same direction.
301 // Without acceleration, a full swipe of the touch pad diagonal in movement mode
302 // will cover this portion of the display diagonal.
303 float pointerGestureMovementSpeedRatio;
304
305 // The gesture zoom speed factor relative to the size of the display.
306 // Zoom speed applies when the fingers are mostly moving relative to each other
307 // to execute a scale gesture or similar.
308 // Without acceleration, a full swipe of the touch pad diagonal in zoom mode
309 // will cover this portion of the display diagonal.
310 float pointerGestureZoomSpeedRatio;
311
312 // True to show the location of touches on the touch screen as spots.
313 bool showTouches;
314
Prabir Pradhan5cc1a692021-08-06 14:01:18 +0000315 // The latest request to enable or disable Pointer Capture.
316 PointerCaptureRequest pointerCaptureRequest;
Prabir Pradhan29c95332018-11-14 20:14:11 -0800317
Harry Cuttsa546ba82023-01-13 17:21:00 +0000318 // The touchpad pointer speed, as a number from -7 (slowest) to 7 (fastest).
319 int32_t touchpadPointerSpeed;
320
321 // True to invert the touchpad scrolling direction, so that moving two fingers downwards on the
322 // touchpad scrolls the content upwards.
323 bool touchpadNaturalScrollingEnabled;
324
325 // True to enable tap-to-click on touchpads.
326 bool touchpadTapToClickEnabled;
327
328 // True to enable a zone on the right-hand side of touchpads where clicks will be turned into
329 // context (a.k.a. "right") clicks.
330 bool touchpadRightClickZoneEnabled;
331
Prabir Pradhan29c95332018-11-14 20:14:11 -0800332 // The set of currently disabled input devices.
Siarhei Vishniakouc6f61192019-07-23 18:12:31 +0000333 std::set<int32_t> disabledDevices;
Prabir Pradhan29c95332018-11-14 20:14:11 -0800334
Prabir Pradhan7aa7ff02022-12-21 21:05:38 +0000335 // True if stylus button reporting through motion events should be enabled, in which case
336 // stylus button state changes are reported through motion events.
337 bool stylusButtonMotionEventsEnabled;
338
Seunghwan Choi2de48e42023-01-17 20:45:15 +0900339 // True if a pointer icon should be shown for direct stylus pointers.
340 bool stylusPointerIconEnabled;
341
Prabir Pradhan5cc1a692021-08-06 14:01:18 +0000342 InputReaderConfiguration()
343 : virtualKeyQuietTime(0),
Christine Franks46d8a1e2022-01-05 16:11:48 -0800344 pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f,
345 static_cast<float>(
346 android::os::IInputConstants::
347 DEFAULT_POINTER_ACCELERATION)),
Prabir Pradhan29c95332018-11-14 20:14:11 -0800348 wheelVelocityControlParameters(1.0f, 15.0f, 50.0f, 4.0f),
349 pointerGesturesEnabled(true),
Prabir Pradhan5cc1a692021-08-06 14:01:18 +0000350 pointerGestureQuietInterval(100 * 1000000LL), // 100 ms
351 pointerGestureDragMinSwitchSpeed(50), // 50 pixels per second
352 pointerGestureTapInterval(150 * 1000000LL), // 150 ms
353 pointerGestureTapDragInterval(150 * 1000000LL), // 150 ms
354 pointerGestureTapSlop(10.0f), // 10 pixels
Prabir Pradhan29c95332018-11-14 20:14:11 -0800355 pointerGestureMultitouchSettleInterval(100 * 1000000LL), // 100 ms
Prabir Pradhan5cc1a692021-08-06 14:01:18 +0000356 pointerGestureMultitouchMinDistance(15), // 15 pixels
357 pointerGestureSwipeTransitionAngleCosine(0.2588f), // cosine of 75 degrees
Prabir Pradhan29c95332018-11-14 20:14:11 -0800358 pointerGestureSwipeMaxWidthRatio(0.25f),
359 pointerGestureMovementSpeedRatio(0.8f),
360 pointerGestureZoomSpeedRatio(0.3f),
Prabir Pradhan5cc1a692021-08-06 14:01:18 +0000361 showTouches(false),
Prabir Pradhan7aa7ff02022-12-21 21:05:38 +0000362 pointerCaptureRequest(),
Harry Cuttsa546ba82023-01-13 17:21:00 +0000363 touchpadPointerSpeed(0),
364 touchpadNaturalScrollingEnabled(true),
365 touchpadTapToClickEnabled(true),
366 touchpadRightClickZoneEnabled(false),
Seunghwan Choi2de48e42023-01-17 20:45:15 +0900367 stylusButtonMotionEventsEnabled(true),
368 stylusPointerIconEnabled(false) {}
Prabir Pradhan29c95332018-11-14 20:14:11 -0800369
Siarhei Vishniakouc5ae0dc2019-07-10 15:51:18 -0700370 static std::string changesToString(uint32_t changes);
371
Siarhei Vishniakou8158e7e2018-10-15 14:28:20 -0700372 std::optional<DisplayViewport> getDisplayViewportByType(ViewportType type) const;
373 std::optional<DisplayViewport> getDisplayViewportByUniqueId(const std::string& uniqueDisplayId)
374 const;
375 std::optional<DisplayViewport> getDisplayViewportByPort(uint8_t physicalPort) const;
Garfield Tan888a6a42020-01-09 11:39:16 -0800376 std::optional<DisplayViewport> getDisplayViewportById(int32_t displayId) const;
Prabir Pradhan29c95332018-11-14 20:14:11 -0800377 void setDisplayViewports(const std::vector<DisplayViewport>& viewports);
378
Prabir Pradhan29c95332018-11-14 20:14:11 -0800379 void dump(std::string& dump) const;
380 void dumpViewport(std::string& dump, const DisplayViewport& viewport) const;
381
382private:
383 std::vector<DisplayViewport> mDisplays;
384};
385
Prabir Pradhan28efc192019-11-05 01:10:04 +0000386// --- TouchAffineTransformation ---
387
Prabir Pradhan29c95332018-11-14 20:14:11 -0800388struct TouchAffineTransformation {
389 float x_scale;
390 float x_ymix;
391 float x_offset;
392 float y_xmix;
393 float y_scale;
394 float y_offset;
395
396 TouchAffineTransformation() :
397 x_scale(1.0f), x_ymix(0.0f), x_offset(0.0f),
398 y_xmix(0.0f), y_scale(1.0f), y_offset(0.0f) {
399 }
400
401 TouchAffineTransformation(float xscale, float xymix, float xoffset,
402 float yxmix, float yscale, float yoffset) :
403 x_scale(xscale), x_ymix(xymix), x_offset(xoffset),
404 y_xmix(yxmix), y_scale(yscale), y_offset(yoffset) {
405 }
406
407 void applyTo(float& x, float& y) const;
408};
409
Prabir Pradhan28efc192019-11-05 01:10:04 +0000410// --- InputReaderPolicyInterface ---
411
Prabir Pradhan29c95332018-11-14 20:14:11 -0800412/*
413 * Input reader policy interface.
414 *
415 * The input reader policy is used by the input reader to interact with the Window Manager
416 * and other system components.
417 *
418 * The actual implementation is partially supported by callbacks into the DVM
419 * via JNI. This interface is also mocked in the unit tests.
420 *
Prabir Pradhan28efc192019-11-05 01:10:04 +0000421 * These methods will NOT re-enter the input reader interface, so they may be called from
422 * any method in the input reader interface.
Prabir Pradhan29c95332018-11-14 20:14:11 -0800423 */
424class InputReaderPolicyInterface : public virtual RefBase {
425protected:
426 InputReaderPolicyInterface() { }
427 virtual ~InputReaderPolicyInterface() { }
428
429public:
430 /* Gets the input reader configuration. */
431 virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) = 0;
432
433 /* Gets a pointer controller associated with the specified cursor device (ie. a mouse). */
Michael Wright17db18e2020-06-26 20:51:44 +0100434 virtual std::shared_ptr<PointerControllerInterface> obtainPointerController(
435 int32_t deviceId) = 0;
Prabir Pradhan29c95332018-11-14 20:14:11 -0800436
437 /* Notifies the input reader policy that some input devices have changed
438 * and provides information about all current input devices.
439 */
Arthur Hung7c3ae9c2019-03-11 11:23:03 +0800440 virtual void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) = 0;
Prabir Pradhan29c95332018-11-14 20:14:11 -0800441
442 /* Gets the keyboard layout for a particular input device. */
Chris Ye3a1e4462020-08-12 10:13:15 -0700443 virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay(
Prabir Pradhan29c95332018-11-14 20:14:11 -0800444 const InputDeviceIdentifier& identifier) = 0;
445
446 /* Gets a user-supplied alias for a particular input device, or an empty string if none. */
447 virtual std::string getDeviceAlias(const InputDeviceIdentifier& identifier) = 0;
448
449 /* Gets the affine calibration associated with the specified device. */
450 virtual TouchAffineTransformation getTouchAffineTransformation(
Michael Wrighta9cf4192022-12-01 23:46:39 +0000451 const std::string& inputDeviceDescriptor, ui::Rotation surfaceRotation) = 0;
Prabir Pradhanda20b172022-09-26 17:01:18 +0000452 /* Notifies the input reader policy that a stylus gesture has started. */
453 virtual void notifyStylusGestureStarted(int32_t deviceId, nsecs_t eventTime) = 0;
Prabir Pradhan29c95332018-11-14 20:14:11 -0800454};
455
456} // namespace android