xref: /aosp_15_r20/frameworks/native/include/input/Input.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1*38e8c45fSAndroid Build Coastguard Worker /*
2*38e8c45fSAndroid Build Coastguard Worker  * Copyright (C) 2010 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 #pragma GCC system_header
20*38e8c45fSAndroid Build Coastguard Worker 
21*38e8c45fSAndroid Build Coastguard Worker /**
22*38e8c45fSAndroid Build Coastguard Worker  * Native input event structures.
23*38e8c45fSAndroid Build Coastguard Worker  */
24*38e8c45fSAndroid Build Coastguard Worker 
25*38e8c45fSAndroid Build Coastguard Worker #include <android/input.h>
26*38e8c45fSAndroid Build Coastguard Worker #ifdef __linux__
27*38e8c45fSAndroid Build Coastguard Worker #include <android/os/IInputConstants.h>
28*38e8c45fSAndroid Build Coastguard Worker #include <android/os/MotionEventFlag.h>
29*38e8c45fSAndroid Build Coastguard Worker #endif
30*38e8c45fSAndroid Build Coastguard Worker #include <android/os/PointerIconType.h>
31*38e8c45fSAndroid Build Coastguard Worker #include <math.h>
32*38e8c45fSAndroid Build Coastguard Worker #include <stdint.h>
33*38e8c45fSAndroid Build Coastguard Worker #include <ui/LogicalDisplayId.h>
34*38e8c45fSAndroid Build Coastguard Worker #include <ui/Transform.h>
35*38e8c45fSAndroid Build Coastguard Worker #include <utils/BitSet.h>
36*38e8c45fSAndroid Build Coastguard Worker #include <utils/Timers.h>
37*38e8c45fSAndroid Build Coastguard Worker #include <array>
38*38e8c45fSAndroid Build Coastguard Worker #include <limits>
39*38e8c45fSAndroid Build Coastguard Worker #include <queue>
40*38e8c45fSAndroid Build Coastguard Worker 
41*38e8c45fSAndroid Build Coastguard Worker /*
42*38e8c45fSAndroid Build Coastguard Worker  * Additional private constants not defined in ndk/ui/input.h.
43*38e8c45fSAndroid Build Coastguard Worker  */
44*38e8c45fSAndroid Build Coastguard Worker enum {
45*38e8c45fSAndroid Build Coastguard Worker 
46*38e8c45fSAndroid Build Coastguard Worker     /* This event was generated or modified by accessibility service. */
47*38e8c45fSAndroid Build Coastguard Worker     AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT =
48*38e8c45fSAndroid Build Coastguard Worker             android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT,
49*38e8c45fSAndroid Build Coastguard Worker 
50*38e8c45fSAndroid Build Coastguard Worker     /* Signifies that the key is being predispatched */
51*38e8c45fSAndroid Build Coastguard Worker     AKEY_EVENT_FLAG_PREDISPATCH = 0x20000000,
52*38e8c45fSAndroid Build Coastguard Worker 
53*38e8c45fSAndroid Build Coastguard Worker     /* Private control to determine when an app is tracking a key sequence. */
54*38e8c45fSAndroid Build Coastguard Worker     AKEY_EVENT_FLAG_START_TRACKING = 0x40000000,
55*38e8c45fSAndroid Build Coastguard Worker 
56*38e8c45fSAndroid Build Coastguard Worker     /* Key event is inconsistent with previously sent key events. */
57*38e8c45fSAndroid Build Coastguard Worker     AKEY_EVENT_FLAG_TAINTED = android::os::IInputConstants::INPUT_EVENT_FLAG_TAINTED,
58*38e8c45fSAndroid Build Coastguard Worker };
59*38e8c45fSAndroid Build Coastguard Worker 
60*38e8c45fSAndroid Build Coastguard Worker enum {
61*38e8c45fSAndroid Build Coastguard Worker     // AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED is defined in include/android/input.h
62*38e8c45fSAndroid Build Coastguard Worker     /**
63*38e8c45fSAndroid Build Coastguard Worker      * This flag indicates that the window that received this motion event is partly
64*38e8c45fSAndroid Build Coastguard Worker      * or wholly obscured by another visible window above it.  This flag is set to true
65*38e8c45fSAndroid Build Coastguard Worker      * even if the event did not directly pass through the obscured area.
66*38e8c45fSAndroid Build Coastguard Worker      * A security sensitive application can check this flag to identify situations in which
67*38e8c45fSAndroid Build Coastguard Worker      * a malicious application may have covered up part of its content for the purpose
68*38e8c45fSAndroid Build Coastguard Worker      * of misleading the user or hijacking touches.  An appropriate response might be
69*38e8c45fSAndroid Build Coastguard Worker      * to drop the suspect touches or to take additional precautions to confirm the user's
70*38e8c45fSAndroid Build Coastguard Worker      * actual intent.
71*38e8c45fSAndroid Build Coastguard Worker      */
72*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED =
73*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(android::os::MotionEventFlag::WINDOW_IS_PARTIALLY_OBSCURED),
74*38e8c45fSAndroid Build Coastguard Worker 
75*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_FLAG_HOVER_EXIT_PENDING =
76*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(android::os::MotionEventFlag::HOVER_EXIT_PENDING),
77*38e8c45fSAndroid Build Coastguard Worker 
78*38e8c45fSAndroid Build Coastguard Worker     /**
79*38e8c45fSAndroid Build Coastguard Worker      * This flag indicates that the event has been generated by a gesture generator. It
80*38e8c45fSAndroid Build Coastguard Worker      * provides a hint to the GestureDetector to not apply any touch slop.
81*38e8c45fSAndroid Build Coastguard Worker      */
82*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE =
83*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(android::os::MotionEventFlag::IS_GENERATED_GESTURE),
84*38e8c45fSAndroid Build Coastguard Worker 
85*38e8c45fSAndroid Build Coastguard Worker     /**
86*38e8c45fSAndroid Build Coastguard Worker      * This flag indicates that the event will not cause a focus change if it is directed to an
87*38e8c45fSAndroid Build Coastguard Worker      * unfocused window, even if it an ACTION_DOWN. This is typically used with pointer
88*38e8c45fSAndroid Build Coastguard Worker      * gestures to allow the user to direct gestures to an unfocused window without bringing it
89*38e8c45fSAndroid Build Coastguard Worker      * into focus.
90*38e8c45fSAndroid Build Coastguard Worker      */
91*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE =
92*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(android::os::MotionEventFlag::NO_FOCUS_CHANGE),
93*38e8c45fSAndroid Build Coastguard Worker 
94*38e8c45fSAndroid Build Coastguard Worker     /**
95*38e8c45fSAndroid Build Coastguard Worker      * This event was generated or modified by accessibility service.
96*38e8c45fSAndroid Build Coastguard Worker      */
97*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT =
98*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(android::os::MotionEventFlag::IS_ACCESSIBILITY_EVENT),
99*38e8c45fSAndroid Build Coastguard Worker 
100*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS =
101*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(android::os::MotionEventFlag::TARGET_ACCESSIBILITY_FOCUS),
102*38e8c45fSAndroid Build Coastguard Worker 
103*38e8c45fSAndroid Build Coastguard Worker     /* Motion event is inconsistent with previously sent motion events. */
104*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_FLAG_TAINTED = static_cast<int32_t>(android::os::MotionEventFlag::TAINTED),
105*38e8c45fSAndroid Build Coastguard Worker 
106*38e8c45fSAndroid Build Coastguard Worker     /** Private flag, not used in Java. */
107*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_ORIENTATION =
108*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(android::os::MotionEventFlag::PRIVATE_FLAG_SUPPORTS_ORIENTATION),
109*38e8c45fSAndroid Build Coastguard Worker 
110*38e8c45fSAndroid Build Coastguard Worker     /** Private flag, not used in Java. */
111*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION = static_cast<int32_t>(
112*38e8c45fSAndroid Build Coastguard Worker             android::os::MotionEventFlag::PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION),
113*38e8c45fSAndroid Build Coastguard Worker 
114*38e8c45fSAndroid Build Coastguard Worker     /** Mask for all private flags that are not used in Java. */
115*38e8c45fSAndroid Build Coastguard Worker     AMOTION_EVENT_PRIVATE_FLAG_MASK = AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_ORIENTATION |
116*38e8c45fSAndroid Build Coastguard Worker             AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION,
117*38e8c45fSAndroid Build Coastguard Worker };
118*38e8c45fSAndroid Build Coastguard Worker 
119*38e8c45fSAndroid Build Coastguard Worker /**
120*38e8c45fSAndroid Build Coastguard Worker  * Allowed VerifiedKeyEvent flags. All other flags from KeyEvent do not get verified.
121*38e8c45fSAndroid Build Coastguard Worker  * These values must be kept in sync with VerifiedKeyEvent.java
122*38e8c45fSAndroid Build Coastguard Worker  */
123*38e8c45fSAndroid Build Coastguard Worker constexpr int32_t VERIFIED_KEY_EVENT_FLAGS =
124*38e8c45fSAndroid Build Coastguard Worker         AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT;
125*38e8c45fSAndroid Build Coastguard Worker 
126*38e8c45fSAndroid Build Coastguard Worker /**
127*38e8c45fSAndroid Build Coastguard Worker  * Allowed VerifiedMotionEventFlags. All other flags from MotionEvent do not get verified.
128*38e8c45fSAndroid Build Coastguard Worker  * These values must be kept in sync with VerifiedMotionEvent.java
129*38e8c45fSAndroid Build Coastguard Worker  */
130*38e8c45fSAndroid Build Coastguard Worker constexpr int32_t VERIFIED_MOTION_EVENT_FLAGS = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED |
131*38e8c45fSAndroid Build Coastguard Worker         AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED | AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT;
132*38e8c45fSAndroid Build Coastguard Worker 
133*38e8c45fSAndroid Build Coastguard Worker /**
134*38e8c45fSAndroid Build Coastguard Worker  * This flag indicates that the point up event has been canceled.
135*38e8c45fSAndroid Build Coastguard Worker  * Typically this is used for palm event when the user has accidental touches.
136*38e8c45fSAndroid Build Coastguard Worker  * TODO(b/338143308): Add this to NDK
137*38e8c45fSAndroid Build Coastguard Worker  */
138*38e8c45fSAndroid Build Coastguard Worker constexpr int32_t AMOTION_EVENT_FLAG_CANCELED =
139*38e8c45fSAndroid Build Coastguard Worker         android::os::IInputConstants::INPUT_EVENT_FLAG_CANCELED;
140*38e8c45fSAndroid Build Coastguard Worker 
141*38e8c45fSAndroid Build Coastguard Worker enum {
142*38e8c45fSAndroid Build Coastguard Worker     /*
143*38e8c45fSAndroid Build Coastguard Worker      * Indicates that an input device has switches.
144*38e8c45fSAndroid Build Coastguard Worker      * This input source flag is hidden from the API because switches are only used by the system
145*38e8c45fSAndroid Build Coastguard Worker      * and applications have no way to interact with them.
146*38e8c45fSAndroid Build Coastguard Worker      */
147*38e8c45fSAndroid Build Coastguard Worker     AINPUT_SOURCE_SWITCH = 0x80000000,
148*38e8c45fSAndroid Build Coastguard Worker };
149*38e8c45fSAndroid Build Coastguard Worker 
150*38e8c45fSAndroid Build Coastguard Worker enum {
151*38e8c45fSAndroid Build Coastguard Worker     /**
152*38e8c45fSAndroid Build Coastguard Worker      * Constants for LEDs. Hidden from the API since we don't actually expose a way to interact
153*38e8c45fSAndroid Build Coastguard Worker      * with LEDs to developers
154*38e8c45fSAndroid Build Coastguard Worker      *
155*38e8c45fSAndroid Build Coastguard Worker      * NOTE: If you add LEDs here, you must also add them to InputEventLabels.h
156*38e8c45fSAndroid Build Coastguard Worker      */
157*38e8c45fSAndroid Build Coastguard Worker 
158*38e8c45fSAndroid Build Coastguard Worker     ALED_NUM_LOCK = 0x00,
159*38e8c45fSAndroid Build Coastguard Worker     ALED_CAPS_LOCK = 0x01,
160*38e8c45fSAndroid Build Coastguard Worker     ALED_SCROLL_LOCK = 0x02,
161*38e8c45fSAndroid Build Coastguard Worker     ALED_COMPOSE = 0x03,
162*38e8c45fSAndroid Build Coastguard Worker     ALED_KANA = 0x04,
163*38e8c45fSAndroid Build Coastguard Worker     ALED_SLEEP = 0x05,
164*38e8c45fSAndroid Build Coastguard Worker     ALED_SUSPEND = 0x06,
165*38e8c45fSAndroid Build Coastguard Worker     ALED_MUTE = 0x07,
166*38e8c45fSAndroid Build Coastguard Worker     ALED_MISC = 0x08,
167*38e8c45fSAndroid Build Coastguard Worker     ALED_MAIL = 0x09,
168*38e8c45fSAndroid Build Coastguard Worker     ALED_CHARGING = 0x0a,
169*38e8c45fSAndroid Build Coastguard Worker     ALED_CONTROLLER_1 = 0x10,
170*38e8c45fSAndroid Build Coastguard Worker     ALED_CONTROLLER_2 = 0x11,
171*38e8c45fSAndroid Build Coastguard Worker     ALED_CONTROLLER_3 = 0x12,
172*38e8c45fSAndroid Build Coastguard Worker     ALED_CONTROLLER_4 = 0x13,
173*38e8c45fSAndroid Build Coastguard Worker };
174*38e8c45fSAndroid Build Coastguard Worker 
175*38e8c45fSAndroid Build Coastguard Worker /* Maximum number of controller LEDs we support */
176*38e8c45fSAndroid Build Coastguard Worker #define MAX_CONTROLLER_LEDS 4
177*38e8c45fSAndroid Build Coastguard Worker 
178*38e8c45fSAndroid Build Coastguard Worker /*
179*38e8c45fSAndroid Build Coastguard Worker  * Maximum number of pointers supported per motion event.
180*38e8c45fSAndroid Build Coastguard Worker  * Smallest number of pointers is 1.
181*38e8c45fSAndroid Build Coastguard Worker  * (We want at least 10 but some touch controllers obstensibly configured for 10 pointers
182*38e8c45fSAndroid Build Coastguard Worker  * will occasionally emit 11.  There is not much harm making this constant bigger.)
183*38e8c45fSAndroid Build Coastguard Worker  */
184*38e8c45fSAndroid Build Coastguard Worker static constexpr size_t MAX_POINTERS = 16;
185*38e8c45fSAndroid Build Coastguard Worker 
186*38e8c45fSAndroid Build Coastguard Worker /*
187*38e8c45fSAndroid Build Coastguard Worker  * Maximum number of samples supported per motion event.
188*38e8c45fSAndroid Build Coastguard Worker  */
189*38e8c45fSAndroid Build Coastguard Worker #define MAX_SAMPLES UINT16_MAX
190*38e8c45fSAndroid Build Coastguard Worker 
191*38e8c45fSAndroid Build Coastguard Worker /*
192*38e8c45fSAndroid Build Coastguard Worker  * Maximum pointer id value supported in a motion event.
193*38e8c45fSAndroid Build Coastguard Worker  * Smallest pointer id is 0.
194*38e8c45fSAndroid Build Coastguard Worker  * (This is limited by our use of BitSet32 to track pointer assignments.)
195*38e8c45fSAndroid Build Coastguard Worker  */
196*38e8c45fSAndroid Build Coastguard Worker #define MAX_POINTER_ID 31
197*38e8c45fSAndroid Build Coastguard Worker 
198*38e8c45fSAndroid Build Coastguard Worker /*
199*38e8c45fSAndroid Build Coastguard Worker  * Number of high resolution scroll units for one detent (scroll wheel click), as defined in
200*38e8c45fSAndroid Build Coastguard Worker  * evdev. This is relevant when an input device is emitting REL_WHEEL_HI_RES or REL_HWHEEL_HI_RES
201*38e8c45fSAndroid Build Coastguard Worker  * events.
202*38e8c45fSAndroid Build Coastguard Worker  */
203*38e8c45fSAndroid Build Coastguard Worker constexpr int32_t kEvdevHighResScrollUnitsPerDetent = 120;
204*38e8c45fSAndroid Build Coastguard Worker 
205*38e8c45fSAndroid Build Coastguard Worker /*
206*38e8c45fSAndroid Build Coastguard Worker  * Declare a concrete type for the NDK's input event forward declaration.
207*38e8c45fSAndroid Build Coastguard Worker  */
208*38e8c45fSAndroid Build Coastguard Worker struct AInputEvent {
~AInputEventAInputEvent209*38e8c45fSAndroid Build Coastguard Worker     virtual ~AInputEvent() {}
210*38e8c45fSAndroid Build Coastguard Worker     bool operator==(const AInputEvent&) const = default;
211*38e8c45fSAndroid Build Coastguard Worker };
212*38e8c45fSAndroid Build Coastguard Worker 
213*38e8c45fSAndroid Build Coastguard Worker /*
214*38e8c45fSAndroid Build Coastguard Worker  * Declare a concrete type for the NDK's input device forward declaration.
215*38e8c45fSAndroid Build Coastguard Worker  */
216*38e8c45fSAndroid Build Coastguard Worker struct AInputDevice {
~AInputDeviceAInputDevice217*38e8c45fSAndroid Build Coastguard Worker     virtual ~AInputDevice() { }
218*38e8c45fSAndroid Build Coastguard Worker };
219*38e8c45fSAndroid Build Coastguard Worker 
220*38e8c45fSAndroid Build Coastguard Worker 
221*38e8c45fSAndroid Build Coastguard Worker namespace android {
222*38e8c45fSAndroid Build Coastguard Worker 
223*38e8c45fSAndroid Build Coastguard Worker class Parcel;
224*38e8c45fSAndroid Build Coastguard Worker 
225*38e8c45fSAndroid Build Coastguard Worker /*
226*38e8c45fSAndroid Build Coastguard Worker  * Apply the given transform to the point without applying any translation/offset.
227*38e8c45fSAndroid Build Coastguard Worker  */
228*38e8c45fSAndroid Build Coastguard Worker vec2 transformWithoutTranslation(const ui::Transform& transform, const vec2& xy);
229*38e8c45fSAndroid Build Coastguard Worker 
230*38e8c45fSAndroid Build Coastguard Worker /*
231*38e8c45fSAndroid Build Coastguard Worker  * Transform an angle on the x-y plane. An angle of 0 radians corresponds to "north" or
232*38e8c45fSAndroid Build Coastguard Worker  * pointing upwards in the negative Y direction, a positive angle points towards the right, and a
233*38e8c45fSAndroid Build Coastguard Worker  * negative angle points towards the left.
234*38e8c45fSAndroid Build Coastguard Worker  *
235*38e8c45fSAndroid Build Coastguard Worker  * If the angle represents a direction that needs to be preserved, set isDirectional to true to get
236*38e8c45fSAndroid Build Coastguard Worker  * an output range of [-pi, pi]. If the angle's direction does not need to be preserved, set
237*38e8c45fSAndroid Build Coastguard Worker  * isDirectional to false to get an output range of [-pi/2, pi/2].
238*38e8c45fSAndroid Build Coastguard Worker  */
239*38e8c45fSAndroid Build Coastguard Worker float transformAngle(const ui::Transform& transform, float angleRadians, bool isDirectional);
240*38e8c45fSAndroid Build Coastguard Worker 
241*38e8c45fSAndroid Build Coastguard Worker /**
242*38e8c45fSAndroid Build Coastguard Worker  * The type of the InputEvent.
243*38e8c45fSAndroid Build Coastguard Worker  * This should have 1:1 correspondence with the values of anonymous enum defined in input.h.
244*38e8c45fSAndroid Build Coastguard Worker  */
245*38e8c45fSAndroid Build Coastguard Worker enum class InputEventType {
246*38e8c45fSAndroid Build Coastguard Worker     KEY = AINPUT_EVENT_TYPE_KEY,
247*38e8c45fSAndroid Build Coastguard Worker     MOTION = AINPUT_EVENT_TYPE_MOTION,
248*38e8c45fSAndroid Build Coastguard Worker     FOCUS = AINPUT_EVENT_TYPE_FOCUS,
249*38e8c45fSAndroid Build Coastguard Worker     CAPTURE = AINPUT_EVENT_TYPE_CAPTURE,
250*38e8c45fSAndroid Build Coastguard Worker     DRAG = AINPUT_EVENT_TYPE_DRAG,
251*38e8c45fSAndroid Build Coastguard Worker     TOUCH_MODE = AINPUT_EVENT_TYPE_TOUCH_MODE,
252*38e8c45fSAndroid Build Coastguard Worker     ftl_first = KEY,
253*38e8c45fSAndroid Build Coastguard Worker     ftl_last = TOUCH_MODE,
254*38e8c45fSAndroid Build Coastguard Worker     // Used by LatencyTracker fuzzer
255*38e8c45fSAndroid Build Coastguard Worker     kMaxValue = ftl_last
256*38e8c45fSAndroid Build Coastguard Worker };
257*38e8c45fSAndroid Build Coastguard Worker 
258*38e8c45fSAndroid Build Coastguard Worker std::string inputEventSourceToString(int32_t source);
259*38e8c45fSAndroid Build Coastguard Worker 
260*38e8c45fSAndroid Build Coastguard Worker bool isFromSource(uint32_t source, uint32_t test);
261*38e8c45fSAndroid Build Coastguard Worker 
262*38e8c45fSAndroid Build Coastguard Worker /**
263*38e8c45fSAndroid Build Coastguard Worker  * The pointer tool type.
264*38e8c45fSAndroid Build Coastguard Worker  */
265*38e8c45fSAndroid Build Coastguard Worker enum class ToolType {
266*38e8c45fSAndroid Build Coastguard Worker     UNKNOWN = AMOTION_EVENT_TOOL_TYPE_UNKNOWN,
267*38e8c45fSAndroid Build Coastguard Worker     FINGER = AMOTION_EVENT_TOOL_TYPE_FINGER,
268*38e8c45fSAndroid Build Coastguard Worker     STYLUS = AMOTION_EVENT_TOOL_TYPE_STYLUS,
269*38e8c45fSAndroid Build Coastguard Worker     MOUSE = AMOTION_EVENT_TOOL_TYPE_MOUSE,
270*38e8c45fSAndroid Build Coastguard Worker     ERASER = AMOTION_EVENT_TOOL_TYPE_ERASER,
271*38e8c45fSAndroid Build Coastguard Worker     PALM = AMOTION_EVENT_TOOL_TYPE_PALM,
272*38e8c45fSAndroid Build Coastguard Worker     ftl_first = UNKNOWN,
273*38e8c45fSAndroid Build Coastguard Worker     ftl_last = PALM,
274*38e8c45fSAndroid Build Coastguard Worker };
275*38e8c45fSAndroid Build Coastguard Worker 
276*38e8c45fSAndroid Build Coastguard Worker /**
277*38e8c45fSAndroid Build Coastguard Worker  * The state of the key. This should have 1:1 correspondence with the values of anonymous enum
278*38e8c45fSAndroid Build Coastguard Worker  * defined in input.h
279*38e8c45fSAndroid Build Coastguard Worker  */
280*38e8c45fSAndroid Build Coastguard Worker enum class KeyState {
281*38e8c45fSAndroid Build Coastguard Worker     UNKNOWN = AKEY_STATE_UNKNOWN,
282*38e8c45fSAndroid Build Coastguard Worker     UP = AKEY_STATE_UP,
283*38e8c45fSAndroid Build Coastguard Worker     DOWN = AKEY_STATE_DOWN,
284*38e8c45fSAndroid Build Coastguard Worker     VIRTUAL = AKEY_STATE_VIRTUAL,
285*38e8c45fSAndroid Build Coastguard Worker     ftl_first = UNKNOWN,
286*38e8c45fSAndroid Build Coastguard Worker     ftl_last = VIRTUAL,
287*38e8c45fSAndroid Build Coastguard Worker };
288*38e8c45fSAndroid Build Coastguard Worker 
289*38e8c45fSAndroid Build Coastguard Worker /**
290*38e8c45fSAndroid Build Coastguard Worker  * The keyboard type. This should have 1:1 correspondence with the values of anonymous enum
291*38e8c45fSAndroid Build Coastguard Worker  * defined in input.h
292*38e8c45fSAndroid Build Coastguard Worker  */
293*38e8c45fSAndroid Build Coastguard Worker enum class KeyboardType {
294*38e8c45fSAndroid Build Coastguard Worker     NONE = AINPUT_KEYBOARD_TYPE_NONE,
295*38e8c45fSAndroid Build Coastguard Worker     NON_ALPHABETIC = AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC,
296*38e8c45fSAndroid Build Coastguard Worker     ALPHABETIC = AINPUT_KEYBOARD_TYPE_ALPHABETIC,
297*38e8c45fSAndroid Build Coastguard Worker     ftl_first = NONE,
298*38e8c45fSAndroid Build Coastguard Worker     ftl_last = ALPHABETIC,
299*38e8c45fSAndroid Build Coastguard Worker };
300*38e8c45fSAndroid Build Coastguard Worker 
301*38e8c45fSAndroid Build Coastguard Worker bool isStylusToolType(ToolType toolType);
302*38e8c45fSAndroid Build Coastguard Worker 
303*38e8c45fSAndroid Build Coastguard Worker struct PointerProperties;
304*38e8c45fSAndroid Build Coastguard Worker 
305*38e8c45fSAndroid Build Coastguard Worker bool isStylusEvent(uint32_t source, const std::vector<PointerProperties>& properties);
306*38e8c45fSAndroid Build Coastguard Worker 
307*38e8c45fSAndroid Build Coastguard Worker /*
308*38e8c45fSAndroid Build Coastguard Worker  * Flags that flow alongside events in the input dispatch system to help with certain
309*38e8c45fSAndroid Build Coastguard Worker  * policy decisions such as waking from device sleep.
310*38e8c45fSAndroid Build Coastguard Worker  *
311*38e8c45fSAndroid Build Coastguard Worker  * These flags are also defined in frameworks/base/core/java/android/view/WindowManagerPolicy.java.
312*38e8c45fSAndroid Build Coastguard Worker  */
313*38e8c45fSAndroid Build Coastguard Worker enum {
314*38e8c45fSAndroid Build Coastguard Worker     /* These flags originate in RawEvents and are generally set in the key map.
315*38e8c45fSAndroid Build Coastguard Worker      * NOTE: If you want a flag to be able to set in a keylayout file, then you must add it to
316*38e8c45fSAndroid Build Coastguard Worker      * InputEventLabels.h as well. */
317*38e8c45fSAndroid Build Coastguard Worker 
318*38e8c45fSAndroid Build Coastguard Worker     // Indicates that the event should wake the device.
319*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_WAKE = 0x00000001,
320*38e8c45fSAndroid Build Coastguard Worker 
321*38e8c45fSAndroid Build Coastguard Worker     // Indicates that the key is virtual, such as a capacitive button, and should
322*38e8c45fSAndroid Build Coastguard Worker     // generate haptic feedback.  Virtual keys may be suppressed for some time
323*38e8c45fSAndroid Build Coastguard Worker     // after a recent touch to prevent accidental activation of virtual keys adjacent
324*38e8c45fSAndroid Build Coastguard Worker     // to the touch screen during an edge swipe.
325*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_VIRTUAL = 0x00000002,
326*38e8c45fSAndroid Build Coastguard Worker 
327*38e8c45fSAndroid Build Coastguard Worker     // Indicates that the key is the special function modifier.
328*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_FUNCTION = 0x00000004,
329*38e8c45fSAndroid Build Coastguard Worker 
330*38e8c45fSAndroid Build Coastguard Worker     // Indicates that the key represents a special gesture that has been detected by
331*38e8c45fSAndroid Build Coastguard Worker     // the touch firmware or driver.  Causes touch events from the same device to be canceled.
332*38e8c45fSAndroid Build Coastguard Worker     // This policy flag prevents key events from changing touch mode state.
333*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_GESTURE = 0x00000008,
334*38e8c45fSAndroid Build Coastguard Worker 
335*38e8c45fSAndroid Build Coastguard Worker     // Indicates that key usage mapping represents a fallback mapping.
336*38e8c45fSAndroid Build Coastguard Worker     // Fallback mappings cannot be used to definitively determine whether a device
337*38e8c45fSAndroid Build Coastguard Worker     // supports a key code. For example, a HID device can report a key press
338*38e8c45fSAndroid Build Coastguard Worker     // as a HID usage code if it is not mapped to any linux key code in the kernel.
339*38e8c45fSAndroid Build Coastguard Worker     // However, we cannot know which HID usage codes that device supports from
340*38e8c45fSAndroid Build Coastguard Worker     // userspace through the evdev. We can use fallback mappings to convert HID
341*38e8c45fSAndroid Build Coastguard Worker     // usage codes to Android key codes without needing to know if a device can
342*38e8c45fSAndroid Build Coastguard Worker     // actually report the usage code.
343*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_FALLBACK_USAGE_MAPPING = 0x00000010,
344*38e8c45fSAndroid Build Coastguard Worker 
345*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_RAW_MASK = 0x0000ffff,
346*38e8c45fSAndroid Build Coastguard Worker 
347*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY =
348*38e8c45fSAndroid Build Coastguard Worker             android::os::IInputConstants::POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY,
349*38e8c45fSAndroid Build Coastguard Worker 
350*38e8c45fSAndroid Build Coastguard Worker     /* These flags are set by the input dispatcher. */
351*38e8c45fSAndroid Build Coastguard Worker 
352*38e8c45fSAndroid Build Coastguard Worker     // Indicates that the input event was injected.
353*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_INJECTED = 0x01000000,
354*38e8c45fSAndroid Build Coastguard Worker 
355*38e8c45fSAndroid Build Coastguard Worker     // Indicates that the input event is from a trusted source such as a directly attached
356*38e8c45fSAndroid Build Coastguard Worker     // input device or an application with system-wide event injection permission.
357*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_TRUSTED = 0x02000000,
358*38e8c45fSAndroid Build Coastguard Worker 
359*38e8c45fSAndroid Build Coastguard Worker     // Indicates that the input event has passed through an input filter.
360*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_FILTERED = 0x04000000,
361*38e8c45fSAndroid Build Coastguard Worker 
362*38e8c45fSAndroid Build Coastguard Worker     // Disables automatic key repeating behavior.
363*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_DISABLE_KEY_REPEAT = 0x08000000,
364*38e8c45fSAndroid Build Coastguard Worker 
365*38e8c45fSAndroid Build Coastguard Worker     /* These flags are set by the input reader policy as it intercepts each event. */
366*38e8c45fSAndroid Build Coastguard Worker 
367*38e8c45fSAndroid Build Coastguard Worker     // Indicates that the device was in an interactive state when the
368*38e8c45fSAndroid Build Coastguard Worker     // event was intercepted.
369*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_INTERACTIVE = 0x20000000,
370*38e8c45fSAndroid Build Coastguard Worker 
371*38e8c45fSAndroid Build Coastguard Worker     // Indicates that the event should be dispatched to applications.
372*38e8c45fSAndroid Build Coastguard Worker     // The input event should still be sent to the InputDispatcher so that it can see all
373*38e8c45fSAndroid Build Coastguard Worker     // input events received include those that it will not deliver.
374*38e8c45fSAndroid Build Coastguard Worker     POLICY_FLAG_PASS_TO_USER = 0x40000000,
375*38e8c45fSAndroid Build Coastguard Worker };
376*38e8c45fSAndroid Build Coastguard Worker 
377*38e8c45fSAndroid Build Coastguard Worker /**
378*38e8c45fSAndroid Build Coastguard Worker  * Classifications of the current gesture, if available.
379*38e8c45fSAndroid Build Coastguard Worker  */
380*38e8c45fSAndroid Build Coastguard Worker enum class MotionClassification : uint8_t {
381*38e8c45fSAndroid Build Coastguard Worker     /**
382*38e8c45fSAndroid Build Coastguard Worker      * No classification is available.
383*38e8c45fSAndroid Build Coastguard Worker      */
384*38e8c45fSAndroid Build Coastguard Worker     NONE = AMOTION_EVENT_CLASSIFICATION_NONE,
385*38e8c45fSAndroid Build Coastguard Worker     /**
386*38e8c45fSAndroid Build Coastguard Worker      * Too early to classify the current gesture. Need more events. Look for changes in the
387*38e8c45fSAndroid Build Coastguard Worker      * upcoming motion events.
388*38e8c45fSAndroid Build Coastguard Worker      */
389*38e8c45fSAndroid Build Coastguard Worker     AMBIGUOUS_GESTURE = AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE,
390*38e8c45fSAndroid Build Coastguard Worker     /**
391*38e8c45fSAndroid Build Coastguard Worker      * The current gesture likely represents a user intentionally exerting force on the touchscreen.
392*38e8c45fSAndroid Build Coastguard Worker      */
393*38e8c45fSAndroid Build Coastguard Worker     DEEP_PRESS = AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS,
394*38e8c45fSAndroid Build Coastguard Worker     /**
395*38e8c45fSAndroid Build Coastguard Worker      * The current gesture represents the user swiping with two fingers on a touchpad.
396*38e8c45fSAndroid Build Coastguard Worker      */
397*38e8c45fSAndroid Build Coastguard Worker     TWO_FINGER_SWIPE = AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE,
398*38e8c45fSAndroid Build Coastguard Worker     /**
399*38e8c45fSAndroid Build Coastguard Worker      * The current gesture represents the user swiping with three or more fingers on a touchpad.
400*38e8c45fSAndroid Build Coastguard Worker      * Unlike two-finger swipes, these are only to be handled by the system UI, which is why they
401*38e8c45fSAndroid Build Coastguard Worker      * have a separate constant from two-finger swipes.
402*38e8c45fSAndroid Build Coastguard Worker      */
403*38e8c45fSAndroid Build Coastguard Worker     MULTI_FINGER_SWIPE = AMOTION_EVENT_CLASSIFICATION_MULTI_FINGER_SWIPE,
404*38e8c45fSAndroid Build Coastguard Worker     /**
405*38e8c45fSAndroid Build Coastguard Worker      * The current gesture represents the user pinching with two fingers on a touchpad. The gesture
406*38e8c45fSAndroid Build Coastguard Worker      * is centered around the current cursor position.
407*38e8c45fSAndroid Build Coastguard Worker      */
408*38e8c45fSAndroid Build Coastguard Worker     PINCH = AMOTION_EVENT_CLASSIFICATION_PINCH,
409*38e8c45fSAndroid Build Coastguard Worker };
410*38e8c45fSAndroid Build Coastguard Worker 
411*38e8c45fSAndroid Build Coastguard Worker /**
412*38e8c45fSAndroid Build Coastguard Worker  * String representation of MotionClassification
413*38e8c45fSAndroid Build Coastguard Worker  */
414*38e8c45fSAndroid Build Coastguard Worker const char* motionClassificationToString(MotionClassification classification);
415*38e8c45fSAndroid Build Coastguard Worker 
416*38e8c45fSAndroid Build Coastguard Worker /**
417*38e8c45fSAndroid Build Coastguard Worker  * Portion of FrameMetrics timeline of interest to input code.
418*38e8c45fSAndroid Build Coastguard Worker  */
419*38e8c45fSAndroid Build Coastguard Worker enum GraphicsTimeline : size_t {
420*38e8c45fSAndroid Build Coastguard Worker     /** Time when the app sent the buffer to SurfaceFlinger. */
421*38e8c45fSAndroid Build Coastguard Worker     GPU_COMPLETED_TIME = 0,
422*38e8c45fSAndroid Build Coastguard Worker 
423*38e8c45fSAndroid Build Coastguard Worker     /** Time when the frame was presented on the display */
424*38e8c45fSAndroid Build Coastguard Worker     PRESENT_TIME = 1,
425*38e8c45fSAndroid Build Coastguard Worker 
426*38e8c45fSAndroid Build Coastguard Worker     /** Total size of the 'GraphicsTimeline' array. Must always be last. */
427*38e8c45fSAndroid Build Coastguard Worker     SIZE = 2
428*38e8c45fSAndroid Build Coastguard Worker };
429*38e8c45fSAndroid Build Coastguard Worker 
430*38e8c45fSAndroid Build Coastguard Worker /**
431*38e8c45fSAndroid Build Coastguard Worker  * Generator of unique numbers used to identify input events.
432*38e8c45fSAndroid Build Coastguard Worker  *
433*38e8c45fSAndroid Build Coastguard Worker  * Layout of ID:
434*38e8c45fSAndroid Build Coastguard Worker  *     |--------------------------|---------------------------|
435*38e8c45fSAndroid Build Coastguard Worker  *     |   2 bits for source      | 30 bits for random number |
436*38e8c45fSAndroid Build Coastguard Worker  *     |--------------------------|---------------------------|
437*38e8c45fSAndroid Build Coastguard Worker  */
438*38e8c45fSAndroid Build Coastguard Worker class IdGenerator {
439*38e8c45fSAndroid Build Coastguard Worker private:
440*38e8c45fSAndroid Build Coastguard Worker     static constexpr uint32_t SOURCE_SHIFT = 30;
441*38e8c45fSAndroid Build Coastguard Worker 
442*38e8c45fSAndroid Build Coastguard Worker public:
443*38e8c45fSAndroid Build Coastguard Worker     // Used to divide integer space to ensure no conflict among these sources./
444*38e8c45fSAndroid Build Coastguard Worker     enum class Source : int32_t {
445*38e8c45fSAndroid Build Coastguard Worker         INPUT_READER = static_cast<int32_t>(0x0u << SOURCE_SHIFT),
446*38e8c45fSAndroid Build Coastguard Worker         INPUT_DISPATCHER = static_cast<int32_t>(0x1u << SOURCE_SHIFT),
447*38e8c45fSAndroid Build Coastguard Worker         OTHER = static_cast<int32_t>(0x3u << SOURCE_SHIFT), // E.g. app injected events
448*38e8c45fSAndroid Build Coastguard Worker     };
449*38e8c45fSAndroid Build Coastguard Worker     IdGenerator(Source source);
450*38e8c45fSAndroid Build Coastguard Worker 
451*38e8c45fSAndroid Build Coastguard Worker     int32_t nextId() const;
452*38e8c45fSAndroid Build Coastguard Worker 
453*38e8c45fSAndroid Build Coastguard Worker     // Extract source from given id.
getSource(int32_t id)454*38e8c45fSAndroid Build Coastguard Worker     static inline Source getSource(int32_t id) { return static_cast<Source>(SOURCE_MASK & id); }
455*38e8c45fSAndroid Build Coastguard Worker 
456*38e8c45fSAndroid Build Coastguard Worker private:
457*38e8c45fSAndroid Build Coastguard Worker     const Source mSource;
458*38e8c45fSAndroid Build Coastguard Worker 
459*38e8c45fSAndroid Build Coastguard Worker     static constexpr int32_t SOURCE_MASK = static_cast<int32_t>(0x3u << SOURCE_SHIFT);
460*38e8c45fSAndroid Build Coastguard Worker };
461*38e8c45fSAndroid Build Coastguard Worker 
462*38e8c45fSAndroid Build Coastguard Worker /**
463*38e8c45fSAndroid Build Coastguard Worker  * Invalid value for cursor position. Used for non-mouse events, tests and injected events. Don't
464*38e8c45fSAndroid Build Coastguard Worker  * use it for direct comparison with any other value, because NaN isn't equal to itself according to
465*38e8c45fSAndroid Build Coastguard Worker  * IEEE 754. Use isnan() instead to check if a cursor position is valid.
466*38e8c45fSAndroid Build Coastguard Worker  */
467*38e8c45fSAndroid Build Coastguard Worker constexpr float AMOTION_EVENT_INVALID_CURSOR_POSITION = std::numeric_limits<float>::quiet_NaN();
468*38e8c45fSAndroid Build Coastguard Worker 
469*38e8c45fSAndroid Build Coastguard Worker /*
470*38e8c45fSAndroid Build Coastguard Worker  * Pointer coordinate data.
471*38e8c45fSAndroid Build Coastguard Worker  */
472*38e8c45fSAndroid Build Coastguard Worker struct PointerCoords {
473*38e8c45fSAndroid Build Coastguard Worker     enum { MAX_AXES = 30 }; // 30 so that sizeof(PointerCoords) == 136
474*38e8c45fSAndroid Build Coastguard Worker 
475*38e8c45fSAndroid Build Coastguard Worker     // Bitfield of axes that are present in this structure.
476*38e8c45fSAndroid Build Coastguard Worker     uint64_t bits __attribute__((aligned(8)));
477*38e8c45fSAndroid Build Coastguard Worker 
478*38e8c45fSAndroid Build Coastguard Worker     // Values of axes that are stored in this structure packed in order by axis id
479*38e8c45fSAndroid Build Coastguard Worker     // for each axis that is present in the structure according to 'bits'.
480*38e8c45fSAndroid Build Coastguard Worker     std::array<float, MAX_AXES> values;
481*38e8c45fSAndroid Build Coastguard Worker 
482*38e8c45fSAndroid Build Coastguard Worker     // Whether these coordinate data were generated by resampling.
483*38e8c45fSAndroid Build Coastguard Worker     bool isResampled;
484*38e8c45fSAndroid Build Coastguard Worker 
485*38e8c45fSAndroid Build Coastguard Worker     static_assert(sizeof(bool) == 1); // Ensure padding is correctly sized.
486*38e8c45fSAndroid Build Coastguard Worker     uint8_t empty[7];
487*38e8c45fSAndroid Build Coastguard Worker 
clearPointerCoords488*38e8c45fSAndroid Build Coastguard Worker     inline void clear() {
489*38e8c45fSAndroid Build Coastguard Worker         BitSet64::clear(bits);
490*38e8c45fSAndroid Build Coastguard Worker         isResampled = false;
491*38e8c45fSAndroid Build Coastguard Worker     }
492*38e8c45fSAndroid Build Coastguard Worker 
isEmptyPointerCoords493*38e8c45fSAndroid Build Coastguard Worker     bool isEmpty() const {
494*38e8c45fSAndroid Build Coastguard Worker         return BitSet64::isEmpty(bits);
495*38e8c45fSAndroid Build Coastguard Worker     }
496*38e8c45fSAndroid Build Coastguard Worker 
497*38e8c45fSAndroid Build Coastguard Worker     float getAxisValue(int32_t axis) const;
498*38e8c45fSAndroid Build Coastguard Worker     status_t setAxisValue(int32_t axis, float value);
499*38e8c45fSAndroid Build Coastguard Worker 
500*38e8c45fSAndroid Build Coastguard Worker     // Scale the pointer coordinates according to a global scale and a
501*38e8c45fSAndroid Build Coastguard Worker     // window scale. The global scale will be applied to TOUCH/TOOL_MAJOR/MINOR
502*38e8c45fSAndroid Build Coastguard Worker     // axes, however the window scaling will not.
503*38e8c45fSAndroid Build Coastguard Worker     void scale(float globalScale, float windowXScale, float windowYScale);
504*38e8c45fSAndroid Build Coastguard Worker 
getXPointerCoords505*38e8c45fSAndroid Build Coastguard Worker     inline float getX() const {
506*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_X);
507*38e8c45fSAndroid Build Coastguard Worker     }
508*38e8c45fSAndroid Build Coastguard Worker 
getYPointerCoords509*38e8c45fSAndroid Build Coastguard Worker     inline float getY() const {
510*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_Y);
511*38e8c45fSAndroid Build Coastguard Worker     }
512*38e8c45fSAndroid Build Coastguard Worker 
getXYValuePointerCoords513*38e8c45fSAndroid Build Coastguard Worker     vec2 getXYValue() const { return vec2(getX(), getY()); }
514*38e8c45fSAndroid Build Coastguard Worker 
515*38e8c45fSAndroid Build Coastguard Worker     status_t readFromParcel(Parcel* parcel);
516*38e8c45fSAndroid Build Coastguard Worker     status_t writeToParcel(Parcel* parcel) const;
517*38e8c45fSAndroid Build Coastguard Worker 
518*38e8c45fSAndroid Build Coastguard Worker     bool operator==(const PointerCoords& other) const;
519*38e8c45fSAndroid Build Coastguard Worker     inline bool operator!=(const PointerCoords& other) const {
520*38e8c45fSAndroid Build Coastguard Worker         return !(*this == other);
521*38e8c45fSAndroid Build Coastguard Worker     }
522*38e8c45fSAndroid Build Coastguard Worker 
copyFromPointerCoords523*38e8c45fSAndroid Build Coastguard Worker     inline void copyFrom(const PointerCoords& other) { *this = other; }
524*38e8c45fSAndroid Build Coastguard Worker     PointerCoords& operator=(const PointerCoords&) = default;
525*38e8c45fSAndroid Build Coastguard Worker 
526*38e8c45fSAndroid Build Coastguard Worker private:
527*38e8c45fSAndroid Build Coastguard Worker     void tooManyAxes(int axis);
528*38e8c45fSAndroid Build Coastguard Worker };
529*38e8c45fSAndroid Build Coastguard Worker 
530*38e8c45fSAndroid Build Coastguard Worker /*
531*38e8c45fSAndroid Build Coastguard Worker  * Pointer property data.
532*38e8c45fSAndroid Build Coastguard Worker  */
533*38e8c45fSAndroid Build Coastguard Worker struct PointerProperties {
534*38e8c45fSAndroid Build Coastguard Worker     // The id of the pointer.
535*38e8c45fSAndroid Build Coastguard Worker     int32_t id;
536*38e8c45fSAndroid Build Coastguard Worker 
537*38e8c45fSAndroid Build Coastguard Worker     // The pointer tool type.
538*38e8c45fSAndroid Build Coastguard Worker     ToolType toolType;
539*38e8c45fSAndroid Build Coastguard Worker 
clearPointerProperties540*38e8c45fSAndroid Build Coastguard Worker     inline void clear() {
541*38e8c45fSAndroid Build Coastguard Worker         id = -1;
542*38e8c45fSAndroid Build Coastguard Worker         toolType = ToolType::UNKNOWN;
543*38e8c45fSAndroid Build Coastguard Worker     }
544*38e8c45fSAndroid Build Coastguard Worker 
545*38e8c45fSAndroid Build Coastguard Worker     bool operator==(const PointerProperties& other) const = default;
546*38e8c45fSAndroid Build Coastguard Worker     inline bool operator!=(const PointerProperties& other) const {
547*38e8c45fSAndroid Build Coastguard Worker         return !(*this == other);
548*38e8c45fSAndroid Build Coastguard Worker     }
549*38e8c45fSAndroid Build Coastguard Worker 
550*38e8c45fSAndroid Build Coastguard Worker     PointerProperties& operator=(const PointerProperties&) = default;
551*38e8c45fSAndroid Build Coastguard Worker };
552*38e8c45fSAndroid Build Coastguard Worker 
553*38e8c45fSAndroid Build Coastguard Worker std::ostream& operator<<(std::ostream& out, const PointerProperties& properties);
554*38e8c45fSAndroid Build Coastguard Worker 
555*38e8c45fSAndroid Build Coastguard Worker // TODO(b/211379801) : Use a strong type from ftl/mixins.h instead
556*38e8c45fSAndroid Build Coastguard Worker using DeviceId = int32_t;
557*38e8c45fSAndroid Build Coastguard Worker 
558*38e8c45fSAndroid Build Coastguard Worker /*
559*38e8c45fSAndroid Build Coastguard Worker  * Input events.
560*38e8c45fSAndroid Build Coastguard Worker  */
561*38e8c45fSAndroid Build Coastguard Worker class InputEvent : public AInputEvent {
562*38e8c45fSAndroid Build Coastguard Worker public:
~InputEvent()563*38e8c45fSAndroid Build Coastguard Worker     virtual ~InputEvent() { }
564*38e8c45fSAndroid Build Coastguard Worker 
565*38e8c45fSAndroid Build Coastguard Worker     virtual InputEventType getType() const = 0;
566*38e8c45fSAndroid Build Coastguard Worker 
getId()567*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getId() const { return mId; }
568*38e8c45fSAndroid Build Coastguard Worker 
getDeviceId()569*38e8c45fSAndroid Build Coastguard Worker     inline DeviceId getDeviceId() const { return mDeviceId; }
570*38e8c45fSAndroid Build Coastguard Worker 
getSource()571*38e8c45fSAndroid Build Coastguard Worker     inline uint32_t getSource() const { return mSource; }
572*38e8c45fSAndroid Build Coastguard Worker 
setSource(uint32_t source)573*38e8c45fSAndroid Build Coastguard Worker     inline void setSource(uint32_t source) { mSource = source; }
574*38e8c45fSAndroid Build Coastguard Worker 
getDisplayId()575*38e8c45fSAndroid Build Coastguard Worker     inline ui::LogicalDisplayId getDisplayId() const { return mDisplayId; }
576*38e8c45fSAndroid Build Coastguard Worker 
setDisplayId(ui::LogicalDisplayId displayId)577*38e8c45fSAndroid Build Coastguard Worker     inline void setDisplayId(ui::LogicalDisplayId displayId) { mDisplayId = displayId; }
578*38e8c45fSAndroid Build Coastguard Worker 
getHmac()579*38e8c45fSAndroid Build Coastguard Worker     inline std::array<uint8_t, 32> getHmac() const { return mHmac; }
580*38e8c45fSAndroid Build Coastguard Worker 
581*38e8c45fSAndroid Build Coastguard Worker     static int32_t nextId();
582*38e8c45fSAndroid Build Coastguard Worker 
583*38e8c45fSAndroid Build Coastguard Worker     bool operator==(const InputEvent&) const = default;
584*38e8c45fSAndroid Build Coastguard Worker 
585*38e8c45fSAndroid Build Coastguard Worker protected:
586*38e8c45fSAndroid Build Coastguard Worker     void initialize(int32_t id, DeviceId deviceId, uint32_t source, ui::LogicalDisplayId displayId,
587*38e8c45fSAndroid Build Coastguard Worker                     std::array<uint8_t, 32> hmac);
588*38e8c45fSAndroid Build Coastguard Worker 
589*38e8c45fSAndroid Build Coastguard Worker     void initialize(const InputEvent& from);
590*38e8c45fSAndroid Build Coastguard Worker 
591*38e8c45fSAndroid Build Coastguard Worker     int32_t mId;
592*38e8c45fSAndroid Build Coastguard Worker     DeviceId mDeviceId;
593*38e8c45fSAndroid Build Coastguard Worker     uint32_t mSource;
594*38e8c45fSAndroid Build Coastguard Worker     ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::INVALID};
595*38e8c45fSAndroid Build Coastguard Worker     std::array<uint8_t, 32> mHmac;
596*38e8c45fSAndroid Build Coastguard Worker };
597*38e8c45fSAndroid Build Coastguard Worker 
598*38e8c45fSAndroid Build Coastguard Worker std::ostream& operator<<(std::ostream& out, const InputEvent& event);
599*38e8c45fSAndroid Build Coastguard Worker 
600*38e8c45fSAndroid Build Coastguard Worker /*
601*38e8c45fSAndroid Build Coastguard Worker  * Key events.
602*38e8c45fSAndroid Build Coastguard Worker  */
603*38e8c45fSAndroid Build Coastguard Worker class KeyEvent : public InputEvent {
604*38e8c45fSAndroid Build Coastguard Worker public:
~KeyEvent()605*38e8c45fSAndroid Build Coastguard Worker     virtual ~KeyEvent() { }
606*38e8c45fSAndroid Build Coastguard Worker 
getType()607*38e8c45fSAndroid Build Coastguard Worker     InputEventType getType() const override { return InputEventType::KEY; }
608*38e8c45fSAndroid Build Coastguard Worker 
getAction()609*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getAction() const { return mAction; }
610*38e8c45fSAndroid Build Coastguard Worker 
getFlags()611*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getFlags() const { return mFlags; }
612*38e8c45fSAndroid Build Coastguard Worker 
setFlags(int32_t flags)613*38e8c45fSAndroid Build Coastguard Worker     inline void setFlags(int32_t flags) { mFlags = flags; }
614*38e8c45fSAndroid Build Coastguard Worker 
getKeyCode()615*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getKeyCode() const { return mKeyCode; }
616*38e8c45fSAndroid Build Coastguard Worker 
getScanCode()617*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getScanCode() const { return mScanCode; }
618*38e8c45fSAndroid Build Coastguard Worker 
getMetaState()619*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getMetaState() const { return mMetaState; }
620*38e8c45fSAndroid Build Coastguard Worker 
getRepeatCount()621*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getRepeatCount() const { return mRepeatCount; }
622*38e8c45fSAndroid Build Coastguard Worker 
getDownTime()623*38e8c45fSAndroid Build Coastguard Worker     inline nsecs_t getDownTime() const { return mDownTime; }
624*38e8c45fSAndroid Build Coastguard Worker 
getEventTime()625*38e8c45fSAndroid Build Coastguard Worker     inline nsecs_t getEventTime() const { return mEventTime; }
626*38e8c45fSAndroid Build Coastguard Worker 
627*38e8c45fSAndroid Build Coastguard Worker     static const char* getLabel(int32_t keyCode);
628*38e8c45fSAndroid Build Coastguard Worker     static std::optional<int> getKeyCodeFromLabel(const char* label);
629*38e8c45fSAndroid Build Coastguard Worker 
630*38e8c45fSAndroid Build Coastguard Worker     void initialize(int32_t id, DeviceId deviceId, uint32_t source, ui::LogicalDisplayId displayId,
631*38e8c45fSAndroid Build Coastguard Worker                     std::array<uint8_t, 32> hmac, int32_t action, int32_t flags, int32_t keyCode,
632*38e8c45fSAndroid Build Coastguard Worker                     int32_t scanCode, int32_t metaState, int32_t repeatCount, nsecs_t downTime,
633*38e8c45fSAndroid Build Coastguard Worker                     nsecs_t eventTime);
634*38e8c45fSAndroid Build Coastguard Worker     void initialize(const KeyEvent& from);
635*38e8c45fSAndroid Build Coastguard Worker 
636*38e8c45fSAndroid Build Coastguard Worker     static const char* actionToString(int32_t action);
637*38e8c45fSAndroid Build Coastguard Worker 
638*38e8c45fSAndroid Build Coastguard Worker     bool operator==(const KeyEvent&) const = default;
639*38e8c45fSAndroid Build Coastguard Worker 
640*38e8c45fSAndroid Build Coastguard Worker protected:
641*38e8c45fSAndroid Build Coastguard Worker     int32_t mAction;
642*38e8c45fSAndroid Build Coastguard Worker     int32_t mFlags;
643*38e8c45fSAndroid Build Coastguard Worker     int32_t mKeyCode;
644*38e8c45fSAndroid Build Coastguard Worker     int32_t mScanCode;
645*38e8c45fSAndroid Build Coastguard Worker     int32_t mMetaState;
646*38e8c45fSAndroid Build Coastguard Worker     int32_t mRepeatCount;
647*38e8c45fSAndroid Build Coastguard Worker     nsecs_t mDownTime;
648*38e8c45fSAndroid Build Coastguard Worker     nsecs_t mEventTime;
649*38e8c45fSAndroid Build Coastguard Worker };
650*38e8c45fSAndroid Build Coastguard Worker 
651*38e8c45fSAndroid Build Coastguard Worker std::ostream& operator<<(std::ostream& out, const KeyEvent& event);
652*38e8c45fSAndroid Build Coastguard Worker 
653*38e8c45fSAndroid Build Coastguard Worker /*
654*38e8c45fSAndroid Build Coastguard Worker  * Motion events.
655*38e8c45fSAndroid Build Coastguard Worker  */
656*38e8c45fSAndroid Build Coastguard Worker class MotionEvent : public InputEvent {
657*38e8c45fSAndroid Build Coastguard Worker public:
~MotionEvent()658*38e8c45fSAndroid Build Coastguard Worker     virtual ~MotionEvent() { }
659*38e8c45fSAndroid Build Coastguard Worker 
getType()660*38e8c45fSAndroid Build Coastguard Worker     InputEventType getType() const override { return InputEventType::MOTION; }
661*38e8c45fSAndroid Build Coastguard Worker 
getAction()662*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getAction() const { return mAction; }
663*38e8c45fSAndroid Build Coastguard Worker 
getActionMasked(int32_t action)664*38e8c45fSAndroid Build Coastguard Worker     static int32_t getActionMasked(int32_t action) { return action & AMOTION_EVENT_ACTION_MASK; }
665*38e8c45fSAndroid Build Coastguard Worker 
getActionMasked()666*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getActionMasked() const { return getActionMasked(mAction); }
667*38e8c45fSAndroid Build Coastguard Worker 
getActionIndex(int32_t action)668*38e8c45fSAndroid Build Coastguard Worker     static uint8_t getActionIndex(int32_t action) {
669*38e8c45fSAndroid Build Coastguard Worker         return (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
670*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
671*38e8c45fSAndroid Build Coastguard Worker     }
672*38e8c45fSAndroid Build Coastguard Worker 
getActionIndex()673*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getActionIndex() const { return getActionIndex(mAction); }
674*38e8c45fSAndroid Build Coastguard Worker 
setAction(int32_t action)675*38e8c45fSAndroid Build Coastguard Worker     inline void setAction(int32_t action) { mAction = action; }
676*38e8c45fSAndroid Build Coastguard Worker 
getFlags()677*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getFlags() const { return mFlags; }
678*38e8c45fSAndroid Build Coastguard Worker 
setFlags(int32_t flags)679*38e8c45fSAndroid Build Coastguard Worker     inline void setFlags(int32_t flags) { mFlags = flags; }
680*38e8c45fSAndroid Build Coastguard Worker 
getEdgeFlags()681*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getEdgeFlags() const { return mEdgeFlags; }
682*38e8c45fSAndroid Build Coastguard Worker 
setEdgeFlags(int32_t edgeFlags)683*38e8c45fSAndroid Build Coastguard Worker     inline void setEdgeFlags(int32_t edgeFlags) { mEdgeFlags = edgeFlags; }
684*38e8c45fSAndroid Build Coastguard Worker 
getMetaState()685*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getMetaState() const { return mMetaState; }
686*38e8c45fSAndroid Build Coastguard Worker 
setMetaState(int32_t metaState)687*38e8c45fSAndroid Build Coastguard Worker     inline void setMetaState(int32_t metaState) { mMetaState = metaState; }
688*38e8c45fSAndroid Build Coastguard Worker 
getButtonState()689*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getButtonState() const { return mButtonState; }
690*38e8c45fSAndroid Build Coastguard Worker 
setButtonState(int32_t buttonState)691*38e8c45fSAndroid Build Coastguard Worker     inline void setButtonState(int32_t buttonState) { mButtonState = buttonState; }
692*38e8c45fSAndroid Build Coastguard Worker 
getClassification()693*38e8c45fSAndroid Build Coastguard Worker     inline MotionClassification getClassification() const { return mClassification; }
694*38e8c45fSAndroid Build Coastguard Worker 
getActionButton()695*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getActionButton() const { return mActionButton; }
696*38e8c45fSAndroid Build Coastguard Worker 
setActionButton(int32_t button)697*38e8c45fSAndroid Build Coastguard Worker     inline void setActionButton(int32_t button) { mActionButton = button; }
698*38e8c45fSAndroid Build Coastguard Worker 
getTransform()699*38e8c45fSAndroid Build Coastguard Worker     inline const ui::Transform& getTransform() const { return mTransform; }
700*38e8c45fSAndroid Build Coastguard Worker 
701*38e8c45fSAndroid Build Coastguard Worker     std::optional<ui::Rotation> getSurfaceRotation() const;
702*38e8c45fSAndroid Build Coastguard Worker 
getXPrecision()703*38e8c45fSAndroid Build Coastguard Worker     inline float getXPrecision() const { return mXPrecision; }
704*38e8c45fSAndroid Build Coastguard Worker 
getYPrecision()705*38e8c45fSAndroid Build Coastguard Worker     inline float getYPrecision() const { return mYPrecision; }
706*38e8c45fSAndroid Build Coastguard Worker 
getRawXCursorPosition()707*38e8c45fSAndroid Build Coastguard Worker     inline float getRawXCursorPosition() const { return mRawXCursorPosition; }
708*38e8c45fSAndroid Build Coastguard Worker 
709*38e8c45fSAndroid Build Coastguard Worker     float getXCursorPosition() const;
710*38e8c45fSAndroid Build Coastguard Worker 
getRawYCursorPosition()711*38e8c45fSAndroid Build Coastguard Worker     inline float getRawYCursorPosition() const { return mRawYCursorPosition; }
712*38e8c45fSAndroid Build Coastguard Worker 
713*38e8c45fSAndroid Build Coastguard Worker     float getYCursorPosition() const;
714*38e8c45fSAndroid Build Coastguard Worker 
715*38e8c45fSAndroid Build Coastguard Worker     void setCursorPosition(float x, float y);
716*38e8c45fSAndroid Build Coastguard Worker 
getRawTransform()717*38e8c45fSAndroid Build Coastguard Worker     inline const ui::Transform& getRawTransform() const { return mRawTransform; }
718*38e8c45fSAndroid Build Coastguard Worker 
isValidCursorPosition(float x,float y)719*38e8c45fSAndroid Build Coastguard Worker     static inline bool isValidCursorPosition(float x, float y) { return !isnan(x) && !isnan(y); }
720*38e8c45fSAndroid Build Coastguard Worker 
getDownTime()721*38e8c45fSAndroid Build Coastguard Worker     inline nsecs_t getDownTime() const { return mDownTime; }
722*38e8c45fSAndroid Build Coastguard Worker 
setDownTime(nsecs_t downTime)723*38e8c45fSAndroid Build Coastguard Worker     inline void setDownTime(nsecs_t downTime) { mDownTime = downTime; }
724*38e8c45fSAndroid Build Coastguard Worker 
getPointerCount()725*38e8c45fSAndroid Build Coastguard Worker     inline size_t getPointerCount() const { return mPointerProperties.size(); }
726*38e8c45fSAndroid Build Coastguard Worker 
getPointerProperties(size_t pointerIndex)727*38e8c45fSAndroid Build Coastguard Worker     inline const PointerProperties* getPointerProperties(size_t pointerIndex) const {
728*38e8c45fSAndroid Build Coastguard Worker         return &mPointerProperties[pointerIndex];
729*38e8c45fSAndroid Build Coastguard Worker     }
730*38e8c45fSAndroid Build Coastguard Worker 
getPointerId(size_t pointerIndex)731*38e8c45fSAndroid Build Coastguard Worker     inline int32_t getPointerId(size_t pointerIndex) const {
732*38e8c45fSAndroid Build Coastguard Worker         return mPointerProperties[pointerIndex].id;
733*38e8c45fSAndroid Build Coastguard Worker     }
734*38e8c45fSAndroid Build Coastguard Worker 
getToolType(size_t pointerIndex)735*38e8c45fSAndroid Build Coastguard Worker     inline ToolType getToolType(size_t pointerIndex) const {
736*38e8c45fSAndroid Build Coastguard Worker         return mPointerProperties[pointerIndex].toolType;
737*38e8c45fSAndroid Build Coastguard Worker     }
738*38e8c45fSAndroid Build Coastguard Worker 
getEventTime()739*38e8c45fSAndroid Build Coastguard Worker     inline nsecs_t getEventTime() const { return mSampleEventTimes[getHistorySize()]; }
740*38e8c45fSAndroid Build Coastguard Worker 
741*38e8c45fSAndroid Build Coastguard Worker     /**
742*38e8c45fSAndroid Build Coastguard Worker      * The actual raw pointer coords: whatever comes from the input device without any external
743*38e8c45fSAndroid Build Coastguard Worker      * transforms applied.
744*38e8c45fSAndroid Build Coastguard Worker      */
745*38e8c45fSAndroid Build Coastguard Worker     const PointerCoords* getRawPointerCoords(size_t pointerIndex) const;
746*38e8c45fSAndroid Build Coastguard Worker 
747*38e8c45fSAndroid Build Coastguard Worker     /**
748*38e8c45fSAndroid Build Coastguard Worker      * This is the raw axis value. However, for X/Y axes, this currently applies a "compat-raw"
749*38e8c45fSAndroid Build Coastguard Worker      * transform because many apps (incorrectly) assumed that raw == oriented-screen-space.
750*38e8c45fSAndroid Build Coastguard Worker      * "compat raw" is raw coordinates with screen rotation applied.
751*38e8c45fSAndroid Build Coastguard Worker      */
752*38e8c45fSAndroid Build Coastguard Worker     float getRawAxisValue(int32_t axis, size_t pointerIndex) const;
753*38e8c45fSAndroid Build Coastguard Worker 
getRawX(size_t pointerIndex)754*38e8c45fSAndroid Build Coastguard Worker     inline float getRawX(size_t pointerIndex) const {
755*38e8c45fSAndroid Build Coastguard Worker         return getRawAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex);
756*38e8c45fSAndroid Build Coastguard Worker     }
757*38e8c45fSAndroid Build Coastguard Worker 
getRawY(size_t pointerIndex)758*38e8c45fSAndroid Build Coastguard Worker     inline float getRawY(size_t pointerIndex) const {
759*38e8c45fSAndroid Build Coastguard Worker         return getRawAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex);
760*38e8c45fSAndroid Build Coastguard Worker     }
761*38e8c45fSAndroid Build Coastguard Worker 
762*38e8c45fSAndroid Build Coastguard Worker     float getAxisValue(int32_t axis, size_t pointerIndex) const;
763*38e8c45fSAndroid Build Coastguard Worker 
764*38e8c45fSAndroid Build Coastguard Worker     /**
765*38e8c45fSAndroid Build Coastguard Worker      * Get the X coordinate of the latest sample in this MotionEvent for pointer 'pointerIndex'.
766*38e8c45fSAndroid Build Coastguard Worker      * Identical to calling getHistoricalX(pointerIndex, getHistorySize()).
767*38e8c45fSAndroid Build Coastguard Worker      */
getX(size_t pointerIndex)768*38e8c45fSAndroid Build Coastguard Worker     inline float getX(size_t pointerIndex) const {
769*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex);
770*38e8c45fSAndroid Build Coastguard Worker     }
771*38e8c45fSAndroid Build Coastguard Worker 
772*38e8c45fSAndroid Build Coastguard Worker     /**
773*38e8c45fSAndroid Build Coastguard Worker      * Get the Y coordinate of the latest sample in this MotionEvent for pointer 'pointerIndex'.
774*38e8c45fSAndroid Build Coastguard Worker      * Identical to calling getHistoricalX(pointerIndex, getHistorySize()).
775*38e8c45fSAndroid Build Coastguard Worker      */
getY(size_t pointerIndex)776*38e8c45fSAndroid Build Coastguard Worker     inline float getY(size_t pointerIndex) const {
777*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex);
778*38e8c45fSAndroid Build Coastguard Worker     }
779*38e8c45fSAndroid Build Coastguard Worker 
getPressure(size_t pointerIndex)780*38e8c45fSAndroid Build Coastguard Worker     inline float getPressure(size_t pointerIndex) const {
781*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerIndex);
782*38e8c45fSAndroid Build Coastguard Worker     }
783*38e8c45fSAndroid Build Coastguard Worker 
getSize(size_t pointerIndex)784*38e8c45fSAndroid Build Coastguard Worker     inline float getSize(size_t pointerIndex) const {
785*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_SIZE, pointerIndex);
786*38e8c45fSAndroid Build Coastguard Worker     }
787*38e8c45fSAndroid Build Coastguard Worker 
getTouchMajor(size_t pointerIndex)788*38e8c45fSAndroid Build Coastguard Worker     inline float getTouchMajor(size_t pointerIndex) const {
789*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex);
790*38e8c45fSAndroid Build Coastguard Worker     }
791*38e8c45fSAndroid Build Coastguard Worker 
getTouchMinor(size_t pointerIndex)792*38e8c45fSAndroid Build Coastguard Worker     inline float getTouchMinor(size_t pointerIndex) const {
793*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex);
794*38e8c45fSAndroid Build Coastguard Worker     }
795*38e8c45fSAndroid Build Coastguard Worker 
getToolMajor(size_t pointerIndex)796*38e8c45fSAndroid Build Coastguard Worker     inline float getToolMajor(size_t pointerIndex) const {
797*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex);
798*38e8c45fSAndroid Build Coastguard Worker     }
799*38e8c45fSAndroid Build Coastguard Worker 
getToolMinor(size_t pointerIndex)800*38e8c45fSAndroid Build Coastguard Worker     inline float getToolMinor(size_t pointerIndex) const {
801*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex);
802*38e8c45fSAndroid Build Coastguard Worker     }
803*38e8c45fSAndroid Build Coastguard Worker 
getOrientation(size_t pointerIndex)804*38e8c45fSAndroid Build Coastguard Worker     inline float getOrientation(size_t pointerIndex) const {
805*38e8c45fSAndroid Build Coastguard Worker         return getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex);
806*38e8c45fSAndroid Build Coastguard Worker     }
807*38e8c45fSAndroid Build Coastguard Worker 
getHistorySize()808*38e8c45fSAndroid Build Coastguard Worker     inline size_t getHistorySize() const { return mSampleEventTimes.size() - 1; }
809*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalEventTime(size_t historicalIndex)810*38e8c45fSAndroid Build Coastguard Worker     inline nsecs_t getHistoricalEventTime(size_t historicalIndex) const {
811*38e8c45fSAndroid Build Coastguard Worker         return mSampleEventTimes[historicalIndex];
812*38e8c45fSAndroid Build Coastguard Worker     }
813*38e8c45fSAndroid Build Coastguard Worker 
814*38e8c45fSAndroid Build Coastguard Worker     /**
815*38e8c45fSAndroid Build Coastguard Worker      * The actual raw pointer coords: whatever comes from the input device without any external
816*38e8c45fSAndroid Build Coastguard Worker      * transforms applied.
817*38e8c45fSAndroid Build Coastguard Worker      */
818*38e8c45fSAndroid Build Coastguard Worker     const PointerCoords* getHistoricalRawPointerCoords(
819*38e8c45fSAndroid Build Coastguard Worker             size_t pointerIndex, size_t historicalIndex) const;
820*38e8c45fSAndroid Build Coastguard Worker 
821*38e8c45fSAndroid Build Coastguard Worker     /**
822*38e8c45fSAndroid Build Coastguard Worker      * This is the raw axis value. However, for X/Y axes, this currently applies a "compat-raw"
823*38e8c45fSAndroid Build Coastguard Worker      * transform because many apps (incorrectly) assumed that raw == oriented-screen-space.
824*38e8c45fSAndroid Build Coastguard Worker      * "compat raw" is raw coordinates with screen rotation applied.
825*38e8c45fSAndroid Build Coastguard Worker      */
826*38e8c45fSAndroid Build Coastguard Worker     float getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex,
827*38e8c45fSAndroid Build Coastguard Worker             size_t historicalIndex) const;
828*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalRawX(size_t pointerIndex,size_t historicalIndex)829*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalRawX(size_t pointerIndex, size_t historicalIndex) const {
830*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalRawAxisValue(
831*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex);
832*38e8c45fSAndroid Build Coastguard Worker     }
833*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalRawY(size_t pointerIndex,size_t historicalIndex)834*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalRawY(size_t pointerIndex, size_t historicalIndex) const {
835*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalRawAxisValue(
836*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex);
837*38e8c45fSAndroid Build Coastguard Worker     }
838*38e8c45fSAndroid Build Coastguard Worker 
839*38e8c45fSAndroid Build Coastguard Worker     float getHistoricalAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const;
840*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalX(size_t pointerIndex,size_t historicalIndex)841*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const {
842*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalAxisValue(
843*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex);
844*38e8c45fSAndroid Build Coastguard Worker     }
845*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalY(size_t pointerIndex,size_t historicalIndex)846*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const {
847*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalAxisValue(
848*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex);
849*38e8c45fSAndroid Build Coastguard Worker     }
850*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalPressure(size_t pointerIndex,size_t historicalIndex)851*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const {
852*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalAxisValue(
853*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_PRESSURE, pointerIndex, historicalIndex);
854*38e8c45fSAndroid Build Coastguard Worker     }
855*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalSize(size_t pointerIndex,size_t historicalIndex)856*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalSize(size_t pointerIndex, size_t historicalIndex) const {
857*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalAxisValue(
858*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_SIZE, pointerIndex, historicalIndex);
859*38e8c45fSAndroid Build Coastguard Worker     }
860*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalTouchMajor(size_t pointerIndex,size_t historicalIndex)861*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const {
862*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalAxisValue(
863*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex);
864*38e8c45fSAndroid Build Coastguard Worker     }
865*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalTouchMinor(size_t pointerIndex,size_t historicalIndex)866*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const {
867*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalAxisValue(
868*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex);
869*38e8c45fSAndroid Build Coastguard Worker     }
870*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalToolMajor(size_t pointerIndex,size_t historicalIndex)871*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const {
872*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalAxisValue(
873*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex);
874*38e8c45fSAndroid Build Coastguard Worker     }
875*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalToolMinor(size_t pointerIndex,size_t historicalIndex)876*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const {
877*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalAxisValue(
878*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex, historicalIndex);
879*38e8c45fSAndroid Build Coastguard Worker     }
880*38e8c45fSAndroid Build Coastguard Worker 
getHistoricalOrientation(size_t pointerIndex,size_t historicalIndex)881*38e8c45fSAndroid Build Coastguard Worker     inline float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const {
882*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalAxisValue(
883*38e8c45fSAndroid Build Coastguard Worker                 AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex, historicalIndex);
884*38e8c45fSAndroid Build Coastguard Worker     }
885*38e8c45fSAndroid Build Coastguard Worker 
isResampled(size_t pointerIndex,size_t historicalIndex)886*38e8c45fSAndroid Build Coastguard Worker     inline bool isResampled(size_t pointerIndex, size_t historicalIndex) const {
887*38e8c45fSAndroid Build Coastguard Worker         return getHistoricalRawPointerCoords(pointerIndex, historicalIndex)->isResampled;
888*38e8c45fSAndroid Build Coastguard Worker     }
889*38e8c45fSAndroid Build Coastguard Worker 
890*38e8c45fSAndroid Build Coastguard Worker     ssize_t findPointerIndex(int32_t pointerId) const;
891*38e8c45fSAndroid Build Coastguard Worker 
892*38e8c45fSAndroid Build Coastguard Worker     void initialize(int32_t id, DeviceId deviceId, uint32_t source, ui::LogicalDisplayId displayId,
893*38e8c45fSAndroid Build Coastguard Worker                     std::array<uint8_t, 32> hmac, int32_t action, int32_t actionButton,
894*38e8c45fSAndroid Build Coastguard Worker                     int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState,
895*38e8c45fSAndroid Build Coastguard Worker                     MotionClassification classification, const ui::Transform& transform,
896*38e8c45fSAndroid Build Coastguard Worker                     float xPrecision, float yPrecision, float rawXCursorPosition,
897*38e8c45fSAndroid Build Coastguard Worker                     float rawYCursorPosition, const ui::Transform& rawTransform, nsecs_t downTime,
898*38e8c45fSAndroid Build Coastguard Worker                     nsecs_t eventTime, size_t pointerCount,
899*38e8c45fSAndroid Build Coastguard Worker                     const PointerProperties* pointerProperties, const PointerCoords* pointerCoords);
900*38e8c45fSAndroid Build Coastguard Worker 
901*38e8c45fSAndroid Build Coastguard Worker     void copyFrom(const MotionEvent* other, bool keepHistory);
902*38e8c45fSAndroid Build Coastguard Worker 
903*38e8c45fSAndroid Build Coastguard Worker     // Initialize this event by keeping only the pointers from "other" that are in splitPointerIds.
904*38e8c45fSAndroid Build Coastguard Worker     void splitFrom(const MotionEvent& other, std::bitset<MAX_POINTER_ID + 1> splitPointerIds,
905*38e8c45fSAndroid Build Coastguard Worker                    int32_t newEventId);
906*38e8c45fSAndroid Build Coastguard Worker 
907*38e8c45fSAndroid Build Coastguard Worker     void addSample(nsecs_t eventTime, const PointerCoords* pointerCoords, int32_t eventId);
908*38e8c45fSAndroid Build Coastguard Worker 
909*38e8c45fSAndroid Build Coastguard Worker     void offsetLocation(float xOffset, float yOffset);
910*38e8c45fSAndroid Build Coastguard Worker 
911*38e8c45fSAndroid Build Coastguard Worker     /**
912*38e8c45fSAndroid Build Coastguard Worker      * Get the X offset of this motion event relative to the origin of the raw coordinate space.
913*38e8c45fSAndroid Build Coastguard Worker      *
914*38e8c45fSAndroid Build Coastguard Worker      * In practice, this is the delta that was added to the raw screen coordinates (i.e. in logical
915*38e8c45fSAndroid Build Coastguard Worker      * display space) to adjust for the absolute position of the containing windows and views.
916*38e8c45fSAndroid Build Coastguard Worker      */
917*38e8c45fSAndroid Build Coastguard Worker     float getRawXOffset() const;
918*38e8c45fSAndroid Build Coastguard Worker 
919*38e8c45fSAndroid Build Coastguard Worker     /**
920*38e8c45fSAndroid Build Coastguard Worker      * Get the Y offset of this motion event relative to the origin of the raw coordinate space.
921*38e8c45fSAndroid Build Coastguard Worker      *
922*38e8c45fSAndroid Build Coastguard Worker      * In practice, this is the delta that was added to the raw screen coordinates (i.e. in logical
923*38e8c45fSAndroid Build Coastguard Worker      * display space) to adjust for the absolute position of the containing windows and views.
924*38e8c45fSAndroid Build Coastguard Worker      */
925*38e8c45fSAndroid Build Coastguard Worker     float getRawYOffset() const;
926*38e8c45fSAndroid Build Coastguard Worker 
927*38e8c45fSAndroid Build Coastguard Worker     void scale(float globalScaleFactor);
928*38e8c45fSAndroid Build Coastguard Worker 
929*38e8c45fSAndroid Build Coastguard Worker     // Set 3x3 perspective matrix transformation.
930*38e8c45fSAndroid Build Coastguard Worker     // Matrix is in row-major form and compatible with SkMatrix.
931*38e8c45fSAndroid Build Coastguard Worker     void transform(const std::array<float, 9>& matrix);
932*38e8c45fSAndroid Build Coastguard Worker 
933*38e8c45fSAndroid Build Coastguard Worker     // Apply 3x3 perspective matrix transformation only to content (do not modify mTransform).
934*38e8c45fSAndroid Build Coastguard Worker     // Matrix is in row-major form and compatible with SkMatrix.
935*38e8c45fSAndroid Build Coastguard Worker     void applyTransform(const std::array<float, 9>& matrix);
936*38e8c45fSAndroid Build Coastguard Worker 
937*38e8c45fSAndroid Build Coastguard Worker     status_t readFromParcel(Parcel* parcel);
938*38e8c45fSAndroid Build Coastguard Worker     status_t writeToParcel(Parcel* parcel) const;
939*38e8c45fSAndroid Build Coastguard Worker 
940*38e8c45fSAndroid Build Coastguard Worker     static bool isTouchEvent(uint32_t source, int32_t action);
isTouchEvent()941*38e8c45fSAndroid Build Coastguard Worker     inline bool isTouchEvent() const {
942*38e8c45fSAndroid Build Coastguard Worker         return isTouchEvent(mSource, mAction);
943*38e8c45fSAndroid Build Coastguard Worker     }
944*38e8c45fSAndroid Build Coastguard Worker 
945*38e8c45fSAndroid Build Coastguard Worker     // Low-level accessors.
getPointerProperties()946*38e8c45fSAndroid Build Coastguard Worker     inline const PointerProperties* getPointerProperties() const {
947*38e8c45fSAndroid Build Coastguard Worker         return mPointerProperties.data();
948*38e8c45fSAndroid Build Coastguard Worker     }
getSampleEventTimes()949*38e8c45fSAndroid Build Coastguard Worker     inline const nsecs_t* getSampleEventTimes() const { return mSampleEventTimes.data(); }
getSamplePointerCoords()950*38e8c45fSAndroid Build Coastguard Worker     inline const PointerCoords* getSamplePointerCoords() const {
951*38e8c45fSAndroid Build Coastguard Worker         return mSamplePointerCoords.data();
952*38e8c45fSAndroid Build Coastguard Worker     }
953*38e8c45fSAndroid Build Coastguard Worker 
954*38e8c45fSAndroid Build Coastguard Worker     static const char* getLabel(int32_t axis);
955*38e8c45fSAndroid Build Coastguard Worker     static std::optional<int> getAxisFromLabel(const char* label);
956*38e8c45fSAndroid Build Coastguard Worker 
957*38e8c45fSAndroid Build Coastguard Worker     static std::string actionToString(int32_t action);
958*38e8c45fSAndroid Build Coastguard Worker 
959*38e8c45fSAndroid Build Coastguard Worker     static std::tuple<int32_t /*action*/, std::vector<PointerProperties>,
960*38e8c45fSAndroid Build Coastguard Worker                       std::vector<PointerCoords>>
961*38e8c45fSAndroid Build Coastguard Worker     split(int32_t action, int32_t flags, int32_t historySize, const std::vector<PointerProperties>&,
962*38e8c45fSAndroid Build Coastguard Worker           const std::vector<PointerCoords>&, std::bitset<MAX_POINTER_ID + 1> splitPointerIds);
963*38e8c45fSAndroid Build Coastguard Worker 
964*38e8c45fSAndroid Build Coastguard Worker     // MotionEvent will transform various axes in different ways, based on the source. For
965*38e8c45fSAndroid Build Coastguard Worker     // example, the x and y axes will not have any offsets/translations applied if it comes from a
966*38e8c45fSAndroid Build Coastguard Worker     // relative mouse device (since SOURCE_RELATIVE_MOUSE is a non-pointer source). These methods
967*38e8c45fSAndroid Build Coastguard Worker     // are used to apply these transformations for different axes.
968*38e8c45fSAndroid Build Coastguard Worker     static vec2 calculateTransformedXY(uint32_t source, const ui::Transform&, const vec2& xy);
969*38e8c45fSAndroid Build Coastguard Worker     static float calculateTransformedAxisValue(int32_t axis, uint32_t source, int32_t flags,
970*38e8c45fSAndroid Build Coastguard Worker                                                const ui::Transform&, const PointerCoords&);
971*38e8c45fSAndroid Build Coastguard Worker     static void calculateTransformedCoordsInPlace(PointerCoords& coords, uint32_t source,
972*38e8c45fSAndroid Build Coastguard Worker                                                   int32_t flags, const ui::Transform&);
973*38e8c45fSAndroid Build Coastguard Worker     static PointerCoords calculateTransformedCoords(uint32_t source, int32_t flags,
974*38e8c45fSAndroid Build Coastguard Worker                                                     const ui::Transform&, const PointerCoords&);
975*38e8c45fSAndroid Build Coastguard Worker     // The rounding precision for transformed motion events.
976*38e8c45fSAndroid Build Coastguard Worker     static constexpr float ROUNDING_PRECISION = 0.001f;
977*38e8c45fSAndroid Build Coastguard Worker 
978*38e8c45fSAndroid Build Coastguard Worker     bool operator==(const MotionEvent&) const;
979*38e8c45fSAndroid Build Coastguard Worker     inline bool operator!=(const MotionEvent& o) const { return !(*this == o); };
980*38e8c45fSAndroid Build Coastguard Worker 
981*38e8c45fSAndroid Build Coastguard Worker protected:
982*38e8c45fSAndroid Build Coastguard Worker     int32_t mAction;
983*38e8c45fSAndroid Build Coastguard Worker     int32_t mActionButton;
984*38e8c45fSAndroid Build Coastguard Worker     int32_t mFlags;
985*38e8c45fSAndroid Build Coastguard Worker     int32_t mEdgeFlags;
986*38e8c45fSAndroid Build Coastguard Worker     int32_t mMetaState;
987*38e8c45fSAndroid Build Coastguard Worker     int32_t mButtonState;
988*38e8c45fSAndroid Build Coastguard Worker     MotionClassification mClassification;
989*38e8c45fSAndroid Build Coastguard Worker     ui::Transform mTransform;
990*38e8c45fSAndroid Build Coastguard Worker     float mXPrecision;
991*38e8c45fSAndroid Build Coastguard Worker     float mYPrecision;
992*38e8c45fSAndroid Build Coastguard Worker     float mRawXCursorPosition;
993*38e8c45fSAndroid Build Coastguard Worker     float mRawYCursorPosition;
994*38e8c45fSAndroid Build Coastguard Worker     ui::Transform mRawTransform;
995*38e8c45fSAndroid Build Coastguard Worker     nsecs_t mDownTime;
996*38e8c45fSAndroid Build Coastguard Worker     std::vector<PointerProperties> mPointerProperties;
997*38e8c45fSAndroid Build Coastguard Worker     std::vector<nsecs_t> mSampleEventTimes;
998*38e8c45fSAndroid Build Coastguard Worker     std::vector<PointerCoords> mSamplePointerCoords;
999*38e8c45fSAndroid Build Coastguard Worker 
1000*38e8c45fSAndroid Build Coastguard Worker private:
1001*38e8c45fSAndroid Build Coastguard Worker     /**
1002*38e8c45fSAndroid Build Coastguard Worker      * Create a human-readable string representation of the event's data for debugging purposes.
1003*38e8c45fSAndroid Build Coastguard Worker      *
1004*38e8c45fSAndroid Build Coastguard Worker      * Unlike operator<<, this method does not assume that the event data is valid or consistent, or
1005*38e8c45fSAndroid Build Coastguard Worker      * call any accessor methods that might themselves call safeDump in the case of invalid data.
1006*38e8c45fSAndroid Build Coastguard Worker      */
1007*38e8c45fSAndroid Build Coastguard Worker     std::string safeDump() const;
1008*38e8c45fSAndroid Build Coastguard Worker };
1009*38e8c45fSAndroid Build Coastguard Worker 
1010*38e8c45fSAndroid Build Coastguard Worker std::ostream& operator<<(std::ostream& out, const MotionEvent& event);
1011*38e8c45fSAndroid Build Coastguard Worker 
1012*38e8c45fSAndroid Build Coastguard Worker /*
1013*38e8c45fSAndroid Build Coastguard Worker  * Focus events.
1014*38e8c45fSAndroid Build Coastguard Worker  */
1015*38e8c45fSAndroid Build Coastguard Worker class FocusEvent : public InputEvent {
1016*38e8c45fSAndroid Build Coastguard Worker public:
~FocusEvent()1017*38e8c45fSAndroid Build Coastguard Worker     virtual ~FocusEvent() {}
1018*38e8c45fSAndroid Build Coastguard Worker 
getType()1019*38e8c45fSAndroid Build Coastguard Worker     InputEventType getType() const override { return InputEventType::FOCUS; }
1020*38e8c45fSAndroid Build Coastguard Worker 
getHasFocus()1021*38e8c45fSAndroid Build Coastguard Worker     inline bool getHasFocus() const { return mHasFocus; }
1022*38e8c45fSAndroid Build Coastguard Worker 
1023*38e8c45fSAndroid Build Coastguard Worker     void initialize(int32_t id, bool hasFocus);
1024*38e8c45fSAndroid Build Coastguard Worker 
1025*38e8c45fSAndroid Build Coastguard Worker     void initialize(const FocusEvent& from);
1026*38e8c45fSAndroid Build Coastguard Worker 
1027*38e8c45fSAndroid Build Coastguard Worker protected:
1028*38e8c45fSAndroid Build Coastguard Worker     bool mHasFocus;
1029*38e8c45fSAndroid Build Coastguard Worker };
1030*38e8c45fSAndroid Build Coastguard Worker 
1031*38e8c45fSAndroid Build Coastguard Worker /*
1032*38e8c45fSAndroid Build Coastguard Worker  * Capture events.
1033*38e8c45fSAndroid Build Coastguard Worker  */
1034*38e8c45fSAndroid Build Coastguard Worker class CaptureEvent : public InputEvent {
1035*38e8c45fSAndroid Build Coastguard Worker public:
~CaptureEvent()1036*38e8c45fSAndroid Build Coastguard Worker     virtual ~CaptureEvent() {}
1037*38e8c45fSAndroid Build Coastguard Worker 
getType()1038*38e8c45fSAndroid Build Coastguard Worker     InputEventType getType() const override { return InputEventType::CAPTURE; }
1039*38e8c45fSAndroid Build Coastguard Worker 
getPointerCaptureEnabled()1040*38e8c45fSAndroid Build Coastguard Worker     inline bool getPointerCaptureEnabled() const { return mPointerCaptureEnabled; }
1041*38e8c45fSAndroid Build Coastguard Worker 
1042*38e8c45fSAndroid Build Coastguard Worker     void initialize(int32_t id, bool pointerCaptureEnabled);
1043*38e8c45fSAndroid Build Coastguard Worker 
1044*38e8c45fSAndroid Build Coastguard Worker     void initialize(const CaptureEvent& from);
1045*38e8c45fSAndroid Build Coastguard Worker 
1046*38e8c45fSAndroid Build Coastguard Worker protected:
1047*38e8c45fSAndroid Build Coastguard Worker     bool mPointerCaptureEnabled;
1048*38e8c45fSAndroid Build Coastguard Worker };
1049*38e8c45fSAndroid Build Coastguard Worker 
1050*38e8c45fSAndroid Build Coastguard Worker /*
1051*38e8c45fSAndroid Build Coastguard Worker  * Drag events.
1052*38e8c45fSAndroid Build Coastguard Worker  */
1053*38e8c45fSAndroid Build Coastguard Worker class DragEvent : public InputEvent {
1054*38e8c45fSAndroid Build Coastguard Worker public:
~DragEvent()1055*38e8c45fSAndroid Build Coastguard Worker     virtual ~DragEvent() {}
1056*38e8c45fSAndroid Build Coastguard Worker 
getType()1057*38e8c45fSAndroid Build Coastguard Worker     InputEventType getType() const override { return InputEventType::DRAG; }
1058*38e8c45fSAndroid Build Coastguard Worker 
isExiting()1059*38e8c45fSAndroid Build Coastguard Worker     inline bool isExiting() const { return mIsExiting; }
1060*38e8c45fSAndroid Build Coastguard Worker 
getX()1061*38e8c45fSAndroid Build Coastguard Worker     inline float getX() const { return mX; }
1062*38e8c45fSAndroid Build Coastguard Worker 
getY()1063*38e8c45fSAndroid Build Coastguard Worker     inline float getY() const { return mY; }
1064*38e8c45fSAndroid Build Coastguard Worker 
1065*38e8c45fSAndroid Build Coastguard Worker     void initialize(int32_t id, float x, float y, bool isExiting);
1066*38e8c45fSAndroid Build Coastguard Worker 
1067*38e8c45fSAndroid Build Coastguard Worker     void initialize(const DragEvent& from);
1068*38e8c45fSAndroid Build Coastguard Worker 
1069*38e8c45fSAndroid Build Coastguard Worker protected:
1070*38e8c45fSAndroid Build Coastguard Worker     bool mIsExiting;
1071*38e8c45fSAndroid Build Coastguard Worker     float mX, mY;
1072*38e8c45fSAndroid Build Coastguard Worker };
1073*38e8c45fSAndroid Build Coastguard Worker 
1074*38e8c45fSAndroid Build Coastguard Worker /*
1075*38e8c45fSAndroid Build Coastguard Worker  * Touch mode events.
1076*38e8c45fSAndroid Build Coastguard Worker  */
1077*38e8c45fSAndroid Build Coastguard Worker class TouchModeEvent : public InputEvent {
1078*38e8c45fSAndroid Build Coastguard Worker public:
~TouchModeEvent()1079*38e8c45fSAndroid Build Coastguard Worker     virtual ~TouchModeEvent() {}
1080*38e8c45fSAndroid Build Coastguard Worker 
getType()1081*38e8c45fSAndroid Build Coastguard Worker     InputEventType getType() const override { return InputEventType::TOUCH_MODE; }
1082*38e8c45fSAndroid Build Coastguard Worker 
isInTouchMode()1083*38e8c45fSAndroid Build Coastguard Worker     inline bool isInTouchMode() const { return mIsInTouchMode; }
1084*38e8c45fSAndroid Build Coastguard Worker 
1085*38e8c45fSAndroid Build Coastguard Worker     void initialize(int32_t id, bool isInTouchMode);
1086*38e8c45fSAndroid Build Coastguard Worker 
1087*38e8c45fSAndroid Build Coastguard Worker     void initialize(const TouchModeEvent& from);
1088*38e8c45fSAndroid Build Coastguard Worker 
1089*38e8c45fSAndroid Build Coastguard Worker protected:
1090*38e8c45fSAndroid Build Coastguard Worker     bool mIsInTouchMode;
1091*38e8c45fSAndroid Build Coastguard Worker };
1092*38e8c45fSAndroid Build Coastguard Worker 
1093*38e8c45fSAndroid Build Coastguard Worker /**
1094*38e8c45fSAndroid Build Coastguard Worker  * Base class for verified events.
1095*38e8c45fSAndroid Build Coastguard Worker  * Do not create a VerifiedInputEvent explicitly.
1096*38e8c45fSAndroid Build Coastguard Worker  * Use helper functions to create them from InputEvents.
1097*38e8c45fSAndroid Build Coastguard Worker  */
1098*38e8c45fSAndroid Build Coastguard Worker struct __attribute__((__packed__)) VerifiedInputEvent {
1099*38e8c45fSAndroid Build Coastguard Worker     enum class Type : int32_t {
1100*38e8c45fSAndroid Build Coastguard Worker         KEY = AINPUT_EVENT_TYPE_KEY,
1101*38e8c45fSAndroid Build Coastguard Worker         MOTION = AINPUT_EVENT_TYPE_MOTION,
1102*38e8c45fSAndroid Build Coastguard Worker     };
1103*38e8c45fSAndroid Build Coastguard Worker 
1104*38e8c45fSAndroid Build Coastguard Worker     Type type;
1105*38e8c45fSAndroid Build Coastguard Worker     DeviceId deviceId;
1106*38e8c45fSAndroid Build Coastguard Worker     nsecs_t eventTimeNanos;
1107*38e8c45fSAndroid Build Coastguard Worker     uint32_t source;
1108*38e8c45fSAndroid Build Coastguard Worker     ui::LogicalDisplayId displayId;
1109*38e8c45fSAndroid Build Coastguard Worker };
1110*38e8c45fSAndroid Build Coastguard Worker 
1111*38e8c45fSAndroid Build Coastguard Worker /**
1112*38e8c45fSAndroid Build Coastguard Worker  * Same as KeyEvent, but only contains the data that can be verified.
1113*38e8c45fSAndroid Build Coastguard Worker  * If you update this class, you must also update VerifiedKeyEvent.java
1114*38e8c45fSAndroid Build Coastguard Worker  */
1115*38e8c45fSAndroid Build Coastguard Worker struct __attribute__((__packed__)) VerifiedKeyEvent : public VerifiedInputEvent {
1116*38e8c45fSAndroid Build Coastguard Worker     int32_t action;
1117*38e8c45fSAndroid Build Coastguard Worker     int32_t flags;
1118*38e8c45fSAndroid Build Coastguard Worker     nsecs_t downTimeNanos;
1119*38e8c45fSAndroid Build Coastguard Worker     int32_t keyCode;
1120*38e8c45fSAndroid Build Coastguard Worker     int32_t scanCode;
1121*38e8c45fSAndroid Build Coastguard Worker     int32_t metaState;
1122*38e8c45fSAndroid Build Coastguard Worker     int32_t repeatCount;
1123*38e8c45fSAndroid Build Coastguard Worker };
1124*38e8c45fSAndroid Build Coastguard Worker 
1125*38e8c45fSAndroid Build Coastguard Worker /**
1126*38e8c45fSAndroid Build Coastguard Worker  * Same as MotionEvent, but only contains the data that can be verified.
1127*38e8c45fSAndroid Build Coastguard Worker  * If you update this class, you must also update VerifiedMotionEvent.java
1128*38e8c45fSAndroid Build Coastguard Worker  */
1129*38e8c45fSAndroid Build Coastguard Worker struct __attribute__((__packed__)) VerifiedMotionEvent : public VerifiedInputEvent {
1130*38e8c45fSAndroid Build Coastguard Worker     float rawX;
1131*38e8c45fSAndroid Build Coastguard Worker     float rawY;
1132*38e8c45fSAndroid Build Coastguard Worker     int32_t actionMasked;
1133*38e8c45fSAndroid Build Coastguard Worker     int32_t flags;
1134*38e8c45fSAndroid Build Coastguard Worker     nsecs_t downTimeNanos;
1135*38e8c45fSAndroid Build Coastguard Worker     int32_t metaState;
1136*38e8c45fSAndroid Build Coastguard Worker     int32_t buttonState;
1137*38e8c45fSAndroid Build Coastguard Worker };
1138*38e8c45fSAndroid Build Coastguard Worker 
1139*38e8c45fSAndroid Build Coastguard Worker VerifiedKeyEvent verifiedKeyEventFromKeyEvent(const KeyEvent& event);
1140*38e8c45fSAndroid Build Coastguard Worker VerifiedMotionEvent verifiedMotionEventFromMotionEvent(const MotionEvent& event);
1141*38e8c45fSAndroid Build Coastguard Worker 
1142*38e8c45fSAndroid Build Coastguard Worker /*
1143*38e8c45fSAndroid Build Coastguard Worker  * Input event factory.
1144*38e8c45fSAndroid Build Coastguard Worker  */
1145*38e8c45fSAndroid Build Coastguard Worker class InputEventFactoryInterface {
1146*38e8c45fSAndroid Build Coastguard Worker protected:
~InputEventFactoryInterface()1147*38e8c45fSAndroid Build Coastguard Worker     virtual ~InputEventFactoryInterface() { }
1148*38e8c45fSAndroid Build Coastguard Worker 
1149*38e8c45fSAndroid Build Coastguard Worker public:
InputEventFactoryInterface()1150*38e8c45fSAndroid Build Coastguard Worker     InputEventFactoryInterface() { }
1151*38e8c45fSAndroid Build Coastguard Worker 
1152*38e8c45fSAndroid Build Coastguard Worker     virtual KeyEvent* createKeyEvent() = 0;
1153*38e8c45fSAndroid Build Coastguard Worker     virtual MotionEvent* createMotionEvent() = 0;
1154*38e8c45fSAndroid Build Coastguard Worker     virtual FocusEvent* createFocusEvent() = 0;
1155*38e8c45fSAndroid Build Coastguard Worker     virtual CaptureEvent* createCaptureEvent() = 0;
1156*38e8c45fSAndroid Build Coastguard Worker     virtual DragEvent* createDragEvent() = 0;
1157*38e8c45fSAndroid Build Coastguard Worker     virtual TouchModeEvent* createTouchModeEvent() = 0;
1158*38e8c45fSAndroid Build Coastguard Worker };
1159*38e8c45fSAndroid Build Coastguard Worker 
1160*38e8c45fSAndroid Build Coastguard Worker /*
1161*38e8c45fSAndroid Build Coastguard Worker  * A simple input event factory implementation that uses a single preallocated instance
1162*38e8c45fSAndroid Build Coastguard Worker  * of each type of input event that are reused for each request.
1163*38e8c45fSAndroid Build Coastguard Worker  */
1164*38e8c45fSAndroid Build Coastguard Worker class PreallocatedInputEventFactory : public InputEventFactoryInterface {
1165*38e8c45fSAndroid Build Coastguard Worker public:
PreallocatedInputEventFactory()1166*38e8c45fSAndroid Build Coastguard Worker     PreallocatedInputEventFactory() { }
~PreallocatedInputEventFactory()1167*38e8c45fSAndroid Build Coastguard Worker     virtual ~PreallocatedInputEventFactory() { }
1168*38e8c45fSAndroid Build Coastguard Worker 
createKeyEvent()1169*38e8c45fSAndroid Build Coastguard Worker     virtual KeyEvent* createKeyEvent() override { return &mKeyEvent; }
createMotionEvent()1170*38e8c45fSAndroid Build Coastguard Worker     virtual MotionEvent* createMotionEvent() override { return &mMotionEvent; }
createFocusEvent()1171*38e8c45fSAndroid Build Coastguard Worker     virtual FocusEvent* createFocusEvent() override { return &mFocusEvent; }
createCaptureEvent()1172*38e8c45fSAndroid Build Coastguard Worker     virtual CaptureEvent* createCaptureEvent() override { return &mCaptureEvent; }
createDragEvent()1173*38e8c45fSAndroid Build Coastguard Worker     virtual DragEvent* createDragEvent() override { return &mDragEvent; }
createTouchModeEvent()1174*38e8c45fSAndroid Build Coastguard Worker     virtual TouchModeEvent* createTouchModeEvent() override { return &mTouchModeEvent; }
1175*38e8c45fSAndroid Build Coastguard Worker 
1176*38e8c45fSAndroid Build Coastguard Worker private:
1177*38e8c45fSAndroid Build Coastguard Worker     KeyEvent mKeyEvent;
1178*38e8c45fSAndroid Build Coastguard Worker     MotionEvent mMotionEvent;
1179*38e8c45fSAndroid Build Coastguard Worker     FocusEvent mFocusEvent;
1180*38e8c45fSAndroid Build Coastguard Worker     CaptureEvent mCaptureEvent;
1181*38e8c45fSAndroid Build Coastguard Worker     DragEvent mDragEvent;
1182*38e8c45fSAndroid Build Coastguard Worker     TouchModeEvent mTouchModeEvent;
1183*38e8c45fSAndroid Build Coastguard Worker };
1184*38e8c45fSAndroid Build Coastguard Worker 
1185*38e8c45fSAndroid Build Coastguard Worker /*
1186*38e8c45fSAndroid Build Coastguard Worker  * An input event factory implementation that maintains a pool of input events.
1187*38e8c45fSAndroid Build Coastguard Worker  */
1188*38e8c45fSAndroid Build Coastguard Worker class PooledInputEventFactory : public InputEventFactoryInterface {
1189*38e8c45fSAndroid Build Coastguard Worker public:
1190*38e8c45fSAndroid Build Coastguard Worker     explicit PooledInputEventFactory(size_t maxPoolSize = 20);
1191*38e8c45fSAndroid Build Coastguard Worker     virtual ~PooledInputEventFactory();
1192*38e8c45fSAndroid Build Coastguard Worker 
1193*38e8c45fSAndroid Build Coastguard Worker     virtual KeyEvent* createKeyEvent() override;
1194*38e8c45fSAndroid Build Coastguard Worker     virtual MotionEvent* createMotionEvent() override;
1195*38e8c45fSAndroid Build Coastguard Worker     virtual FocusEvent* createFocusEvent() override;
1196*38e8c45fSAndroid Build Coastguard Worker     virtual CaptureEvent* createCaptureEvent() override;
1197*38e8c45fSAndroid Build Coastguard Worker     virtual DragEvent* createDragEvent() override;
1198*38e8c45fSAndroid Build Coastguard Worker     virtual TouchModeEvent* createTouchModeEvent() override;
1199*38e8c45fSAndroid Build Coastguard Worker 
1200*38e8c45fSAndroid Build Coastguard Worker     void recycle(InputEvent* event);
1201*38e8c45fSAndroid Build Coastguard Worker 
1202*38e8c45fSAndroid Build Coastguard Worker private:
1203*38e8c45fSAndroid Build Coastguard Worker     const size_t mMaxPoolSize;
1204*38e8c45fSAndroid Build Coastguard Worker 
1205*38e8c45fSAndroid Build Coastguard Worker     std::queue<std::unique_ptr<KeyEvent>> mKeyEventPool;
1206*38e8c45fSAndroid Build Coastguard Worker     std::queue<std::unique_ptr<MotionEvent>> mMotionEventPool;
1207*38e8c45fSAndroid Build Coastguard Worker     std::queue<std::unique_ptr<FocusEvent>> mFocusEventPool;
1208*38e8c45fSAndroid Build Coastguard Worker     std::queue<std::unique_ptr<CaptureEvent>> mCaptureEventPool;
1209*38e8c45fSAndroid Build Coastguard Worker     std::queue<std::unique_ptr<DragEvent>> mDragEventPool;
1210*38e8c45fSAndroid Build Coastguard Worker     std::queue<std::unique_ptr<TouchModeEvent>> mTouchModeEventPool;
1211*38e8c45fSAndroid Build Coastguard Worker };
1212*38e8c45fSAndroid Build Coastguard Worker 
1213*38e8c45fSAndroid Build Coastguard Worker /**
1214*38e8c45fSAndroid Build Coastguard Worker  * An input event factory implementation that simply creates the input events on the heap, when
1215*38e8c45fSAndroid Build Coastguard Worker  * needed. The caller is responsible for destroying the returned references.
1216*38e8c45fSAndroid Build Coastguard Worker  * It is recommended that the caller wrap these return values into std::unique_ptr.
1217*38e8c45fSAndroid Build Coastguard Worker  */
1218*38e8c45fSAndroid Build Coastguard Worker class DynamicInputEventFactory : public InputEventFactoryInterface {
1219*38e8c45fSAndroid Build Coastguard Worker public:
DynamicInputEventFactory()1220*38e8c45fSAndroid Build Coastguard Worker     explicit DynamicInputEventFactory(){};
~DynamicInputEventFactory()1221*38e8c45fSAndroid Build Coastguard Worker     ~DynamicInputEventFactory(){};
1222*38e8c45fSAndroid Build Coastguard Worker 
createKeyEvent()1223*38e8c45fSAndroid Build Coastguard Worker     KeyEvent* createKeyEvent() override { return new KeyEvent(); };
createMotionEvent()1224*38e8c45fSAndroid Build Coastguard Worker     MotionEvent* createMotionEvent() override { return new MotionEvent(); };
createFocusEvent()1225*38e8c45fSAndroid Build Coastguard Worker     FocusEvent* createFocusEvent() override { return new FocusEvent(); };
createCaptureEvent()1226*38e8c45fSAndroid Build Coastguard Worker     CaptureEvent* createCaptureEvent() override { return new CaptureEvent(); };
createDragEvent()1227*38e8c45fSAndroid Build Coastguard Worker     DragEvent* createDragEvent() override { return new DragEvent(); };
createTouchModeEvent()1228*38e8c45fSAndroid Build Coastguard Worker     TouchModeEvent* createTouchModeEvent() override { return new TouchModeEvent(); };
1229*38e8c45fSAndroid Build Coastguard Worker };
1230*38e8c45fSAndroid Build Coastguard Worker 
1231*38e8c45fSAndroid Build Coastguard Worker /*
1232*38e8c45fSAndroid Build Coastguard Worker  * Describes a unique request to enable or disable Pointer Capture.
1233*38e8c45fSAndroid Build Coastguard Worker  */
1234*38e8c45fSAndroid Build Coastguard Worker struct PointerCaptureRequest {
1235*38e8c45fSAndroid Build Coastguard Worker public:
PointerCaptureRequestPointerCaptureRequest1236*38e8c45fSAndroid Build Coastguard Worker     inline PointerCaptureRequest() : window(), seq(0) {}
PointerCaptureRequestPointerCaptureRequest1237*38e8c45fSAndroid Build Coastguard Worker     inline PointerCaptureRequest(sp<IBinder> window, uint32_t seq) : window(window), seq(seq) {}
1238*38e8c45fSAndroid Build Coastguard Worker     inline bool operator==(const PointerCaptureRequest& other) const {
1239*38e8c45fSAndroid Build Coastguard Worker         return window == other.window && seq == other.seq;
1240*38e8c45fSAndroid Build Coastguard Worker     }
isEnablePointerCaptureRequest1241*38e8c45fSAndroid Build Coastguard Worker     inline bool isEnable() const { return window != nullptr; }
1242*38e8c45fSAndroid Build Coastguard Worker 
1243*38e8c45fSAndroid Build Coastguard Worker     // The requesting window.
1244*38e8c45fSAndroid Build Coastguard Worker     // If the request is to enable the capture, this is the input token of the window that requested
1245*38e8c45fSAndroid Build Coastguard Worker     // pointer capture. Otherwise, this is nullptr.
1246*38e8c45fSAndroid Build Coastguard Worker     sp<IBinder> window;
1247*38e8c45fSAndroid Build Coastguard Worker 
1248*38e8c45fSAndroid Build Coastguard Worker     // The sequence number for the request.
1249*38e8c45fSAndroid Build Coastguard Worker     uint32_t seq;
1250*38e8c45fSAndroid Build Coastguard Worker };
1251*38e8c45fSAndroid Build Coastguard Worker 
1252*38e8c45fSAndroid Build Coastguard Worker /* Pointer icon styles.
1253*38e8c45fSAndroid Build Coastguard Worker  * Must match the definition in android.view.PointerIcon.
1254*38e8c45fSAndroid Build Coastguard Worker  *
1255*38e8c45fSAndroid Build Coastguard Worker  * Due to backwards compatibility and public api constraints, this is a duplicate (but type safe)
1256*38e8c45fSAndroid Build Coastguard Worker  * definition of PointerIcon.java.
1257*38e8c45fSAndroid Build Coastguard Worker  */
1258*38e8c45fSAndroid Build Coastguard Worker enum class PointerIconStyle : int32_t {
1259*38e8c45fSAndroid Build Coastguard Worker     TYPE_CUSTOM = static_cast<int32_t>(::android::os::PointerIconType::CUSTOM),
1260*38e8c45fSAndroid Build Coastguard Worker     TYPE_NULL = static_cast<int32_t>(::android::os::PointerIconType::TYPE_NULL),
1261*38e8c45fSAndroid Build Coastguard Worker     TYPE_NOT_SPECIFIED = static_cast<int32_t>(::android::os::PointerIconType::NOT_SPECIFIED),
1262*38e8c45fSAndroid Build Coastguard Worker     TYPE_ARROW = static_cast<int32_t>(::android::os::PointerIconType::ARROW),
1263*38e8c45fSAndroid Build Coastguard Worker     TYPE_CONTEXT_MENU = static_cast<int32_t>(::android::os::PointerIconType::CONTEXT_MENU),
1264*38e8c45fSAndroid Build Coastguard Worker     TYPE_HAND = static_cast<int32_t>(::android::os::PointerIconType::HAND),
1265*38e8c45fSAndroid Build Coastguard Worker     TYPE_HELP = static_cast<int32_t>(::android::os::PointerIconType::HELP),
1266*38e8c45fSAndroid Build Coastguard Worker     TYPE_WAIT = static_cast<int32_t>(::android::os::PointerIconType::WAIT),
1267*38e8c45fSAndroid Build Coastguard Worker     TYPE_CELL = static_cast<int32_t>(::android::os::PointerIconType::CELL),
1268*38e8c45fSAndroid Build Coastguard Worker     TYPE_CROSSHAIR = static_cast<int32_t>(::android::os::PointerIconType::CROSSHAIR),
1269*38e8c45fSAndroid Build Coastguard Worker     TYPE_TEXT = static_cast<int32_t>(::android::os::PointerIconType::TEXT),
1270*38e8c45fSAndroid Build Coastguard Worker     TYPE_VERTICAL_TEXT = static_cast<int32_t>(::android::os::PointerIconType::VERTICAL_TEXT),
1271*38e8c45fSAndroid Build Coastguard Worker     TYPE_ALIAS = static_cast<int32_t>(::android::os::PointerIconType::ALIAS),
1272*38e8c45fSAndroid Build Coastguard Worker     TYPE_COPY = static_cast<int32_t>(::android::os::PointerIconType::COPY),
1273*38e8c45fSAndroid Build Coastguard Worker     TYPE_NO_DROP = static_cast<int32_t>(::android::os::PointerIconType::NO_DROP),
1274*38e8c45fSAndroid Build Coastguard Worker     TYPE_ALL_SCROLL = static_cast<int32_t>(::android::os::PointerIconType::ALL_SCROLL),
1275*38e8c45fSAndroid Build Coastguard Worker     TYPE_HORIZONTAL_DOUBLE_ARROW =
1276*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(::android::os::PointerIconType::HORIZONTAL_DOUBLE_ARROW),
1277*38e8c45fSAndroid Build Coastguard Worker     TYPE_VERTICAL_DOUBLE_ARROW =
1278*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(::android::os::PointerIconType::VERTICAL_DOUBLE_ARROW),
1279*38e8c45fSAndroid Build Coastguard Worker     TYPE_TOP_RIGHT_DOUBLE_ARROW =
1280*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(::android::os::PointerIconType::TOP_RIGHT_DOUBLE_ARROW),
1281*38e8c45fSAndroid Build Coastguard Worker     TYPE_TOP_LEFT_DOUBLE_ARROW =
1282*38e8c45fSAndroid Build Coastguard Worker             static_cast<int32_t>(::android::os::PointerIconType::TOP_LEFT_DOUBLE_ARROW),
1283*38e8c45fSAndroid Build Coastguard Worker     TYPE_ZOOM_IN = static_cast<int32_t>(::android::os::PointerIconType::ZOOM_IN),
1284*38e8c45fSAndroid Build Coastguard Worker     TYPE_ZOOM_OUT = static_cast<int32_t>(::android::os::PointerIconType::ZOOM_OUT),
1285*38e8c45fSAndroid Build Coastguard Worker     TYPE_GRAB = static_cast<int32_t>(::android::os::PointerIconType::GRAB),
1286*38e8c45fSAndroid Build Coastguard Worker     TYPE_GRABBING = static_cast<int32_t>(::android::os::PointerIconType::GRABBING),
1287*38e8c45fSAndroid Build Coastguard Worker     TYPE_HANDWRITING = static_cast<int32_t>(::android::os::PointerIconType::HANDWRITING),
1288*38e8c45fSAndroid Build Coastguard Worker 
1289*38e8c45fSAndroid Build Coastguard Worker     TYPE_SPOT_HOVER = static_cast<int32_t>(::android::os::PointerIconType::SPOT_HOVER),
1290*38e8c45fSAndroid Build Coastguard Worker     TYPE_SPOT_TOUCH = static_cast<int32_t>(::android::os::PointerIconType::SPOT_TOUCH),
1291*38e8c45fSAndroid Build Coastguard Worker     TYPE_SPOT_ANCHOR = static_cast<int32_t>(::android::os::PointerIconType::SPOT_ANCHOR),
1292*38e8c45fSAndroid Build Coastguard Worker };
1293*38e8c45fSAndroid Build Coastguard Worker 
1294*38e8c45fSAndroid Build Coastguard Worker } // namespace android
1295