• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18  * @addtogroup Input
19  * @{
20  */
21 
22 /**
23  * @file input.h
24  */
25 
26 #ifndef _ANDROID_INPUT_H
27 #define _ANDROID_INPUT_H
28 
29 #include <sys/cdefs.h>
30 
31 /******************************************************************
32  *
33  * IMPORTANT NOTICE:
34  *
35  *   This file is part of Android's set of stable system headers
36  *   exposed by the Android NDK (Native Development Kit).
37  *
38  *   Third-party source AND binary code relies on the definitions
39  *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
40  *
41  *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
42  *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
43  *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
44  *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
45  */
46 
47 /*
48  * Structures and functions to receive and process input events in
49  * native code.
50  *
51  * NOTE: These functions MUST be implemented by /system/lib/libui.so
52  */
53 
54 #include <stdint.h>
55 #include <sys/types.h>
56 #include <android/keycodes.h>
57 #include <android/looper.h>
58 
59 #include <jni.h>
60 
61 // This file may also be built on glibc or on Windows/MacOS libc's, so no-op
62 // definitions are provided.
63 #if !defined(__INTRODUCED_IN)
64 #define __INTRODUCED_IN(__api_level) /* nothing */
65 #endif
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 /**
72  * Key states (may be returned by queries about the current state of a
73  * particular key code, scan code or switch).
74  */
75 enum {
76     /** The key state is unknown or the requested key itself is not supported. */
77     AKEY_STATE_UNKNOWN = -1,
78 
79     /** The key is up. */
80     AKEY_STATE_UP = 0,
81 
82     /** The key is down. */
83     AKEY_STATE_DOWN = 1,
84 
85     /** The key is down but is a virtual key press that is being emulated by the system. */
86     AKEY_STATE_VIRTUAL = 2
87 };
88 
89 /**
90  * Meta key / modifier state.
91  */
92 enum {
93     /** No meta keys are pressed. */
94     AMETA_NONE = 0,
95 
96     /** This mask is used to check whether one of the ALT meta keys is pressed. */
97     AMETA_ALT_ON = 0x02,
98 
99     /** This mask is used to check whether the left ALT meta key is pressed. */
100     AMETA_ALT_LEFT_ON = 0x10,
101 
102     /** This mask is used to check whether the right ALT meta key is pressed. */
103     AMETA_ALT_RIGHT_ON = 0x20,
104 
105     /** This mask is used to check whether one of the SHIFT meta keys is pressed. */
106     AMETA_SHIFT_ON = 0x01,
107 
108     /** This mask is used to check whether the left SHIFT meta key is pressed. */
109     AMETA_SHIFT_LEFT_ON = 0x40,
110 
111     /** This mask is used to check whether the right SHIFT meta key is pressed. */
112     AMETA_SHIFT_RIGHT_ON = 0x80,
113 
114     /** This mask is used to check whether the SYM meta key is pressed. */
115     AMETA_SYM_ON = 0x04,
116 
117     /** This mask is used to check whether the FUNCTION meta key is pressed. */
118     AMETA_FUNCTION_ON = 0x08,
119 
120     /** This mask is used to check whether one of the CTRL meta keys is pressed. */
121     AMETA_CTRL_ON = 0x1000,
122 
123     /** This mask is used to check whether the left CTRL meta key is pressed. */
124     AMETA_CTRL_LEFT_ON = 0x2000,
125 
126     /** This mask is used to check whether the right CTRL meta key is pressed. */
127     AMETA_CTRL_RIGHT_ON = 0x4000,
128 
129     /** This mask is used to check whether one of the META meta keys is pressed. */
130     AMETA_META_ON = 0x10000,
131 
132     /** This mask is used to check whether the left META meta key is pressed. */
133     AMETA_META_LEFT_ON = 0x20000,
134 
135     /** This mask is used to check whether the right META meta key is pressed. */
136     AMETA_META_RIGHT_ON = 0x40000,
137 
138     /** This mask is used to check whether the CAPS LOCK meta key is on. */
139     AMETA_CAPS_LOCK_ON = 0x100000,
140 
141     /** This mask is used to check whether the NUM LOCK meta key is on. */
142     AMETA_NUM_LOCK_ON = 0x200000,
143 
144     /** This mask is used to check whether the SCROLL LOCK meta key is on. */
145     AMETA_SCROLL_LOCK_ON = 0x400000,
146 };
147 
148 struct AInputEvent;
149 /**
150  * Input events.
151  *
152  * Input events are opaque structures.  Use the provided accessors functions to
153  * read their properties.
154  */
155 typedef struct AInputEvent AInputEvent;
156 
157 /**
158  * Input event types.
159  */
160 enum {
161     /** Indicates that the input event is a key event. */
162     AINPUT_EVENT_TYPE_KEY = 1,
163 
164     /** Indicates that the input event is a motion event. */
165     AINPUT_EVENT_TYPE_MOTION = 2,
166 
167     /** Focus event */
168     AINPUT_EVENT_TYPE_FOCUS = 3,
169 
170     /** Capture event */
171     AINPUT_EVENT_TYPE_CAPTURE = 4,
172 
173     /** Drag event */
174     AINPUT_EVENT_TYPE_DRAG = 5,
175 
176     /** TouchMode event */
177     AINPUT_EVENT_TYPE_TOUCH_MODE = 6,
178 };
179 
180 /**
181  * Key event actions.
182  */
183 enum {
184     /** The key has been pressed down. */
185     AKEY_EVENT_ACTION_DOWN = 0,
186 
187     /** The key has been released. */
188     AKEY_EVENT_ACTION_UP = 1,
189 
190     /**
191      * Multiple duplicate key events have occurred in a row, or a
192      * complex string is being delivered.  The repeat_count property
193      * of the key event contains the number of times the given key
194      * code should be executed.
195      */
196     AKEY_EVENT_ACTION_MULTIPLE = 2
197 };
198 
199 /**
200  * Key event flags.
201  */
202 enum {
203     /** This mask is set if the device woke because of this key event. */
204     AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
205 
206     /** This mask is set if the key event was generated by a software keyboard. */
207     AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
208 
209     /** This mask is set if we don't want the key event to cause us to leave touch mode. */
210     AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
211 
212     /**
213      * This mask is set if an event was known to come from a trusted
214      * part of the system.  That is, the event is known to come from
215      * the user, and could not have been spoofed by a third party
216      * component.
217      */
218     AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
219 
220     /**
221      * This mask is used for compatibility, to identify enter keys that are
222      * coming from an IME whose enter key has been auto-labelled "next" or
223      * "done".  This allows TextView to dispatch these as normal enter keys
224      * for old applications, but still do the appropriate action when
225      * receiving them.
226      */
227     AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
228 
229     /**
230      * When associated with up key events, this indicates that the key press
231      * has been canceled.  Typically this is used with virtual touch screen
232      * keys, where the user can slide from the virtual key area on to the
233      * display: in that case, the application will receive a canceled up
234      * event and should not perform the action normally associated with the
235      * key.  Note that for this to work, the application can not perform an
236      * action for a key until it receives an up or the long press timeout has
237      * expired.
238      */
239     AKEY_EVENT_FLAG_CANCELED = 0x20,
240 
241     /**
242      * This key event was generated by a virtual (on-screen) hard key area.
243      * Typically this is an area of the touchscreen, outside of the regular
244      * display, dedicated to "hardware" buttons.
245      */
246     AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
247 
248     /**
249      * This flag is set for the first key repeat that occurs after the
250      * long press timeout.
251      */
252     AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
253 
254     /**
255      * Set when a key event has #AKEY_EVENT_FLAG_CANCELED set because a long
256      * press action was executed while it was down.
257      */
258     AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
259 
260     /**
261      * Set for #AKEY_EVENT_ACTION_UP when this event's key code is still being
262      * tracked from its initial down.  That is, somebody requested that tracking
263      * started on the key down and a long press has not caused
264      * the tracking to be canceled.
265      */
266     AKEY_EVENT_FLAG_TRACKING = 0x200,
267 
268     /**
269      * Set when a key event has been synthesized to implement default behavior
270      * for an event that the application did not handle.
271      * Fallback key events are generated by unhandled trackball motions
272      * (to emulate a directional keypad) and by certain unhandled key presses
273      * that are declared in the key map (such as special function numeric keypad
274      * keys when numlock is off).
275      */
276     AKEY_EVENT_FLAG_FALLBACK = 0x400,
277 };
278 
279 /**
280  * Bit shift for the action bits holding the pointer index as
281  * defined by #AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
282  */
283 #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
284 
285 /** Motion event actions */
286 enum {
287     /** Bit mask of the parts of the action code that are the action itself. */
288     AMOTION_EVENT_ACTION_MASK = 0xff,
289 
290     /**
291      * Bits in the action code that represent a pointer index, used with
292      * #AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP.  Shifting
293      * down by #AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
294      * index where the data for the pointer going up or down can be found.
295      */
296     AMOTION_EVENT_ACTION_POINTER_INDEX_MASK  = 0xff00,
297 
298     /** A pressed gesture has started, the motion contains the initial starting location. */
299     AMOTION_EVENT_ACTION_DOWN = 0,
300 
301     /**
302      * A pressed gesture has finished, the motion contains the final release location
303      * as well as any intermediate points since the last down or move event.
304      */
305     AMOTION_EVENT_ACTION_UP = 1,
306 
307     /**
308      * A change has happened during a press gesture (between #AMOTION_EVENT_ACTION_DOWN and
309      * #AMOTION_EVENT_ACTION_UP).  The motion contains the most recent point, as well as
310      * any intermediate points since the last down or move event.
311      */
312     AMOTION_EVENT_ACTION_MOVE = 2,
313 
314     /**
315      * The current gesture has been aborted.
316      * You will not receive any more points in it.  You should treat this as
317      * an up event, but not perform any action that you normally would.
318      */
319     AMOTION_EVENT_ACTION_CANCEL = 3,
320 
321     /**
322      * A movement has happened outside of the normal bounds of the UI element.
323      * This does not provide a full gesture, but only the initial location of the movement/touch.
324      */
325     AMOTION_EVENT_ACTION_OUTSIDE = 4,
326 
327     /**
328      * A non-primary pointer has gone down.
329      * The bits in #AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
330      */
331     AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
332 
333     /**
334      * A non-primary pointer has gone up.
335      * The bits in #AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
336      */
337     AMOTION_EVENT_ACTION_POINTER_UP = 6,
338 
339     /**
340      * A change happened but the pointer is not down (unlike #AMOTION_EVENT_ACTION_MOVE).
341      * The motion contains the most recent point, as well as any intermediate points since
342      * the last hover move event.
343      */
344     AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
345 
346     /**
347      * The motion event contains relative vertical and/or horizontal scroll offsets.
348      * Use {@link AMotionEvent_getAxisValue} to retrieve the information from
349      * #AMOTION_EVENT_AXIS_VSCROLL and #AMOTION_EVENT_AXIS_HSCROLL.
350      * The pointer may or may not be down when this event is dispatched.
351      * This action is always delivered to the winder under the pointer, which
352      * may not be the window currently touched.
353      */
354     AMOTION_EVENT_ACTION_SCROLL = 8,
355 
356     /** The pointer is not down but has entered the boundaries of a window or view. */
357     AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
358 
359     /** The pointer is not down but has exited the boundaries of a window or view. */
360     AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
361 
362     /* One or more buttons have been pressed. */
363     AMOTION_EVENT_ACTION_BUTTON_PRESS = 11,
364 
365     /* One or more buttons have been released. */
366     AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12,
367 };
368 
369 /**
370  * Motion event flags.
371  */
372 enum {
373     /**
374      * This flag indicates that the window that received this motion event is partly
375      * or wholly obscured by another visible window above it.  This flag is set to true
376      * even if the event did not directly pass through the obscured area.
377      * A security sensitive application can check this flag to identify situations in which
378      * a malicious application may have covered up part of its content for the purpose
379      * of misleading the user or hijacking touches.  An appropriate response might be
380      * to drop the suspect touches or to take additional precautions to confirm the user's
381      * actual intent.
382      */
383     AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
384 };
385 
386 /**
387  * Motion event edge touch flags.
388  */
389 enum {
390     /** No edges intersected. */
391     AMOTION_EVENT_EDGE_FLAG_NONE = 0,
392 
393     /** Flag indicating the motion event intersected the top edge of the screen. */
394     AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
395 
396     /** Flag indicating the motion event intersected the bottom edge of the screen. */
397     AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
398 
399     /** Flag indicating the motion event intersected the left edge of the screen. */
400     AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
401 
402     /** Flag indicating the motion event intersected the right edge of the screen. */
403     AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
404 };
405 
406 /**
407  * Constants that identify each individual axis of a motion event.
408  * @anchor AMOTION_EVENT_AXIS
409  */
410 enum {
411     /**
412      * Axis constant: X axis of a motion event.
413      *
414      * - For a touch screen, reports the absolute X screen position of the center of
415      * the touch contact area.  The units are display pixels.
416      * - For a touch pad, reports the absolute X surface position of the center of the touch
417      * contact area. The units are device-dependent.
418      * - For a mouse, reports the absolute X screen position of the mouse pointer.
419      * The units are display pixels.
420      * - For a trackball, reports the relative horizontal displacement of the trackball.
421      * The value is normalized to a range from -1.0 (left) to 1.0 (right).
422      * - For a joystick, reports the absolute X position of the joystick.
423      * The value is normalized to a range from -1.0 (left) to 1.0 (right).
424      */
425     AMOTION_EVENT_AXIS_X = 0,
426     /**
427      * Axis constant: Y axis of a motion event.
428      *
429      * - For a touch screen, reports the absolute Y screen position of the center of
430      * the touch contact area.  The units are display pixels.
431      * - For a touch pad, reports the absolute Y surface position of the center of the touch
432      * contact area. The units are device-dependent.
433      * - For a mouse, reports the absolute Y screen position of the mouse pointer.
434      * The units are display pixels.
435      * - For a trackball, reports the relative vertical displacement of the trackball.
436      * The value is normalized to a range from -1.0 (up) to 1.0 (down).
437      * - For a joystick, reports the absolute Y position of the joystick.
438      * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
439      */
440     AMOTION_EVENT_AXIS_Y = 1,
441     /**
442      * Axis constant: Pressure axis of a motion event.
443      *
444      * - For a touch screen or touch pad, reports the approximate pressure applied to the surface
445      * by a finger or other tool.  The value is normalized to a range from
446      * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
447      * may be generated depending on the calibration of the input device.
448      * - For a trackball, the value is set to 1 if the trackball button is pressed
449      * or 0 otherwise.
450      * - For a mouse, the value is set to 1 if the primary mouse button is pressed
451      * or 0 otherwise.
452      */
453     AMOTION_EVENT_AXIS_PRESSURE = 2,
454     /**
455      * Axis constant: Size axis of a motion event.
456      *
457      * - For a touch screen or touch pad, reports the approximate size of the contact area in
458      * relation to the maximum detectable size for the device.  The value is normalized
459      * to a range from 0 (smallest detectable size) to 1 (largest detectable size),
460      * although it is not a linear scale. This value is of limited use.
461      * To obtain calibrated size information, see
462      * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}.
463      */
464     AMOTION_EVENT_AXIS_SIZE = 3,
465     /**
466      * Axis constant: TouchMajor axis of a motion event.
467      *
468      * - For a touch screen, reports the length of the major axis of an ellipse that
469      * represents the touch area at the point of contact.
470      * The units are display pixels.
471      * - For a touch pad, reports the length of the major axis of an ellipse that
472      * represents the touch area at the point of contact.
473      * The units are device-dependent.
474      */
475     AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
476     /**
477      * Axis constant: TouchMinor axis of a motion event.
478      *
479      * - For a touch screen, reports the length of the minor axis of an ellipse that
480      * represents the touch area at the point of contact.
481      * The units are display pixels.
482      * - For a touch pad, reports the length of the minor axis of an ellipse that
483      * represents the touch area at the point of contact.
484      * The units are device-dependent.
485      *
486      * When the touch is circular, the major and minor axis lengths will be equal to one another.
487      */
488     AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
489     /**
490      * Axis constant: ToolMajor axis of a motion event.
491      *
492      * - For a touch screen, reports the length of the major axis of an ellipse that
493      * represents the size of the approaching finger or tool used to make contact.
494      * - For a touch pad, reports the length of the major axis of an ellipse that
495      * represents the size of the approaching finger or tool used to make contact.
496      * The units are device-dependent.
497      *
498      * When the touch is circular, the major and minor axis lengths will be equal to one another.
499      *
500      * The tool size may be larger than the touch size since the tool may not be fully
501      * in contact with the touch sensor.
502      */
503     AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
504     /**
505      * Axis constant: ToolMinor axis of a motion event.
506      *
507      * - For a touch screen, reports the length of the minor axis of an ellipse that
508      * represents the size of the approaching finger or tool used to make contact.
509      * - For a touch pad, reports the length of the minor axis of an ellipse that
510      * represents the size of the approaching finger or tool used to make contact.
511      * The units are device-dependent.
512      *
513      * When the touch is circular, the major and minor axis lengths will be equal to one another.
514      *
515      * The tool size may be larger than the touch size since the tool may not be fully
516      * in contact with the touch sensor.
517      */
518     AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
519     /**
520      * Axis constant: Orientation axis of a motion event.
521      *
522      * - For a touch screen or touch pad, reports the orientation of the finger
523      * or tool in radians relative to the vertical plane of the device.
524      * An angle of 0 radians indicates that the major axis of contact is oriented
525      * upwards, is perfectly circular or is of unknown orientation.  A positive angle
526      * indicates that the major axis of contact is oriented to the right.  A negative angle
527      * indicates that the major axis of contact is oriented to the left.
528      * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
529      * (finger pointing fully right).
530      * - For a stylus, the orientation indicates the direction in which the stylus
531      * is pointing in relation to the vertical axis of the current orientation of the screen.
532      * The range is from -PI radians to PI radians, where 0 is pointing up,
533      * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
534      * is pointing right.  See also #AMOTION_EVENT_AXIS_TILT.
535      */
536     AMOTION_EVENT_AXIS_ORIENTATION = 8,
537     /**
538      * Axis constant: Vertical Scroll axis of a motion event.
539      *
540      * - For a mouse, reports the relative movement of the vertical scroll wheel.
541      * The value is normalized to a range from -1.0 (down) to 1.0 (up).
542      *
543      * This axis should be used to scroll views vertically.
544      */
545     AMOTION_EVENT_AXIS_VSCROLL = 9,
546     /**
547      * Axis constant: Horizontal Scroll axis of a motion event.
548      *
549      * - For a mouse, reports the relative movement of the horizontal scroll wheel.
550      * The value is normalized to a range from -1.0 (left) to 1.0 (right).
551      *
552      * This axis should be used to scroll views horizontally.
553      */
554     AMOTION_EVENT_AXIS_HSCROLL = 10,
555     /**
556      * Axis constant: Z axis of a motion event.
557      *
558      * - For a joystick, reports the absolute Z position of the joystick.
559      * The value is normalized to a range from -1.0 (high) to 1.0 (low).
560      * <em>On game pads with two analog joysticks, this axis is often reinterpreted
561      * to report the absolute X position of the second joystick instead.</em>
562      */
563     AMOTION_EVENT_AXIS_Z = 11,
564     /**
565      * Axis constant: X Rotation axis of a motion event.
566      *
567      * - For a joystick, reports the absolute rotation angle about the X axis.
568      * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
569      */
570     AMOTION_EVENT_AXIS_RX = 12,
571     /**
572      * Axis constant: Y Rotation axis of a motion event.
573      *
574      * - For a joystick, reports the absolute rotation angle about the Y axis.
575      * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
576      */
577     AMOTION_EVENT_AXIS_RY = 13,
578     /**
579      * Axis constant: Z Rotation axis of a motion event.
580      *
581      * - For a joystick, reports the absolute rotation angle about the Z axis.
582      * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
583      * On game pads with two analog joysticks, this axis is often reinterpreted
584      * to report the absolute Y position of the second joystick instead.
585      */
586     AMOTION_EVENT_AXIS_RZ = 14,
587     /**
588      * Axis constant: Hat X axis of a motion event.
589      *
590      * - For a joystick, reports the absolute X position of the directional hat control.
591      * The value is normalized to a range from -1.0 (left) to 1.0 (right).
592      */
593     AMOTION_EVENT_AXIS_HAT_X = 15,
594     /**
595      * Axis constant: Hat Y axis of a motion event.
596      *
597      * - For a joystick, reports the absolute Y position of the directional hat control.
598      * The value is normalized to a range from -1.0 (up) to 1.0 (down).
599      */
600     AMOTION_EVENT_AXIS_HAT_Y = 16,
601     /**
602      * Axis constant: Left Trigger axis of a motion event.
603      *
604      * - For a joystick, reports the absolute position of the left trigger control.
605      * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
606      */
607     AMOTION_EVENT_AXIS_LTRIGGER = 17,
608     /**
609      * Axis constant: Right Trigger axis of a motion event.
610      *
611      * - For a joystick, reports the absolute position of the right trigger control.
612      * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
613      */
614     AMOTION_EVENT_AXIS_RTRIGGER = 18,
615     /**
616      * Axis constant: Throttle axis of a motion event.
617      *
618      * - For a joystick, reports the absolute position of the throttle control.
619      * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
620      */
621     AMOTION_EVENT_AXIS_THROTTLE = 19,
622     /**
623      * Axis constant: Rudder axis of a motion event.
624      *
625      * - For a joystick, reports the absolute position of the rudder control.
626      * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
627      */
628     AMOTION_EVENT_AXIS_RUDDER = 20,
629     /**
630      * Axis constant: Wheel axis of a motion event.
631      *
632      * - For a joystick, reports the absolute position of the steering wheel control.
633      * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
634      */
635     AMOTION_EVENT_AXIS_WHEEL = 21,
636     /**
637      * Axis constant: Gas axis of a motion event.
638      *
639      * - For a joystick, reports the absolute position of the gas (accelerator) control.
640      * The value is normalized to a range from 0.0 (no acceleration)
641      * to 1.0 (maximum acceleration).
642      */
643     AMOTION_EVENT_AXIS_GAS = 22,
644     /**
645      * Axis constant: Brake axis of a motion event.
646      *
647      * - For a joystick, reports the absolute position of the brake control.
648      * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
649      */
650     AMOTION_EVENT_AXIS_BRAKE = 23,
651     /**
652      * Axis constant: Distance axis of a motion event.
653      *
654      * - For a stylus, reports the distance of the stylus from the screen.
655      * A value of 0.0 indicates direct contact and larger values indicate increasing
656      * distance from the surface.
657      */
658     AMOTION_EVENT_AXIS_DISTANCE = 24,
659     /**
660      * Axis constant: Tilt axis of a motion event.
661      *
662      * - For a stylus, reports the tilt angle of the stylus in radians where
663      * 0 radians indicates that the stylus is being held perpendicular to the
664      * surface, and PI/2 radians indicates that the stylus is being held flat
665      * against the surface.
666      */
667     AMOTION_EVENT_AXIS_TILT = 25,
668     /**
669      * Axis constant:  Generic scroll axis of a motion event.
670      *
671      * - This is used for scroll axis motion events that can't be classified as strictly
672      *   vertical or horizontal. The movement of a rotating scroller is an example of this.
673      */
674     AMOTION_EVENT_AXIS_SCROLL = 26,
675     /**
676      * Axis constant: The movement of x position of a motion event.
677      *
678      * - For a mouse, reports a difference of x position between the previous position.
679      * This is useful when pointer is captured, in that case the mouse pointer doesn't
680      * change the location but this axis reports the difference which allows the app
681      * to see how the mouse is moved.
682      */
683     AMOTION_EVENT_AXIS_RELATIVE_X = 27,
684     /**
685      * Axis constant: The movement of y position of a motion event.
686      *
687      * Same as #AMOTION_EVENT_AXIS_RELATIVE_X, but for y position.
688      */
689     AMOTION_EVENT_AXIS_RELATIVE_Y = 28,
690     /**
691      * Axis constant: Generic 1 axis of a motion event.
692      * The interpretation of a generic axis is device-specific.
693      */
694     AMOTION_EVENT_AXIS_GENERIC_1 = 32,
695     /**
696      * Axis constant: Generic 2 axis of a motion event.
697      * The interpretation of a generic axis is device-specific.
698      */
699     AMOTION_EVENT_AXIS_GENERIC_2 = 33,
700     /**
701      * Axis constant: Generic 3 axis of a motion event.
702      * The interpretation of a generic axis is device-specific.
703      */
704     AMOTION_EVENT_AXIS_GENERIC_3 = 34,
705     /**
706      * Axis constant: Generic 4 axis of a motion event.
707      * The interpretation of a generic axis is device-specific.
708      */
709     AMOTION_EVENT_AXIS_GENERIC_4 = 35,
710     /**
711      * Axis constant: Generic 5 axis of a motion event.
712      * The interpretation of a generic axis is device-specific.
713      */
714     AMOTION_EVENT_AXIS_GENERIC_5 = 36,
715     /**
716      * Axis constant: Generic 6 axis of a motion event.
717      * The interpretation of a generic axis is device-specific.
718      */
719     AMOTION_EVENT_AXIS_GENERIC_6 = 37,
720     /**
721      * Axis constant: Generic 7 axis of a motion event.
722      * The interpretation of a generic axis is device-specific.
723      */
724     AMOTION_EVENT_AXIS_GENERIC_7 = 38,
725     /**
726      * Axis constant: Generic 8 axis of a motion event.
727      * The interpretation of a generic axis is device-specific.
728      */
729     AMOTION_EVENT_AXIS_GENERIC_8 = 39,
730     /**
731      * Axis constant: Generic 9 axis of a motion event.
732      * The interpretation of a generic axis is device-specific.
733      */
734     AMOTION_EVENT_AXIS_GENERIC_9 = 40,
735     /**
736      * Axis constant: Generic 10 axis of a motion event.
737      * The interpretation of a generic axis is device-specific.
738      */
739     AMOTION_EVENT_AXIS_GENERIC_10 = 41,
740     /**
741      * Axis constant: Generic 11 axis of a motion event.
742      * The interpretation of a generic axis is device-specific.
743      */
744     AMOTION_EVENT_AXIS_GENERIC_11 = 42,
745     /**
746      * Axis constant: Generic 12 axis of a motion event.
747      * The interpretation of a generic axis is device-specific.
748      */
749     AMOTION_EVENT_AXIS_GENERIC_12 = 43,
750     /**
751      * Axis constant: Generic 13 axis of a motion event.
752      * The interpretation of a generic axis is device-specific.
753      */
754     AMOTION_EVENT_AXIS_GENERIC_13 = 44,
755     /**
756      * Axis constant: Generic 14 axis of a motion event.
757      * The interpretation of a generic axis is device-specific.
758      */
759     AMOTION_EVENT_AXIS_GENERIC_14 = 45,
760     /**
761      * Axis constant: Generic 15 axis of a motion event.
762      * The interpretation of a generic axis is device-specific.
763      */
764     AMOTION_EVENT_AXIS_GENERIC_15 = 46,
765     /**
766      * Axis constant: Generic 16 axis of a motion event.
767      * The interpretation of a generic axis is device-specific.
768      */
769     AMOTION_EVENT_AXIS_GENERIC_16 = 47,
770     /**
771      * Axis constant: X gesture offset axis of a motion event.
772      *
773      * - For a touch pad, reports the distance that a swipe gesture has moved in the X axis, as a
774      *   proportion of the touch pad's size. For example, if a touch pad is 1000 units wide, and a
775      *   swipe gesture starts at X = 500 then moves to X = 400, this axis would have a value of
776      *   -0.1.
777      *
778      * These values are relative to the state from the last event, not accumulated, so developers
779      * should make sure to process this axis value for all batched historical events.
780      *
781      * This axis is only set on the first pointer in a motion event.
782      */
783     AMOTION_EVENT_AXIS_GESTURE_X_OFFSET = 48,
784     /**
785      * Axis constant: Y gesture offset axis of a motion event.
786      *
787      * The same as {@link AMOTION_EVENT_AXIS_GESTURE_X_OFFSET}, but for the Y axis.
788      */
789     AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET = 49,
790     /**
791      * Axis constant: X scroll distance axis of a motion event.
792      *
793      * - For a touch pad, reports the distance that should be scrolled in the X axis as a result of
794      *   the user's two-finger scroll gesture, in display pixels.
795      *
796      * These values are relative to the state from the last event, not accumulated, so developers
797      * should make sure to process this axis value for all batched historical events.
798      *
799      * This axis is only set on the first pointer in a motion event.
800      */
801     AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE = 50,
802     /**
803      * Axis constant: Y scroll distance axis of a motion event.
804      *
805      * The same as {@link AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE}, but for the Y axis.
806      */
807     AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE = 51,
808     /**
809      * Axis constant: pinch scale factor of a motion event.
810      *
811      * - For a touch pad, reports the change in distance between the fingers when the user is making
812      *   a pinch gesture, as a proportion of that distance when the gesture was last reported. For
813      *   example, if the fingers were 50 units apart and are now 52 units apart, the scale factor
814      *   would be 1.04.
815      *
816      * These values are relative to the state from the last event, not accumulated, so developers
817      * should make sure to process this axis value for all batched historical events.
818      *
819      * This axis is only set on the first pointer in a motion event.
820      */
821     AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR = 52,
822 
823     /**
824      * Axis constant: the number of fingers being used in a multi-finger swipe gesture.
825      *
826      * - For a touch pad, reports the number of fingers being used in a multi-finger swipe gesture
827      *   (with CLASSIFICATION_MULTI_FINGER_SWIPE).
828      *
829      * Since CLASSIFICATION_MULTI_FINGER_SWIPE is a hidden API, so is this axis. It is only set on
830      * the first pointer in a motion event.
831      */
832     AMOTION_EVENT_AXIS_GESTURE_SWIPE_FINGER_COUNT = 53,
833 
834     /**
835      * Note: This is not an "Axis constant". It does not represent any axis, nor should it be used
836      * to represent any axis. It is a constant holding the value of the largest defined axis value,
837      * to make some computations (like iterating through all possible axes) cleaner.
838      * Please update the value accordingly if you add a new axis.
839      */
840     AMOTION_EVENT_MAXIMUM_VALID_AXIS_VALUE = AMOTION_EVENT_AXIS_GESTURE_SWIPE_FINGER_COUNT,
841 
842     // NOTE: If you add a new axis here you must also add it to several other files.
843     //       Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
844     //       Update AMOTION_EVENT_MAXIMUM_VALID_AXIS_VALUE accordingly as well.
845 };
846 
847 /**
848  * Constants that identify buttons that are associated with motion events.
849  * Refer to the documentation on the MotionEvent class for descriptions of each button.
850  */
851 enum {
852     // LINT.IfChange(AMOTION_EVENT_BUTTON)
853     /** primary */
854     AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
855     /** secondary */
856     AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
857     /** tertiary */
858     AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
859     /** back */
860     AMOTION_EVENT_BUTTON_BACK = 1 << 3,
861     /** forward */
862     AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
863     AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
864     AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
865     // LINT.ThenChange(/frameworks/native/libs/input/rust/input.rs,/frameworks/native/services/inputflinger/tests/fuzzers/FuzzedInputStream.h)
866 };
867 
868 /**
869  * Constants that identify tool types.
870  * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
871  */
872 enum {
873     /** unknown */
874     AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
875     /** finger */
876     AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
877     /** stylus */
878     AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
879     /** mouse */
880     AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
881     /** eraser */
882     AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
883     /** palm */
884     AMOTION_EVENT_TOOL_TYPE_PALM = 5,
885 };
886 
887 /**
888  * Constants that identify different gesture classification types.
889  */
890 enum AMotionClassification : uint32_t {
891     /**
892      * Classification constant: None.
893      *
894      * No additional information is available about the current motion event stream.
895      */
896     AMOTION_EVENT_CLASSIFICATION_NONE = 0,
897     /**
898      * Classification constant: Ambiguous gesture.
899      *
900      * The user's intent with respect to the current event stream is not yet determined. Events
901      * starting in #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE will eventually resolve into
902      * either #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS or #AMOTION_EVENT_CLASSIFICATION_NONE.
903      * Gestural actions, such as scrolling, should be inhibited until the classification resolves
904      * to another value or the event stream ends.
905      */
906     AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE = 1,
907     /**
908      * Classification constant: Deep press.
909      *
910      * The current event stream represents the user intentionally pressing harder on the screen.
911      * This classification type should be used to accelerate the long press behaviour.
912      */
913     AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS = 2,
914     /**
915      * Classification constant: touchpad two-finger swipe.
916      *
917      * The current event stream represents the user swiping with two fingers on a touchpad.
918      */
919     AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE = 3,
920     /**
921      * Classification constant: multi-finger swipe.
922      *
923      * The current event stream represents the user swiping with three or more fingers on a
924      * touchpad. Unlike two-finger swipes, these are only to be handled by the system UI, which is
925      * why they have a separate constant from two-finger swipes.
926      */
927     AMOTION_EVENT_CLASSIFICATION_MULTI_FINGER_SWIPE = 4,
928     /**
929      * Classification constant: pinch.
930      *
931      * The current event stream represents the user pinching with two fingers on a touchpad. The
932      * gesture is centered around the current cursor position.
933      */
934     AMOTION_EVENT_CLASSIFICATION_PINCH = 5,
935 };
936 
937 /**
938  * Input source masks.
939  *
940  * Refer to the documentation on android.view.InputDevice for more details about input sources
941  * and their correct interpretation.
942  */
943 enum {
944     /** mask */
945     AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
946 
947     /** none */
948     AINPUT_SOURCE_CLASS_NONE = 0x00000000,
949     /** button */
950     AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
951     /** pointer */
952     AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
953     /** navigation */
954     AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
955     /** position */
956     AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
957     /** joystick */
958     AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
959 };
960 
961 /**
962  * Input sources.
963  */
964 enum {
965     /** unknown */
966     AINPUT_SOURCE_UNKNOWN = 0x00000000,
967 
968     /** keyboard */
969     AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
970     /** dpad */
971     AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
972     /** gamepad */
973     AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
974     /** touchscreen */
975     AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
976     /** mouse */
977     AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
978     /** stylus */
979     AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
980     /** bluetooth stylus */
981     AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
982     /** trackball */
983     AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
984     /** mouse relative */
985     AINPUT_SOURCE_MOUSE_RELATIVE = 0x00020000 | AINPUT_SOURCE_CLASS_NAVIGATION,
986     /** touchpad */
987     AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
988     /** navigation */
989     AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
990     /** joystick */
991     AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
992     /** HDMI */
993     AINPUT_SOURCE_HDMI = 0x02000000 | AINPUT_SOURCE_CLASS_BUTTON,
994     /** sensor */
995     AINPUT_SOURCE_SENSOR = 0x04000000 | AINPUT_SOURCE_CLASS_NONE,
996     /** rotary encoder */
997     AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE,
998 
999     /** any */
1000     AINPUT_SOURCE_ANY = 0xffffff00,
1001 };
1002 
1003 /**
1004  * Keyboard types.
1005  *
1006  * Refer to the documentation on android.view.InputDevice for more details.
1007  */
1008 enum {
1009     /** none */
1010     AINPUT_KEYBOARD_TYPE_NONE = 0,
1011     /** non alphabetic */
1012     AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
1013     /** alphabetic */
1014     AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
1015 };
1016 
1017 /**
1018  * Constants used to retrieve information about the range of motion for a particular
1019  * coordinate of a motion event.
1020  *
1021  * Refer to the documentation on android.view.InputDevice for more details about input sources
1022  * and their correct interpretation.
1023  *
1024  * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*}
1025  * constants instead.
1026  */
1027 enum {
1028     /** x */
1029     AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
1030     /** y */
1031     AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
1032     /** pressure */
1033     AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
1034     /** size */
1035     AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
1036     /** touch major */
1037     AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
1038     /** touch minor */
1039     AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
1040     /** tool major */
1041     AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
1042     /** tool minor */
1043     AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
1044     /** orientation */
1045     AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
1046 };
1047 
1048 
1049 /**
1050  * Input event accessors.
1051  *
1052  * Note that most functions can only be used on input events that are of a given type.
1053  * Calling these functions on input events of other types will yield undefined behavior.
1054  */
1055 
1056 /*** Accessors for all input events. ***/
1057 
1058 /** Get the input event type. */
1059 int32_t AInputEvent_getType(const AInputEvent* event);
1060 
1061 /** Get the id for the device that an input event came from.
1062  *
1063  * Input events can be generated by multiple different input devices.
1064  * Use the input device id to obtain information about the input
1065  * device that was responsible for generating a particular event.
1066  *
1067  * An input device id of 0 indicates that the event didn't come from a physical device;
1068  * other numbers are arbitrary and you shouldn't depend on the values.
1069  * Use the provided input device query API to obtain information about input devices.
1070  */
1071 int32_t AInputEvent_getDeviceId(const AInputEvent* event);
1072 
1073 /** Get the input event source. */
1074 int32_t AInputEvent_getSource(const AInputEvent* event);
1075 
1076 /**
1077  * Releases interface objects created by {@link AKeyEvent_fromJava()}
1078  * and {@link AMotionEvent_fromJava()}.
1079  * After returning, the specified {@link AInputEvent}* object becomes invalid and should no longer
1080  * be used. The underlying Java object remains valid and does not change its state.
1081  *
1082  * Available since API level 31.
1083  */
1084 void AInputEvent_release(const AInputEvent* event) __INTRODUCED_IN(31);
1085 
1086 /*** Accessors for key events only. ***/
1087 
1088 /** Get the key event action. */
1089 int32_t AKeyEvent_getAction(const AInputEvent* key_event);
1090 
1091 /** Get the key event flags. */
1092 int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
1093 
1094 /**
1095  * Get the key code of the key event.
1096  * This is the physical key that was pressed, not the Unicode character.
1097  */
1098 int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
1099 
1100 /**
1101  * Get the hardware key id of this key event.
1102  * These values are not reliable and vary from device to device.
1103  */
1104 int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
1105 
1106 /** Get the meta key state. */
1107 int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
1108 
1109 /**
1110  * Get the repeat count of the event.
1111  * For both key up an key down events, this is the number of times the key has
1112  * repeated with the first down starting at 0 and counting up from there.  For
1113  * multiple key events, this is the number of down/up pairs that have occurred.
1114  */
1115 int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
1116 
1117 /**
1118  * Get the time of the most recent key down event, in the
1119  * java.lang.System.nanoTime() time base.  If this is a down event,
1120  * this will be the same as eventTime.
1121  * Note that when chording keys, this value is the down time of the most recently
1122  * pressed key, which may not be the same physical key of this event.
1123  */
1124 int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
1125 
1126 /**
1127  * Get the time this event occurred, in the
1128  * java.lang.System.nanoTime() time base.
1129  */
1130 int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
1131 
1132 /**
1133  * Creates a native {@link AInputEvent}* object that is a copy of the specified Java
1134  * android.view.KeyEvent. The result may be used with generic and KeyEvent-specific AInputEvent_*
1135  * functions. The object returned by this function must be disposed using
1136  * {@link AInputEvent_release()}.
1137  *
1138  * Available since API level 31.
1139  */
1140 const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent) __INTRODUCED_IN(31);
1141 
1142 /*** Accessors for motion events only. ***/
1143 
1144 /** Get the combined motion event action code and pointer index. */
1145 int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
1146 
1147 /** Get the motion event flags. */
1148 int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
1149 
1150 /**
1151  * Get the state of any meta / modifier keys that were in effect when the
1152  * event was generated.
1153  */
1154 int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
1155 
1156 /** Get the button state of all buttons that are pressed. */
1157 int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
1158 
1159 /**
1160  * Get a bitfield indicating which edges, if any, were touched by this motion event.
1161  * For touch events, clients can use this to determine if the user's finger was
1162  * touching the edge of the display.
1163  */
1164 int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
1165 
1166 /**
1167  * Get the time when the user originally pressed down to start a stream of
1168  * position events, in the java.lang.System.nanoTime() time base.
1169  */
1170 int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
1171 
1172 /**
1173  * Get the time when this specific event was generated,
1174  * in the java.lang.System.nanoTime() time base.
1175  */
1176 int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
1177 
1178 /**
1179  * Get the X coordinate offset.
1180  * For touch events on the screen, this is the delta that was added to the raw
1181  * screen coordinates to adjust for the absolute position of the containing windows
1182  * and views.
1183  */
1184 float AMotionEvent_getXOffset(const AInputEvent* motion_event);
1185 
1186 /**
1187  * Get the Y coordinate offset.
1188  * For touch events on the screen, this is the delta that was added to the raw
1189  * screen coordinates to adjust for the absolute position of the containing windows
1190  * and views.
1191  */
1192 float AMotionEvent_getYOffset(const AInputEvent* motion_event);
1193 
1194 /**
1195  * Get the precision of the X coordinates being reported.
1196  * You can multiply this number with an X coordinate sample to find the
1197  * actual hardware value of the X coordinate.
1198  */
1199 float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
1200 
1201 /**
1202  * Get the precision of the Y coordinates being reported.
1203  * You can multiply this number with a Y coordinate sample to find the
1204  * actual hardware value of the Y coordinate.
1205  */
1206 float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
1207 
1208 /**
1209  * Get the number of pointers of data contained in this event.
1210  * Always >= 1.
1211  */
1212 size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
1213 
1214 /**
1215  * Get the pointer identifier associated with a particular pointer
1216  * data index in this event.  The identifier tells you the actual pointer
1217  * number associated with the data, accounting for individual pointers
1218  * going up and down since the start of the current gesture.
1219  */
1220 int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
1221 
1222 /**
1223  * Get the tool type of a pointer for the given pointer index.
1224  * The tool type indicates the type of tool used to make contact such as a
1225  * finger or stylus, if known.
1226  */
1227 int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
1228 
1229 /**
1230  * Get the original raw X coordinate of this event.
1231  * For touch events on the screen, this is the original location of the event
1232  * on the screen, before it had been adjusted for the containing window
1233  * and views.
1234  */
1235 float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
1236 
1237 /**
1238  * Get the original raw X coordinate of this event.
1239  * For touch events on the screen, this is the original location of the event
1240  * on the screen, before it had been adjusted for the containing window
1241  * and views.
1242  */
1243 float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
1244 
1245 /**
1246  * Get the current X coordinate of this event for the given pointer index.
1247  * Whole numbers are pixels; the value may have a fraction for input devices
1248  * that are sub-pixel precise.
1249  */
1250 float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
1251 
1252 /**
1253  * Get the current Y coordinate of this event for the given pointer index.
1254  * Whole numbers are pixels; the value may have a fraction for input devices
1255  * that are sub-pixel precise.
1256  */
1257 float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
1258 
1259 /**
1260  * Get the current pressure of this event for the given pointer index.
1261  * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1262  * although values higher than 1 may be generated depending on the calibration of
1263  * the input device.
1264  */
1265 float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
1266 
1267 /**
1268  * Get the current scaled value of the approximate size for the given pointer index.
1269  * This represents some approximation of the area of the screen being
1270  * pressed; the actual value in pixels corresponding to the
1271  * touch is normalized with the device specific range of values
1272  * and scaled to a value between 0 and 1.  The value of size can be used to
1273  * determine fat touch events.
1274  */
1275 float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
1276 
1277 /**
1278  * Get the current length of the major axis of an ellipse that describes the touch area
1279  * at the point of contact for the given pointer index.
1280  */
1281 float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
1282 
1283 /**
1284  * Get the current length of the minor axis of an ellipse that describes the touch area
1285  * at the point of contact for the given pointer index.
1286  */
1287 float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
1288 
1289 /**
1290  * Get the current length of the major axis of an ellipse that describes the size
1291  * of the approaching tool for the given pointer index.
1292  * The tool area represents the estimated size of the finger or pen that is
1293  * touching the device independent of its actual touch area at the point of contact.
1294  */
1295 float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
1296 
1297 /**
1298  * Get the current length of the minor axis of an ellipse that describes the size
1299  * of the approaching tool for the given pointer index.
1300  * The tool area represents the estimated size of the finger or pen that is
1301  * touching the device independent of its actual touch area at the point of contact.
1302  */
1303 float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
1304 
1305 /**
1306  * Get the current orientation of the touch area and tool area in radians clockwise from
1307  * vertical for the given pointer index.
1308  * An angle of 0 degrees indicates that the major axis of contact is oriented
1309  * upwards, is perfectly circular or is of unknown orientation.  A positive angle
1310  * indicates that the major axis of contact is oriented to the right.  A negative angle
1311  * indicates that the major axis of contact is oriented to the left.
1312  * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
1313  * (finger pointing fully right).
1314  */
1315 float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
1316 
1317 /** Get the value of the request axis for the given pointer index. */
1318 float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
1319         int32_t axis, size_t pointer_index);
1320 
1321 /**
1322  * Get the number of historical points in this event.  These are movements that
1323  * have occurred between this event and the previous event.  This only applies
1324  * to #AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
1325  * Historical samples are indexed from oldest to newest.
1326  */
1327 size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
1328 
1329 /**
1330  * Get the time that a historical movement occurred between this event and
1331  * the previous event, in the java.lang.System.nanoTime() time base.
1332  */
1333 int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
1334         size_t history_index);
1335 
1336 /**
1337  * Get the historical raw X coordinate of this event for the given pointer index that
1338  * occurred between this event and the previous motion event.
1339  * For touch events on the screen, this is the original location of the event
1340  * on the screen, before it had been adjusted for the containing window
1341  * and views.
1342  * Whole numbers are pixels; the value may have a fraction for input devices
1343  * that are sub-pixel precise.
1344  */
1345 float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
1346         size_t history_index);
1347 
1348 /**
1349  * Get the historical raw Y coordinate of this event for the given pointer index that
1350  * occurred between this event and the previous motion event.
1351  * For touch events on the screen, this is the original location of the event
1352  * on the screen, before it had been adjusted for the containing window
1353  * and views.
1354  * Whole numbers are pixels; the value may have a fraction for input devices
1355  * that are sub-pixel precise.
1356  */
1357 float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
1358         size_t history_index);
1359 
1360 /**
1361  * Get the historical X coordinate of this event for the given pointer index that
1362  * occurred between this event and the previous motion event.
1363  * Whole numbers are pixels; the value may have a fraction for input devices
1364  * that are sub-pixel precise.
1365  */
1366 float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
1367         size_t history_index);
1368 
1369 /**
1370  * Get the historical Y coordinate of this event for the given pointer index that
1371  * occurred between this event and the previous motion event.
1372  * Whole numbers are pixels; the value may have a fraction for input devices
1373  * that are sub-pixel precise.
1374  */
1375 float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
1376         size_t history_index);
1377 
1378 /**
1379  * Get the historical pressure of this event for the given pointer index that
1380  * occurred between this event and the previous motion event.
1381  * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1382  * although values higher than 1 may be generated depending on the calibration of
1383  * the input device.
1384  */
1385 float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
1386         size_t history_index);
1387 
1388 /**
1389  * Get the current scaled value of the approximate size for the given pointer index that
1390  * occurred between this event and the previous motion event.
1391  * This represents some approximation of the area of the screen being
1392  * pressed; the actual value in pixels corresponding to the
1393  * touch is normalized with the device specific range of values
1394  * and scaled to a value between 0 and 1.  The value of size can be used to
1395  * determine fat touch events.
1396  */
1397 float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
1398         size_t history_index);
1399 
1400 /**
1401  * Get the historical length of the major axis of an ellipse that describes the touch area
1402  * at the point of contact for the given pointer index that
1403  * occurred between this event and the previous motion event.
1404  */
1405 float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
1406         size_t history_index);
1407 
1408 /**
1409  * Get the historical length of the minor axis of an ellipse that describes the touch area
1410  * at the point of contact for the given pointer index that
1411  * occurred between this event and the previous motion event.
1412  */
1413 float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
1414         size_t history_index);
1415 
1416 /**
1417  * Get the historical length of the major axis of an ellipse that describes the size
1418  * of the approaching tool for the given pointer index that
1419  * occurred between this event and the previous motion event.
1420  * The tool area represents the estimated size of the finger or pen that is
1421  * touching the device independent of its actual touch area at the point of contact.
1422  */
1423 float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
1424         size_t history_index);
1425 
1426 /**
1427  * Get the historical length of the minor axis of an ellipse that describes the size
1428  * of the approaching tool for the given pointer index that
1429  * occurred between this event and the previous motion event.
1430  * The tool area represents the estimated size of the finger or pen that is
1431  * touching the device independent of its actual touch area at the point of contact.
1432  */
1433 float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
1434         size_t history_index);
1435 
1436 /**
1437  * Get the historical orientation of the touch area and tool area in radians clockwise from
1438  * vertical for the given pointer index that
1439  * occurred between this event and the previous motion event.
1440  * An angle of 0 degrees indicates that the major axis of contact is oriented
1441  * upwards, is perfectly circular or is of unknown orientation.  A positive angle
1442  * indicates that the major axis of contact is oriented to the right.  A negative angle
1443  * indicates that the major axis of contact is oriented to the left.
1444  * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
1445  * (finger pointing fully right).
1446  */
1447 float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
1448         size_t history_index);
1449 
1450 /**
1451  * Get the historical value of the request axis for the given pointer index
1452  * that occurred between this event and the previous motion event.
1453  */
1454 float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
1455         int32_t axis, size_t pointer_index, size_t history_index);
1456 
1457 /**
1458  * Get the action button for the motion event. Returns a valid action button when the
1459  * event is associated with a button press or button release action. For other actions
1460  * the return value is undefined.
1461  *
1462  * @see #AMOTION_EVENT_BUTTON_PRIMARY
1463  * @see #AMOTION_EVENT_BUTTON_SECONDARY
1464  * @see #AMOTION_EVENT_BUTTON_TERTIARY
1465  * @see #AMOTION_EVENT_BUTTON_BACK
1466  * @see #AMOTION_EVENT_BUTTON_FORWARD
1467  * @see #AMOTION_EVENT_BUTTON_STYLUS_PRIMARY
1468  * @see #AMOTION_EVENT_BUTTON_STYLUS_SECONDARY
1469  */
1470 int32_t AMotionEvent_getActionButton(const AInputEvent* motion_event)
1471         __INTRODUCED_IN(__ANDROID_API_T__);
1472 
1473 /**
1474  * Returns the classification for the current gesture.
1475  * The classification may change as more events become available for the same gesture.
1476  *
1477  * @see #AMOTION_EVENT_CLASSIFICATION_NONE
1478  * @see #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE
1479  * @see #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS
1480 */
1481 int32_t AMotionEvent_getClassification(const AInputEvent* motion_event)
1482         __INTRODUCED_IN(__ANDROID_API_T__);
1483 
1484 /**
1485  * Creates a native {@link AInputEvent}* object that is a copy of the specified Java
1486  * android.view.MotionEvent. The result may be used with generic and MotionEvent-specific
1487  * AInputEvent_* functions. The object returned by this function must be disposed using
1488  * {@link AInputEvent_release()}.
1489  *
1490  * Available since API level 31.
1491  */
1492 const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) __INTRODUCED_IN(31);
1493 
1494 /**
1495  * Creates a java android.view.InputEvent object that is a copy of the specified native
1496  * {@link AInputEvent}.
1497  *
1498  * Specified {@link AInputEvent} is require to be a valid {@link MotionEvent} or {@link KeyEvent}
1499  * object.
1500  *
1501  *  Available since API level 35.
1502  */
1503 jobject AInputEvent_toJava(JNIEnv* env, const AInputEvent* aInputEvent) __INTRODUCED_IN(35);
1504 
1505 struct AInputQueue;
1506 /**
1507  * Input queue
1508  *
1509  * An input queue is the facility through which you retrieve input
1510  * events.
1511  */
1512 typedef struct AInputQueue AInputQueue;
1513 
1514 /**
1515  * Add this input queue to a looper for processing.  See
1516  * {@link ALooper_addFd()} for information on the ident, callback, and data params.
1517  */
1518 void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
1519         int ident, ALooper_callbackFunc callback, void* data);
1520 
1521 /**
1522  * Remove the input queue from the looper it is currently attached to.
1523  */
1524 void AInputQueue_detachLooper(AInputQueue* queue);
1525 
1526 /**
1527  * Returns true if there are one or more events available in the
1528  * input queue.  Returns 1 if the queue has events; 0 if
1529  * it does not have events; and a negative value if there is an error.
1530  */
1531 int32_t AInputQueue_hasEvents(AInputQueue* queue);
1532 
1533 /**
1534  * Returns the next available event from the queue.  Returns a negative
1535  * value if no events are available or an error has occurred.
1536  */
1537 int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
1538 
1539 /**
1540  * Sends the key for standard pre-dispatching -- that is, possibly deliver
1541  * it to the current IME to be consumed before the app.  Returns 0 if it
1542  * was not pre-dispatched, meaning you can process it right now.  If non-zero
1543  * is returned, you must abandon the current event processing and allow the
1544  * event to appear again in the event queue (if it does not get consumed during
1545  * pre-dispatching).
1546  */
1547 int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
1548 
1549 /**
1550  * Report that dispatching has finished with the given event.
1551  * This must be called after receiving an event with {@link AInputQueue_getEvent()}.
1552  */
1553 void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
1554 
1555 /**
1556  * Returns the {@link AInputQueue}* object associated with the supplied Java InputQueue
1557  * object. The returned native object holds a weak reference to the Java object,
1558  * and is only valid as long as the Java object has not yet been disposed. You
1559  * should ensure that there is a strong reference to the Java object and that it
1560  * has not been disposed before using the returned object.
1561  *
1562  * Available since API level 33.
1563  */
1564 AInputQueue* AInputQueue_fromJava(JNIEnv* env, jobject inputQueue) __INTRODUCED_IN(33);
1565 
1566 #ifdef __cplusplus
1567 }
1568 #endif
1569 
1570 #endif // _ANDROID_INPUT_H
1571 
1572 /** @} */
1573