xref: /aosp_15_r20/frameworks/native/services/inputflinger/include/InputReaderBase.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1*38e8c45fSAndroid Build Coastguard Worker /*
2*38e8c45fSAndroid Build Coastguard Worker  * Copyright (C) 2018 The Android Open Source Project
3*38e8c45fSAndroid Build Coastguard Worker  *
4*38e8c45fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*38e8c45fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*38e8c45fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*38e8c45fSAndroid Build Coastguard Worker  *
8*38e8c45fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*38e8c45fSAndroid Build Coastguard Worker  *
10*38e8c45fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*38e8c45fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*38e8c45fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*38e8c45fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*38e8c45fSAndroid Build Coastguard Worker  * limitations under the License.
15*38e8c45fSAndroid Build Coastguard Worker  */
16*38e8c45fSAndroid Build Coastguard Worker 
17*38e8c45fSAndroid Build Coastguard Worker #pragma once
18*38e8c45fSAndroid Build Coastguard Worker 
19*38e8c45fSAndroid Build Coastguard Worker #include <android/os/IInputConstants.h>
20*38e8c45fSAndroid Build Coastguard Worker #include <input/DisplayViewport.h>
21*38e8c45fSAndroid Build Coastguard Worker #include <input/Input.h>
22*38e8c45fSAndroid Build Coastguard Worker #include <input/InputDevice.h>
23*38e8c45fSAndroid Build Coastguard Worker #include <input/VelocityControl.h>
24*38e8c45fSAndroid Build Coastguard Worker #include <input/VelocityTracker.h>
25*38e8c45fSAndroid Build Coastguard Worker #include <stddef.h>
26*38e8c45fSAndroid Build Coastguard Worker #include <ui/Rotation.h>
27*38e8c45fSAndroid Build Coastguard Worker #include <unistd.h>
28*38e8c45fSAndroid Build Coastguard Worker #include <utils/Errors.h>
29*38e8c45fSAndroid Build Coastguard Worker #include <utils/RefBase.h>
30*38e8c45fSAndroid Build Coastguard Worker 
31*38e8c45fSAndroid Build Coastguard Worker #include <optional>
32*38e8c45fSAndroid Build Coastguard Worker #include <set>
33*38e8c45fSAndroid Build Coastguard Worker #include <unordered_map>
34*38e8c45fSAndroid Build Coastguard Worker #include <vector>
35*38e8c45fSAndroid Build Coastguard Worker 
36*38e8c45fSAndroid Build Coastguard Worker #include "PointerControllerInterface.h"
37*38e8c45fSAndroid Build Coastguard Worker #include "TouchpadHardwareState.h"
38*38e8c45fSAndroid Build Coastguard Worker #include "VibrationElement.h"
39*38e8c45fSAndroid Build Coastguard Worker #include "include/gestures.h"
40*38e8c45fSAndroid Build Coastguard Worker 
41*38e8c45fSAndroid Build Coastguard Worker // Maximum supported size of a vibration pattern.
42*38e8c45fSAndroid Build Coastguard Worker // Must be at least 2.
43*38e8c45fSAndroid Build Coastguard Worker #define MAX_VIBRATE_PATTERN_SIZE 100
44*38e8c45fSAndroid Build Coastguard Worker 
45*38e8c45fSAndroid Build Coastguard Worker namespace android {
46*38e8c45fSAndroid Build Coastguard Worker 
47*38e8c45fSAndroid Build Coastguard Worker // --- InputReaderConfiguration ---
48*38e8c45fSAndroid Build Coastguard Worker 
49*38e8c45fSAndroid Build Coastguard Worker /*
50*38e8c45fSAndroid Build Coastguard Worker  * Input reader configuration.
51*38e8c45fSAndroid Build Coastguard Worker  *
52*38e8c45fSAndroid Build Coastguard Worker  * Specifies various options that modify the behavior of the input reader.
53*38e8c45fSAndroid Build Coastguard Worker  */
54*38e8c45fSAndroid Build Coastguard Worker struct InputReaderConfiguration {
55*38e8c45fSAndroid Build Coastguard Worker     // Describes changes that have occurred.
56*38e8c45fSAndroid Build Coastguard Worker     enum class Change : uint32_t {
57*38e8c45fSAndroid Build Coastguard Worker         // The mouse pointer speed changed.
58*38e8c45fSAndroid Build Coastguard Worker         POINTER_SPEED = 1u << 0,
59*38e8c45fSAndroid Build Coastguard Worker 
60*38e8c45fSAndroid Build Coastguard Worker         // The pointer gesture control changed.
61*38e8c45fSAndroid Build Coastguard Worker         POINTER_GESTURE_ENABLEMENT = 1u << 1,
62*38e8c45fSAndroid Build Coastguard Worker 
63*38e8c45fSAndroid Build Coastguard Worker         // The display size or orientation changed.
64*38e8c45fSAndroid Build Coastguard Worker         DISPLAY_INFO = 1u << 2,
65*38e8c45fSAndroid Build Coastguard Worker 
66*38e8c45fSAndroid Build Coastguard Worker         // The keyboard layouts must be reloaded.
67*38e8c45fSAndroid Build Coastguard Worker         KEYBOARD_LAYOUTS = 1u << 4,
68*38e8c45fSAndroid Build Coastguard Worker 
69*38e8c45fSAndroid Build Coastguard Worker         // The device name alias supplied by the may have changed for some devices.
70*38e8c45fSAndroid Build Coastguard Worker         DEVICE_ALIAS = 1u << 5,
71*38e8c45fSAndroid Build Coastguard Worker 
72*38e8c45fSAndroid Build Coastguard Worker         // The location calibration matrix changed.
73*38e8c45fSAndroid Build Coastguard Worker         TOUCH_AFFINE_TRANSFORMATION = 1u << 6,
74*38e8c45fSAndroid Build Coastguard Worker 
75*38e8c45fSAndroid Build Coastguard Worker         // The presence of an external stylus has changed.
76*38e8c45fSAndroid Build Coastguard Worker         EXTERNAL_STYLUS_PRESENCE = 1u << 7,
77*38e8c45fSAndroid Build Coastguard Worker 
78*38e8c45fSAndroid Build Coastguard Worker         // The pointer capture mode has changed.
79*38e8c45fSAndroid Build Coastguard Worker         POINTER_CAPTURE = 1u << 8,
80*38e8c45fSAndroid Build Coastguard Worker 
81*38e8c45fSAndroid Build Coastguard Worker         // The set of disabled input devices (disabledDevices) has changed.
82*38e8c45fSAndroid Build Coastguard Worker         ENABLED_STATE = 1u << 9,
83*38e8c45fSAndroid Build Coastguard Worker 
84*38e8c45fSAndroid Build Coastguard Worker         // The device type has been updated.
85*38e8c45fSAndroid Build Coastguard Worker         DEVICE_TYPE = 1u << 10,
86*38e8c45fSAndroid Build Coastguard Worker 
87*38e8c45fSAndroid Build Coastguard Worker         // The keyboard layout association has changed.
88*38e8c45fSAndroid Build Coastguard Worker         KEYBOARD_LAYOUT_ASSOCIATION = 1u << 11,
89*38e8c45fSAndroid Build Coastguard Worker 
90*38e8c45fSAndroid Build Coastguard Worker         // The stylus button reporting configurations has changed.
91*38e8c45fSAndroid Build Coastguard Worker         STYLUS_BUTTON_REPORTING = 1u << 12,
92*38e8c45fSAndroid Build Coastguard Worker 
93*38e8c45fSAndroid Build Coastguard Worker         // The touchpad settings changed.
94*38e8c45fSAndroid Build Coastguard Worker         TOUCHPAD_SETTINGS = 1u << 13,
95*38e8c45fSAndroid Build Coastguard Worker 
96*38e8c45fSAndroid Build Coastguard Worker         // The key remapping has changed.
97*38e8c45fSAndroid Build Coastguard Worker         KEY_REMAPPING = 1u << 14,
98*38e8c45fSAndroid Build Coastguard Worker 
99*38e8c45fSAndroid Build Coastguard Worker         // The mouse settings changed, this includes mouse reverse vertical scrolling and swap
100*38e8c45fSAndroid Build Coastguard Worker         // primary button.
101*38e8c45fSAndroid Build Coastguard Worker         MOUSE_SETTINGS = 1u << 15,
102*38e8c45fSAndroid Build Coastguard Worker 
103*38e8c45fSAndroid Build Coastguard Worker         // All devices must be reopened.
104*38e8c45fSAndroid Build Coastguard Worker         MUST_REOPEN = 1u << 31,
105*38e8c45fSAndroid Build Coastguard Worker     };
106*38e8c45fSAndroid Build Coastguard Worker 
107*38e8c45fSAndroid Build Coastguard Worker     // Gets the amount of time to disable virtual keys after the screen is touched
108*38e8c45fSAndroid Build Coastguard Worker     // in order to filter out accidental virtual key presses due to swiping gestures
109*38e8c45fSAndroid Build Coastguard Worker     // or taps near the edge of the display.  May be 0 to disable the feature.
110*38e8c45fSAndroid Build Coastguard Worker     nsecs_t virtualKeyQuietTime;
111*38e8c45fSAndroid Build Coastguard Worker 
112*38e8c45fSAndroid Build Coastguard Worker     // The excluded device names for the platform.
113*38e8c45fSAndroid Build Coastguard Worker     // Devices with these names will be ignored.
114*38e8c45fSAndroid Build Coastguard Worker     std::vector<std::string> excludedDeviceNames;
115*38e8c45fSAndroid Build Coastguard Worker 
116*38e8c45fSAndroid Build Coastguard Worker     // The associations between input ports and display ports.
117*38e8c45fSAndroid Build Coastguard Worker     // Used to determine which DisplayViewport should be tied to which InputDevice.
118*38e8c45fSAndroid Build Coastguard Worker     std::unordered_map<std::string, uint8_t> inputPortToDisplayPortAssociations;
119*38e8c45fSAndroid Build Coastguard Worker 
120*38e8c45fSAndroid Build Coastguard Worker     // The associations between input device ports and display unique ids.
121*38e8c45fSAndroid Build Coastguard Worker     // Used to determine which DisplayViewport should be tied to which InputDevice.
122*38e8c45fSAndroid Build Coastguard Worker     std::unordered_map<std::string, std::string> inputPortToDisplayUniqueIdAssociations;
123*38e8c45fSAndroid Build Coastguard Worker 
124*38e8c45fSAndroid Build Coastguard Worker     // The associations between input device descriptor and display unique ids.
125*38e8c45fSAndroid Build Coastguard Worker     // Used to determine which DisplayViewport should be tied to which InputDevice.
126*38e8c45fSAndroid Build Coastguard Worker     std::unordered_map<std::string, std::string> inputDeviceDescriptorToDisplayUniqueIdAssociations;
127*38e8c45fSAndroid Build Coastguard Worker 
128*38e8c45fSAndroid Build Coastguard Worker     // The associations between input device ports device types.
129*38e8c45fSAndroid Build Coastguard Worker     // This is used to determine which device type and source should be tied to which InputDevice.
130*38e8c45fSAndroid Build Coastguard Worker     std::unordered_map<std::string, std::string> deviceTypeAssociations;
131*38e8c45fSAndroid Build Coastguard Worker 
132*38e8c45fSAndroid Build Coastguard Worker     // The map from the input device physical port location to the input device layout info.
133*38e8c45fSAndroid Build Coastguard Worker     // Can be used to determine the layout of the keyboard device.
134*38e8c45fSAndroid Build Coastguard Worker     std::unordered_map<std::string, KeyboardLayoutInfo> keyboardLayoutAssociations;
135*38e8c45fSAndroid Build Coastguard Worker 
136*38e8c45fSAndroid Build Coastguard Worker     // The suggested display ID to show the cursor.
137*38e8c45fSAndroid Build Coastguard Worker     ui::LogicalDisplayId defaultPointerDisplayId;
138*38e8c45fSAndroid Build Coastguard Worker 
139*38e8c45fSAndroid Build Coastguard Worker     // The mouse pointer speed, as a number from -7 (slowest) to 7 (fastest).
140*38e8c45fSAndroid Build Coastguard Worker     int32_t mousePointerSpeed;
141*38e8c45fSAndroid Build Coastguard Worker 
142*38e8c45fSAndroid Build Coastguard Worker     // Displays on which an acceleration curve shouldn't be applied for pointer movements from mice.
143*38e8c45fSAndroid Build Coastguard Worker     std::set<ui::LogicalDisplayId> displaysWithMousePointerAccelerationDisabled;
144*38e8c45fSAndroid Build Coastguard Worker 
145*38e8c45fSAndroid Build Coastguard Worker     // Velocity control parameters for touchpad pointer movements on the old touchpad stack (based
146*38e8c45fSAndroid Build Coastguard Worker     // on TouchInputMapper).
147*38e8c45fSAndroid Build Coastguard Worker     //
148*38e8c45fSAndroid Build Coastguard Worker     // For mice, these are ignored and the values of mousePointerSpeed and
149*38e8c45fSAndroid Build Coastguard Worker     // mousePointerAccelerationEnabled used instead.
150*38e8c45fSAndroid Build Coastguard Worker     //
151*38e8c45fSAndroid Build Coastguard Worker     // TODO(b/281840344): remove this.
152*38e8c45fSAndroid Build Coastguard Worker     VelocityControlParameters pointerVelocityControlParameters;
153*38e8c45fSAndroid Build Coastguard Worker 
154*38e8c45fSAndroid Build Coastguard Worker     // Velocity control parameters for mouse wheel movements.
155*38e8c45fSAndroid Build Coastguard Worker     VelocityControlParameters wheelVelocityControlParameters;
156*38e8c45fSAndroid Build Coastguard Worker 
157*38e8c45fSAndroid Build Coastguard Worker     // True if pointer gestures are enabled.
158*38e8c45fSAndroid Build Coastguard Worker     bool pointerGesturesEnabled;
159*38e8c45fSAndroid Build Coastguard Worker 
160*38e8c45fSAndroid Build Coastguard Worker     // Quiet time between certain pointer gesture transitions.
161*38e8c45fSAndroid Build Coastguard Worker     // Time to allow for all fingers or buttons to settle into a stable state before
162*38e8c45fSAndroid Build Coastguard Worker     // starting a new gesture.
163*38e8c45fSAndroid Build Coastguard Worker     nsecs_t pointerGestureQuietInterval;
164*38e8c45fSAndroid Build Coastguard Worker 
165*38e8c45fSAndroid Build Coastguard Worker     // The minimum speed that a pointer must travel for us to consider switching the active
166*38e8c45fSAndroid Build Coastguard Worker     // touch pointer to it during a drag.  This threshold is set to avoid switching due
167*38e8c45fSAndroid Build Coastguard Worker     // to noise from a finger resting on the touch pad (perhaps just pressing it down).
168*38e8c45fSAndroid Build Coastguard Worker     float pointerGestureDragMinSwitchSpeed; // in pixels per second
169*38e8c45fSAndroid Build Coastguard Worker 
170*38e8c45fSAndroid Build Coastguard Worker     // Tap gesture delay time.
171*38e8c45fSAndroid Build Coastguard Worker     // The time between down and up must be less than this to be considered a tap.
172*38e8c45fSAndroid Build Coastguard Worker     nsecs_t pointerGestureTapInterval;
173*38e8c45fSAndroid Build Coastguard Worker 
174*38e8c45fSAndroid Build Coastguard Worker     // Tap drag gesture delay time.
175*38e8c45fSAndroid Build Coastguard Worker     // The time between the previous tap's up and the next down must be less than
176*38e8c45fSAndroid Build Coastguard Worker     // this to be considered a drag.  Otherwise, the previous tap is finished and a
177*38e8c45fSAndroid Build Coastguard Worker     // new tap begins.
178*38e8c45fSAndroid Build Coastguard Worker     //
179*38e8c45fSAndroid Build Coastguard Worker     // Note that the previous tap will be held down for this entire duration so this
180*38e8c45fSAndroid Build Coastguard Worker     // interval must be shorter than the long press timeout.
181*38e8c45fSAndroid Build Coastguard Worker     nsecs_t pointerGestureTapDragInterval;
182*38e8c45fSAndroid Build Coastguard Worker 
183*38e8c45fSAndroid Build Coastguard Worker     // The distance in pixels that the pointer is allowed to move from initial down
184*38e8c45fSAndroid Build Coastguard Worker     // to up and still be called a tap.
185*38e8c45fSAndroid Build Coastguard Worker     float pointerGestureTapSlop; // in pixels
186*38e8c45fSAndroid Build Coastguard Worker 
187*38e8c45fSAndroid Build Coastguard Worker     // Time after the first touch points go down to settle on an initial centroid.
188*38e8c45fSAndroid Build Coastguard Worker     // This is intended to be enough time to handle cases where the user puts down two
189*38e8c45fSAndroid Build Coastguard Worker     // fingers at almost but not quite exactly the same time.
190*38e8c45fSAndroid Build Coastguard Worker     nsecs_t pointerGestureMultitouchSettleInterval;
191*38e8c45fSAndroid Build Coastguard Worker 
192*38e8c45fSAndroid Build Coastguard Worker     // The transition from PRESS to SWIPE or FREEFORM gesture mode is made when
193*38e8c45fSAndroid Build Coastguard Worker     // at least two pointers have moved at least this far from their starting place.
194*38e8c45fSAndroid Build Coastguard Worker     float pointerGestureMultitouchMinDistance; // in pixels
195*38e8c45fSAndroid Build Coastguard Worker 
196*38e8c45fSAndroid Build Coastguard Worker     // The transition from PRESS to SWIPE gesture mode can only occur when the
197*38e8c45fSAndroid Build Coastguard Worker     // cosine of the angle between the two vectors is greater than or equal to than this value
198*38e8c45fSAndroid Build Coastguard Worker     // which indicates that the vectors are oriented in the same direction.
199*38e8c45fSAndroid Build Coastguard Worker     // When the vectors are oriented in the exactly same direction, the cosine is 1.0.
200*38e8c45fSAndroid Build Coastguard Worker     // (In exactly opposite directions, the cosine is -1.0.)
201*38e8c45fSAndroid Build Coastguard Worker     float pointerGestureSwipeTransitionAngleCosine;
202*38e8c45fSAndroid Build Coastguard Worker 
203*38e8c45fSAndroid Build Coastguard Worker     // The transition from PRESS to SWIPE gesture mode can only occur when the
204*38e8c45fSAndroid Build Coastguard Worker     // fingers are no more than this far apart relative to the diagonal size of
205*38e8c45fSAndroid Build Coastguard Worker     // the touch pad.  For example, a ratio of 0.5 means that the fingers must be
206*38e8c45fSAndroid Build Coastguard Worker     // no more than half the diagonal size of the touch pad apart.
207*38e8c45fSAndroid Build Coastguard Worker     float pointerGestureSwipeMaxWidthRatio;
208*38e8c45fSAndroid Build Coastguard Worker 
209*38e8c45fSAndroid Build Coastguard Worker     // The gesture movement speed factor relative to the size of the display.
210*38e8c45fSAndroid Build Coastguard Worker     // Movement speed applies when the fingers are moving in the same direction.
211*38e8c45fSAndroid Build Coastguard Worker     // Without acceleration, a full swipe of the touch pad diagonal in movement mode
212*38e8c45fSAndroid Build Coastguard Worker     // will cover this portion of the display diagonal.
213*38e8c45fSAndroid Build Coastguard Worker     float pointerGestureMovementSpeedRatio;
214*38e8c45fSAndroid Build Coastguard Worker 
215*38e8c45fSAndroid Build Coastguard Worker     // The gesture zoom speed factor relative to the size of the display.
216*38e8c45fSAndroid Build Coastguard Worker     // Zoom speed applies when the fingers are mostly moving relative to each other
217*38e8c45fSAndroid Build Coastguard Worker     // to execute a scale gesture or similar.
218*38e8c45fSAndroid Build Coastguard Worker     // Without acceleration, a full swipe of the touch pad diagonal in zoom mode
219*38e8c45fSAndroid Build Coastguard Worker     // will cover this portion of the display diagonal.
220*38e8c45fSAndroid Build Coastguard Worker     float pointerGestureZoomSpeedRatio;
221*38e8c45fSAndroid Build Coastguard Worker 
222*38e8c45fSAndroid Build Coastguard Worker     // The latest request to enable or disable Pointer Capture.
223*38e8c45fSAndroid Build Coastguard Worker     PointerCaptureRequest pointerCaptureRequest;
224*38e8c45fSAndroid Build Coastguard Worker 
225*38e8c45fSAndroid Build Coastguard Worker     // The touchpad pointer speed, as a number from -7 (slowest) to 7 (fastest).
226*38e8c45fSAndroid Build Coastguard Worker     int32_t touchpadPointerSpeed;
227*38e8c45fSAndroid Build Coastguard Worker 
228*38e8c45fSAndroid Build Coastguard Worker     // True to invert the touchpad scrolling direction, so that moving two fingers downwards on the
229*38e8c45fSAndroid Build Coastguard Worker     // touchpad scrolls the content upwards.
230*38e8c45fSAndroid Build Coastguard Worker     bool touchpadNaturalScrollingEnabled;
231*38e8c45fSAndroid Build Coastguard Worker 
232*38e8c45fSAndroid Build Coastguard Worker     // True to enable tap-to-click on touchpads.
233*38e8c45fSAndroid Build Coastguard Worker     bool touchpadTapToClickEnabled;
234*38e8c45fSAndroid Build Coastguard Worker 
235*38e8c45fSAndroid Build Coastguard Worker     // True to enable tap dragging on touchpads.
236*38e8c45fSAndroid Build Coastguard Worker     bool touchpadTapDraggingEnabled;
237*38e8c45fSAndroid Build Coastguard Worker 
238*38e8c45fSAndroid Build Coastguard Worker     // True if hardware state update notifications should be sent to the policy.
239*38e8c45fSAndroid Build Coastguard Worker     bool shouldNotifyTouchpadHardwareState;
240*38e8c45fSAndroid Build Coastguard Worker 
241*38e8c45fSAndroid Build Coastguard Worker     // True to enable a zone on the right-hand side of touchpads where clicks will be turned into
242*38e8c45fSAndroid Build Coastguard Worker     // context (a.k.a. "right") clicks.
243*38e8c45fSAndroid Build Coastguard Worker     bool touchpadRightClickZoneEnabled;
244*38e8c45fSAndroid Build Coastguard Worker 
245*38e8c45fSAndroid Build Coastguard Worker     // True to use three-finger tap as a customizable shortcut; false to use it as a middle-click.
246*38e8c45fSAndroid Build Coastguard Worker     bool touchpadThreeFingerTapShortcutEnabled;
247*38e8c45fSAndroid Build Coastguard Worker 
248*38e8c45fSAndroid Build Coastguard Worker     // True to enable system gestures (three- and four-finger swipes) on touchpads.
249*38e8c45fSAndroid Build Coastguard Worker     bool touchpadSystemGesturesEnabled;
250*38e8c45fSAndroid Build Coastguard Worker 
251*38e8c45fSAndroid Build Coastguard Worker     // The set of currently disabled input devices.
252*38e8c45fSAndroid Build Coastguard Worker     std::set<int32_t> disabledDevices;
253*38e8c45fSAndroid Build Coastguard Worker 
254*38e8c45fSAndroid Build Coastguard Worker     // True if stylus button reporting through motion events should be enabled, in which case
255*38e8c45fSAndroid Build Coastguard Worker     // stylus button state changes are reported through motion events.
256*38e8c45fSAndroid Build Coastguard Worker     bool stylusButtonMotionEventsEnabled;
257*38e8c45fSAndroid Build Coastguard Worker 
258*38e8c45fSAndroid Build Coastguard Worker     // True if a pointer icon should be shown for direct stylus pointers.
259*38e8c45fSAndroid Build Coastguard Worker     bool stylusPointerIconEnabled;
260*38e8c45fSAndroid Build Coastguard Worker 
261*38e8c45fSAndroid Build Coastguard Worker     // Keycodes to be remapped.
262*38e8c45fSAndroid Build Coastguard Worker     std::map<int32_t /* fromKeyCode */, int32_t /* toKeyCode */> keyRemapping;
263*38e8c45fSAndroid Build Coastguard Worker 
264*38e8c45fSAndroid Build Coastguard Worker     // True if the external mouse should have its vertical scrolling reversed, so that rotating the
265*38e8c45fSAndroid Build Coastguard Worker     // wheel downwards scrolls the content upwards.
266*38e8c45fSAndroid Build Coastguard Worker     bool mouseReverseVerticalScrollingEnabled;
267*38e8c45fSAndroid Build Coastguard Worker 
268*38e8c45fSAndroid Build Coastguard Worker     // True if the connected mouse should have its primary button (default: left click) swapped,
269*38e8c45fSAndroid Build Coastguard Worker     // so that the right click will be the primary action button and the left click will be the
270*38e8c45fSAndroid Build Coastguard Worker     // secondary action.
271*38e8c45fSAndroid Build Coastguard Worker     bool mouseSwapPrimaryButtonEnabled;
272*38e8c45fSAndroid Build Coastguard Worker 
InputReaderConfigurationInputReaderConfiguration273*38e8c45fSAndroid Build Coastguard Worker     InputReaderConfiguration()
274*38e8c45fSAndroid Build Coastguard Worker           : virtualKeyQuietTime(0),
275*38e8c45fSAndroid Build Coastguard Worker             defaultPointerDisplayId(ui::LogicalDisplayId::DEFAULT),
276*38e8c45fSAndroid Build Coastguard Worker             mousePointerSpeed(0),
277*38e8c45fSAndroid Build Coastguard Worker             displaysWithMousePointerAccelerationDisabled(),
278*38e8c45fSAndroid Build Coastguard Worker             pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f,
279*38e8c45fSAndroid Build Coastguard Worker                                              static_cast<float>(
280*38e8c45fSAndroid Build Coastguard Worker                                                      android::os::IInputConstants::
281*38e8c45fSAndroid Build Coastguard Worker                                                              DEFAULT_POINTER_ACCELERATION)),
282*38e8c45fSAndroid Build Coastguard Worker             wheelVelocityControlParameters(1.0f, 15.0f, 50.0f, 4.0f),
283*38e8c45fSAndroid Build Coastguard Worker             pointerGesturesEnabled(true),
284*38e8c45fSAndroid Build Coastguard Worker             pointerGestureQuietInterval(100 * 1000000LL),            // 100 ms
285*38e8c45fSAndroid Build Coastguard Worker             pointerGestureDragMinSwitchSpeed(50),                    // 50 pixels per second
286*38e8c45fSAndroid Build Coastguard Worker             pointerGestureTapInterval(150 * 1000000LL),              // 150 ms
287*38e8c45fSAndroid Build Coastguard Worker             pointerGestureTapDragInterval(150 * 1000000LL),          // 150 ms
288*38e8c45fSAndroid Build Coastguard Worker             pointerGestureTapSlop(10.0f),                            // 10 pixels
289*38e8c45fSAndroid Build Coastguard Worker             pointerGestureMultitouchSettleInterval(100 * 1000000LL), // 100 ms
290*38e8c45fSAndroid Build Coastguard Worker             pointerGestureMultitouchMinDistance(15),                 // 15 pixels
291*38e8c45fSAndroid Build Coastguard Worker             pointerGestureSwipeTransitionAngleCosine(0.2588f),       // cosine of 75 degrees
292*38e8c45fSAndroid Build Coastguard Worker             pointerGestureSwipeMaxWidthRatio(0.25f),
293*38e8c45fSAndroid Build Coastguard Worker             pointerGestureMovementSpeedRatio(0.8f),
294*38e8c45fSAndroid Build Coastguard Worker             pointerGestureZoomSpeedRatio(0.3f),
295*38e8c45fSAndroid Build Coastguard Worker             pointerCaptureRequest(),
296*38e8c45fSAndroid Build Coastguard Worker             touchpadPointerSpeed(0),
297*38e8c45fSAndroid Build Coastguard Worker             touchpadNaturalScrollingEnabled(true),
298*38e8c45fSAndroid Build Coastguard Worker             touchpadTapToClickEnabled(true),
299*38e8c45fSAndroid Build Coastguard Worker             touchpadTapDraggingEnabled(false),
300*38e8c45fSAndroid Build Coastguard Worker             shouldNotifyTouchpadHardwareState(false),
301*38e8c45fSAndroid Build Coastguard Worker             touchpadRightClickZoneEnabled(false),
302*38e8c45fSAndroid Build Coastguard Worker             touchpadThreeFingerTapShortcutEnabled(false),
303*38e8c45fSAndroid Build Coastguard Worker             touchpadSystemGesturesEnabled(true),
304*38e8c45fSAndroid Build Coastguard Worker             stylusButtonMotionEventsEnabled(true),
305*38e8c45fSAndroid Build Coastguard Worker             stylusPointerIconEnabled(false),
306*38e8c45fSAndroid Build Coastguard Worker             mouseReverseVerticalScrollingEnabled(false),
307*38e8c45fSAndroid Build Coastguard Worker             mouseSwapPrimaryButtonEnabled(false) {}
308*38e8c45fSAndroid Build Coastguard Worker 
309*38e8c45fSAndroid Build Coastguard Worker     std::optional<DisplayViewport> getDisplayViewportByType(ViewportType type) const;
310*38e8c45fSAndroid Build Coastguard Worker     std::optional<DisplayViewport> getDisplayViewportByUniqueId(const std::string& uniqueDisplayId)
311*38e8c45fSAndroid Build Coastguard Worker             const;
312*38e8c45fSAndroid Build Coastguard Worker     std::optional<DisplayViewport> getDisplayViewportByPort(uint8_t physicalPort) const;
313*38e8c45fSAndroid Build Coastguard Worker     std::optional<DisplayViewport> getDisplayViewportById(ui::LogicalDisplayId displayId) const;
314*38e8c45fSAndroid Build Coastguard Worker     void setDisplayViewports(const std::vector<DisplayViewport>& viewports);
315*38e8c45fSAndroid Build Coastguard Worker 
316*38e8c45fSAndroid Build Coastguard Worker     void dump(std::string& dump) const;
317*38e8c45fSAndroid Build Coastguard Worker     void dumpViewport(std::string& dump, const DisplayViewport& viewport) const;
318*38e8c45fSAndroid Build Coastguard Worker 
319*38e8c45fSAndroid Build Coastguard Worker private:
320*38e8c45fSAndroid Build Coastguard Worker     std::vector<DisplayViewport> mDisplays;
321*38e8c45fSAndroid Build Coastguard Worker };
322*38e8c45fSAndroid Build Coastguard Worker 
323*38e8c45fSAndroid Build Coastguard Worker using ConfigurationChanges = ftl::Flags<InputReaderConfiguration::Change>;
324*38e8c45fSAndroid Build Coastguard Worker 
325*38e8c45fSAndroid Build Coastguard Worker // --- InputReaderInterface ---
326*38e8c45fSAndroid Build Coastguard Worker 
327*38e8c45fSAndroid Build Coastguard Worker /* The interface for the InputReader shared library.
328*38e8c45fSAndroid Build Coastguard Worker  *
329*38e8c45fSAndroid Build Coastguard Worker  * Manages one or more threads that process raw input events and sends cooked event data to an
330*38e8c45fSAndroid Build Coastguard Worker  * input listener.
331*38e8c45fSAndroid Build Coastguard Worker  *
332*38e8c45fSAndroid Build Coastguard Worker  * The implementation must guarantee thread safety for this interface. However, since the input
333*38e8c45fSAndroid Build Coastguard Worker  * listener is NOT thread safe, all calls to the listener must happen from the same thread.
334*38e8c45fSAndroid Build Coastguard Worker  */
335*38e8c45fSAndroid Build Coastguard Worker class InputReaderInterface {
336*38e8c45fSAndroid Build Coastguard Worker public:
InputReaderInterface()337*38e8c45fSAndroid Build Coastguard Worker     InputReaderInterface() {}
~InputReaderInterface()338*38e8c45fSAndroid Build Coastguard Worker     virtual ~InputReaderInterface() {}
339*38e8c45fSAndroid Build Coastguard Worker     /* Dumps the state of the input reader.
340*38e8c45fSAndroid Build Coastguard Worker      *
341*38e8c45fSAndroid Build Coastguard Worker      * This method may be called on any thread (usually by the input manager). */
342*38e8c45fSAndroid Build Coastguard Worker     virtual void dump(std::string& dump) = 0;
343*38e8c45fSAndroid Build Coastguard Worker 
344*38e8c45fSAndroid Build Coastguard Worker     /* Called by the heartbeat to ensures that the reader has not deadlocked. */
345*38e8c45fSAndroid Build Coastguard Worker     virtual void monitor() = 0;
346*38e8c45fSAndroid Build Coastguard Worker 
347*38e8c45fSAndroid Build Coastguard Worker     /* Makes the reader start processing events from the kernel. */
348*38e8c45fSAndroid Build Coastguard Worker     virtual status_t start() = 0;
349*38e8c45fSAndroid Build Coastguard Worker 
350*38e8c45fSAndroid Build Coastguard Worker     /* Makes the reader stop processing any more events. */
351*38e8c45fSAndroid Build Coastguard Worker     virtual status_t stop() = 0;
352*38e8c45fSAndroid Build Coastguard Worker 
353*38e8c45fSAndroid Build Coastguard Worker     /* Gets information about all input devices.
354*38e8c45fSAndroid Build Coastguard Worker      *
355*38e8c45fSAndroid Build Coastguard Worker      * This method may be called on any thread (usually by the input manager).
356*38e8c45fSAndroid Build Coastguard Worker      */
357*38e8c45fSAndroid Build Coastguard Worker     virtual std::vector<InputDeviceInfo> getInputDevices() const = 0;
358*38e8c45fSAndroid Build Coastguard Worker 
359*38e8c45fSAndroid Build Coastguard Worker     /* Query current input state. */
360*38e8c45fSAndroid Build Coastguard Worker     virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, int32_t scanCode) = 0;
361*38e8c45fSAndroid Build Coastguard Worker     virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, int32_t keyCode) = 0;
362*38e8c45fSAndroid Build Coastguard Worker     virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t sw) = 0;
363*38e8c45fSAndroid Build Coastguard Worker 
364*38e8c45fSAndroid Build Coastguard Worker     virtual int32_t getKeyCodeForKeyLocation(int32_t deviceId, int32_t locationKeyCode) const = 0;
365*38e8c45fSAndroid Build Coastguard Worker 
366*38e8c45fSAndroid Build Coastguard Worker     /* Toggle Caps Lock */
367*38e8c45fSAndroid Build Coastguard Worker     virtual void toggleCapsLockState(int32_t deviceId) = 0;
368*38e8c45fSAndroid Build Coastguard Worker 
369*38e8c45fSAndroid Build Coastguard Worker     /* Resets locked modifier state */
370*38e8c45fSAndroid Build Coastguard Worker     virtual void resetLockedModifierState() = 0;
371*38e8c45fSAndroid Build Coastguard Worker 
372*38e8c45fSAndroid Build Coastguard Worker     /* Determine whether physical keys exist for the given framework-domain key codes. */
373*38e8c45fSAndroid Build Coastguard Worker     virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask,
374*38e8c45fSAndroid Build Coastguard Worker                          const std::vector<int32_t>& keyCodes, uint8_t* outFlags) = 0;
375*38e8c45fSAndroid Build Coastguard Worker 
376*38e8c45fSAndroid Build Coastguard Worker     /* Requests that a reconfiguration of all input devices.
377*38e8c45fSAndroid Build Coastguard Worker      * The changes flag is a bitfield that indicates what has changed and whether
378*38e8c45fSAndroid Build Coastguard Worker      * the input devices must all be reopened. */
379*38e8c45fSAndroid Build Coastguard Worker     virtual void requestRefreshConfiguration(ConfigurationChanges changes) = 0;
380*38e8c45fSAndroid Build Coastguard Worker 
381*38e8c45fSAndroid Build Coastguard Worker     /* Controls the vibrator of a particular input device. */
382*38e8c45fSAndroid Build Coastguard Worker     virtual void vibrate(int32_t deviceId, const VibrationSequence& sequence, ssize_t repeat,
383*38e8c45fSAndroid Build Coastguard Worker                          int32_t token) = 0;
384*38e8c45fSAndroid Build Coastguard Worker     virtual void cancelVibrate(int32_t deviceId, int32_t token) = 0;
385*38e8c45fSAndroid Build Coastguard Worker 
386*38e8c45fSAndroid Build Coastguard Worker     virtual bool isVibrating(int32_t deviceId) = 0;
387*38e8c45fSAndroid Build Coastguard Worker 
388*38e8c45fSAndroid Build Coastguard Worker     virtual std::vector<int32_t> getVibratorIds(int32_t deviceId) = 0;
389*38e8c45fSAndroid Build Coastguard Worker     /* Get battery level of a particular input device. */
390*38e8c45fSAndroid Build Coastguard Worker     virtual std::optional<int32_t> getBatteryCapacity(int32_t deviceId) = 0;
391*38e8c45fSAndroid Build Coastguard Worker     /* Get battery status of a particular input device. */
392*38e8c45fSAndroid Build Coastguard Worker     virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId) = 0;
393*38e8c45fSAndroid Build Coastguard Worker     /* Get the device path for the battery of an input device. */
394*38e8c45fSAndroid Build Coastguard Worker     virtual std::optional<std::string> getBatteryDevicePath(int32_t deviceId) = 0;
395*38e8c45fSAndroid Build Coastguard Worker 
396*38e8c45fSAndroid Build Coastguard Worker     virtual std::vector<InputDeviceLightInfo> getLights(int32_t deviceId) = 0;
397*38e8c45fSAndroid Build Coastguard Worker 
398*38e8c45fSAndroid Build Coastguard Worker     virtual std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) = 0;
399*38e8c45fSAndroid Build Coastguard Worker 
400*38e8c45fSAndroid Build Coastguard Worker     virtual std::optional<HardwareProperties> getTouchpadHardwareProperties(int32_t deviceId) = 0;
401*38e8c45fSAndroid Build Coastguard Worker 
402*38e8c45fSAndroid Build Coastguard Worker     /* Return true if the device can send input events to the specified display. */
403*38e8c45fSAndroid Build Coastguard Worker     virtual bool canDispatchToDisplay(int32_t deviceId, ui::LogicalDisplayId displayId) = 0;
404*38e8c45fSAndroid Build Coastguard Worker 
405*38e8c45fSAndroid Build Coastguard Worker     /* Enable sensor in input reader mapper. */
406*38e8c45fSAndroid Build Coastguard Worker     virtual bool enableSensor(int32_t deviceId, InputDeviceSensorType sensorType,
407*38e8c45fSAndroid Build Coastguard Worker                               std::chrono::microseconds samplingPeriod,
408*38e8c45fSAndroid Build Coastguard Worker                               std::chrono::microseconds maxBatchReportLatency) = 0;
409*38e8c45fSAndroid Build Coastguard Worker 
410*38e8c45fSAndroid Build Coastguard Worker     /* Disable sensor in input reader mapper. */
411*38e8c45fSAndroid Build Coastguard Worker     virtual void disableSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0;
412*38e8c45fSAndroid Build Coastguard Worker 
413*38e8c45fSAndroid Build Coastguard Worker     /* Flush sensor data in input reader mapper. */
414*38e8c45fSAndroid Build Coastguard Worker     virtual void flushSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0;
415*38e8c45fSAndroid Build Coastguard Worker 
416*38e8c45fSAndroid Build Coastguard Worker     /* Set color for the light */
417*38e8c45fSAndroid Build Coastguard Worker     virtual bool setLightColor(int32_t deviceId, int32_t lightId, int32_t color) = 0;
418*38e8c45fSAndroid Build Coastguard Worker     /* Set player ID for the light */
419*38e8c45fSAndroid Build Coastguard Worker     virtual bool setLightPlayerId(int32_t deviceId, int32_t lightId, int32_t playerId) = 0;
420*38e8c45fSAndroid Build Coastguard Worker     /* Get light color */
421*38e8c45fSAndroid Build Coastguard Worker     virtual std::optional<int32_t> getLightColor(int32_t deviceId, int32_t lightId) = 0;
422*38e8c45fSAndroid Build Coastguard Worker     /* Get light player ID */
423*38e8c45fSAndroid Build Coastguard Worker     virtual std::optional<int32_t> getLightPlayerId(int32_t deviceId, int32_t lightId) = 0;
424*38e8c45fSAndroid Build Coastguard Worker 
425*38e8c45fSAndroid Build Coastguard Worker     /* Get the Bluetooth address of an input device, if known. */
426*38e8c45fSAndroid Build Coastguard Worker     virtual std::optional<std::string> getBluetoothAddress(int32_t deviceId) const = 0;
427*38e8c45fSAndroid Build Coastguard Worker 
428*38e8c45fSAndroid Build Coastguard Worker     /* Sysfs node change reported. Recreate device if required to incorporate the new sysfs nodes */
429*38e8c45fSAndroid Build Coastguard Worker     virtual void sysfsNodeChanged(const std::string& sysfsNodePath) = 0;
430*38e8c45fSAndroid Build Coastguard Worker 
431*38e8c45fSAndroid Build Coastguard Worker     /* Get the ID of the InputDevice that was used most recently.
432*38e8c45fSAndroid Build Coastguard Worker      *
433*38e8c45fSAndroid Build Coastguard Worker      * Returns ReservedInputDeviceId::INVALID_INPUT_DEVICE_ID if no device has been used since boot.
434*38e8c45fSAndroid Build Coastguard Worker      */
435*38e8c45fSAndroid Build Coastguard Worker     virtual DeviceId getLastUsedInputDeviceId() = 0;
436*38e8c45fSAndroid Build Coastguard Worker 
437*38e8c45fSAndroid Build Coastguard Worker     /* Notifies that mouse cursor faded due to typing. */
438*38e8c45fSAndroid Build Coastguard Worker     virtual void notifyMouseCursorFadedOnTyping() = 0;
439*38e8c45fSAndroid Build Coastguard Worker 
440*38e8c45fSAndroid Build Coastguard Worker     /* Set whether the given input device can wake up the kernel from sleep
441*38e8c45fSAndroid Build Coastguard Worker      * when it generates input events. By default, usually only internal (built-in)
442*38e8c45fSAndroid Build Coastguard Worker      * input devices can wake the kernel from sleep. For an external input device
443*38e8c45fSAndroid Build Coastguard Worker      * that supports remote wakeup to be able to wake the kernel, this must be called
444*38e8c45fSAndroid Build Coastguard Worker      * after each time the device is connected/added.
445*38e8c45fSAndroid Build Coastguard Worker      *
446*38e8c45fSAndroid Build Coastguard Worker      * Returns true if setting power wakeup was successful.
447*38e8c45fSAndroid Build Coastguard Worker      */
448*38e8c45fSAndroid Build Coastguard Worker     virtual bool setKernelWakeEnabled(int32_t deviceId, bool enabled) = 0;
449*38e8c45fSAndroid Build Coastguard Worker };
450*38e8c45fSAndroid Build Coastguard Worker 
451*38e8c45fSAndroid Build Coastguard Worker // --- TouchAffineTransformation ---
452*38e8c45fSAndroid Build Coastguard Worker 
453*38e8c45fSAndroid Build Coastguard Worker struct TouchAffineTransformation {
454*38e8c45fSAndroid Build Coastguard Worker     float x_scale;
455*38e8c45fSAndroid Build Coastguard Worker     float x_ymix;
456*38e8c45fSAndroid Build Coastguard Worker     float x_offset;
457*38e8c45fSAndroid Build Coastguard Worker     float y_xmix;
458*38e8c45fSAndroid Build Coastguard Worker     float y_scale;
459*38e8c45fSAndroid Build Coastguard Worker     float y_offset;
460*38e8c45fSAndroid Build Coastguard Worker 
TouchAffineTransformationTouchAffineTransformation461*38e8c45fSAndroid Build Coastguard Worker     TouchAffineTransformation() :
462*38e8c45fSAndroid Build Coastguard Worker         x_scale(1.0f), x_ymix(0.0f), x_offset(0.0f),
463*38e8c45fSAndroid Build Coastguard Worker         y_xmix(0.0f), y_scale(1.0f), y_offset(0.0f) {
464*38e8c45fSAndroid Build Coastguard Worker     }
465*38e8c45fSAndroid Build Coastguard Worker 
TouchAffineTransformationTouchAffineTransformation466*38e8c45fSAndroid Build Coastguard Worker     TouchAffineTransformation(float xscale, float xymix, float xoffset,
467*38e8c45fSAndroid Build Coastguard Worker             float yxmix, float yscale, float yoffset) :
468*38e8c45fSAndroid Build Coastguard Worker         x_scale(xscale), x_ymix(xymix), x_offset(xoffset),
469*38e8c45fSAndroid Build Coastguard Worker         y_xmix(yxmix), y_scale(yscale), y_offset(yoffset) {
470*38e8c45fSAndroid Build Coastguard Worker     }
471*38e8c45fSAndroid Build Coastguard Worker 
472*38e8c45fSAndroid Build Coastguard Worker     void applyTo(float& x, float& y) const;
473*38e8c45fSAndroid Build Coastguard Worker };
474*38e8c45fSAndroid Build Coastguard Worker 
475*38e8c45fSAndroid Build Coastguard Worker // --- InputReaderPolicyInterface ---
476*38e8c45fSAndroid Build Coastguard Worker 
477*38e8c45fSAndroid Build Coastguard Worker /*
478*38e8c45fSAndroid Build Coastguard Worker  * Input reader policy interface.
479*38e8c45fSAndroid Build Coastguard Worker  *
480*38e8c45fSAndroid Build Coastguard Worker  * The input reader policy is used by the input reader to interact with the Window Manager
481*38e8c45fSAndroid Build Coastguard Worker  * and other system components.
482*38e8c45fSAndroid Build Coastguard Worker  *
483*38e8c45fSAndroid Build Coastguard Worker  * The actual implementation is partially supported by callbacks into the DVM
484*38e8c45fSAndroid Build Coastguard Worker  * via JNI.  This interface is also mocked in the unit tests.
485*38e8c45fSAndroid Build Coastguard Worker  *
486*38e8c45fSAndroid Build Coastguard Worker  * These methods will NOT re-enter the input reader interface, so they may be called from
487*38e8c45fSAndroid Build Coastguard Worker  * any method in the input reader interface.
488*38e8c45fSAndroid Build Coastguard Worker  */
489*38e8c45fSAndroid Build Coastguard Worker class InputReaderPolicyInterface : public virtual RefBase {
490*38e8c45fSAndroid Build Coastguard Worker protected:
InputReaderPolicyInterface()491*38e8c45fSAndroid Build Coastguard Worker     InputReaderPolicyInterface() { }
~InputReaderPolicyInterface()492*38e8c45fSAndroid Build Coastguard Worker     virtual ~InputReaderPolicyInterface() { }
493*38e8c45fSAndroid Build Coastguard Worker 
494*38e8c45fSAndroid Build Coastguard Worker public:
495*38e8c45fSAndroid Build Coastguard Worker     /* Gets the input reader configuration. */
496*38e8c45fSAndroid Build Coastguard Worker     virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) = 0;
497*38e8c45fSAndroid Build Coastguard Worker 
498*38e8c45fSAndroid Build Coastguard Worker     /* Notifies the input reader policy that some input devices have changed
499*38e8c45fSAndroid Build Coastguard Worker      * and provides information about all current input devices.
500*38e8c45fSAndroid Build Coastguard Worker      */
501*38e8c45fSAndroid Build Coastguard Worker     virtual void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) = 0;
502*38e8c45fSAndroid Build Coastguard Worker 
503*38e8c45fSAndroid Build Coastguard Worker     /* Sends the hardware state of a connected touchpad */
504*38e8c45fSAndroid Build Coastguard Worker     virtual void notifyTouchpadHardwareState(const SelfContainedHardwareState& schs,
505*38e8c45fSAndroid Build Coastguard Worker                                              int32_t deviceId) = 0;
506*38e8c45fSAndroid Build Coastguard Worker 
507*38e8c45fSAndroid Build Coastguard Worker     /* Sends the Info of gestures that happen on the touchpad. */
508*38e8c45fSAndroid Build Coastguard Worker     virtual void notifyTouchpadGestureInfo(GestureType type, int32_t deviceId) = 0;
509*38e8c45fSAndroid Build Coastguard Worker 
510*38e8c45fSAndroid Build Coastguard Worker     /* Notifies the policy that the user has performed a three-finger touchpad tap. */
511*38e8c45fSAndroid Build Coastguard Worker     virtual void notifyTouchpadThreeFingerTap() = 0;
512*38e8c45fSAndroid Build Coastguard Worker 
513*38e8c45fSAndroid Build Coastguard Worker     /* Gets the keyboard layout for a particular input device. */
514*38e8c45fSAndroid Build Coastguard Worker     virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay(
515*38e8c45fSAndroid Build Coastguard Worker             const InputDeviceIdentifier& identifier,
516*38e8c45fSAndroid Build Coastguard Worker             const std::optional<KeyboardLayoutInfo> keyboardLayoutInfo) = 0;
517*38e8c45fSAndroid Build Coastguard Worker 
518*38e8c45fSAndroid Build Coastguard Worker     /* Gets a user-supplied alias for a particular input device, or an empty string if none. */
519*38e8c45fSAndroid Build Coastguard Worker     virtual std::string getDeviceAlias(const InputDeviceIdentifier& identifier) = 0;
520*38e8c45fSAndroid Build Coastguard Worker 
521*38e8c45fSAndroid Build Coastguard Worker     /* Gets the affine calibration associated with the specified device. */
522*38e8c45fSAndroid Build Coastguard Worker     virtual TouchAffineTransformation getTouchAffineTransformation(
523*38e8c45fSAndroid Build Coastguard Worker             const std::string& inputDeviceDescriptor, ui::Rotation surfaceRotation) = 0;
524*38e8c45fSAndroid Build Coastguard Worker     /* Notifies the input reader policy that a stylus gesture has started. */
525*38e8c45fSAndroid Build Coastguard Worker     virtual void notifyStylusGestureStarted(int32_t deviceId, nsecs_t eventTime) = 0;
526*38e8c45fSAndroid Build Coastguard Worker 
527*38e8c45fSAndroid Build Coastguard Worker     /* Returns true if any InputConnection is currently active. */
528*38e8c45fSAndroid Build Coastguard Worker     virtual bool isInputMethodConnectionActive() = 0;
529*38e8c45fSAndroid Build Coastguard Worker 
530*38e8c45fSAndroid Build Coastguard Worker     /* Gets the viewport of a particular display that the pointer device is associated with. If
531*38e8c45fSAndroid Build Coastguard Worker      * the pointer device is not associated with any display, it should ADISPLAY_IS_NONE to get
532*38e8c45fSAndroid Build Coastguard Worker      * the viewport that should be used. The device should get a new viewport using this method
533*38e8c45fSAndroid Build Coastguard Worker      * every time there is a display configuration change. The logical bounds of the viewport should
534*38e8c45fSAndroid Build Coastguard Worker      * be used as the range of possible values for pointing devices, like mice and touchpads.
535*38e8c45fSAndroid Build Coastguard Worker      */
536*38e8c45fSAndroid Build Coastguard Worker     virtual std::optional<DisplayViewport> getPointerViewportForAssociatedDisplay(
537*38e8c45fSAndroid Build Coastguard Worker             ui::LogicalDisplayId associatedDisplayId = ui::LogicalDisplayId::INVALID) = 0;
538*38e8c45fSAndroid Build Coastguard Worker };
539*38e8c45fSAndroid Build Coastguard Worker 
540*38e8c45fSAndroid Build Coastguard Worker } // namespace android
541