• 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     /** primary */
853     AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
854     /** secondary */
855     AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
856     /** tertiary */
857     AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
858     /** back */
859     AMOTION_EVENT_BUTTON_BACK = 1 << 3,
860     /** forward */
861     AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
862     AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
863     AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
864 };
865 
866 /**
867  * Constants that identify tool types.
868  * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
869  */
870 enum {
871     /** unknown */
872     AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
873     /** finger */
874     AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
875     /** stylus */
876     AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
877     /** mouse */
878     AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
879     /** eraser */
880     AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
881     /** palm */
882     AMOTION_EVENT_TOOL_TYPE_PALM = 5,
883 };
884 
885 /**
886  * Constants that identify different gesture classification types.
887  */
888 enum AMotionClassification : uint32_t {
889     /**
890      * Classification constant: None.
891      *
892      * No additional information is available about the current motion event stream.
893      */
894     AMOTION_EVENT_CLASSIFICATION_NONE = 0,
895     /**
896      * Classification constant: Ambiguous gesture.
897      *
898      * The user's intent with respect to the current event stream is not yet determined. Events
899      * starting in #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE will eventually resolve into
900      * either #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS or #AMOTION_EVENT_CLASSIFICATION_NONE.
901      * Gestural actions, such as scrolling, should be inhibited until the classification resolves
902      * to another value or the event stream ends.
903      */
904     AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE = 1,
905     /**
906      * Classification constant: Deep press.
907      *
908      * The current event stream represents the user intentionally pressing harder on the screen.
909      * This classification type should be used to accelerate the long press behaviour.
910      */
911     AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS = 2,
912     /**
913      * Classification constant: touchpad two-finger swipe.
914      *
915      * The current event stream represents the user swiping with two fingers on a touchpad.
916      */
917     AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE = 3,
918     /**
919      * Classification constant: multi-finger swipe.
920      *
921      * The current event stream represents the user swiping with three or more fingers on a
922      * touchpad. Unlike two-finger swipes, these are only to be handled by the system UI, which is
923      * why they have a separate constant from two-finger swipes.
924      */
925     AMOTION_EVENT_CLASSIFICATION_MULTI_FINGER_SWIPE = 4,
926     /**
927      * Classification constant: pinch.
928      *
929      * The current event stream represents the user pinching with two fingers on a touchpad. The
930      * gesture is centered around the current cursor position.
931      */
932     AMOTION_EVENT_CLASSIFICATION_PINCH = 5,
933 };
934 
935 /**
936  * Input source masks.
937  *
938  * Refer to the documentation on android.view.InputDevice for more details about input sources
939  * and their correct interpretation.
940  */
941 enum {
942     /** mask */
943     AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
944 
945     /** none */
946     AINPUT_SOURCE_CLASS_NONE = 0x00000000,
947     /** button */
948     AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
949     /** pointer */
950     AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
951     /** navigation */
952     AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
953     /** position */
954     AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
955     /** joystick */
956     AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
957 };
958 
959 /**
960  * Input sources.
961  */
962 enum {
963     /** unknown */
964     AINPUT_SOURCE_UNKNOWN = 0x00000000,
965 
966     /** keyboard */
967     AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
968     /** dpad */
969     AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
970     /** gamepad */
971     AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
972     /** touchscreen */
973     AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
974     /** mouse */
975     AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
976     /** stylus */
977     AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
978     /** bluetooth stylus */
979     AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
980     /** trackball */
981     AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
982     /** mouse relative */
983     AINPUT_SOURCE_MOUSE_RELATIVE = 0x00020000 | AINPUT_SOURCE_CLASS_NAVIGATION,
984     /** touchpad */
985     AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
986     /** navigation */
987     AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
988     /** joystick */
989     AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
990     /** HDMI */
991     AINPUT_SOURCE_HDMI = 0x02000000 | AINPUT_SOURCE_CLASS_BUTTON,
992     /** sensor */
993     AINPUT_SOURCE_SENSOR = 0x04000000 | AINPUT_SOURCE_CLASS_NONE,
994     /** rotary encoder */
995     AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE,
996 
997     /** any */
998     AINPUT_SOURCE_ANY = 0xffffff00,
999 };
1000 
1001 /**
1002  * Keyboard types.
1003  *
1004  * Refer to the documentation on android.view.InputDevice for more details.
1005  */
1006 enum {
1007     /** none */
1008     AINPUT_KEYBOARD_TYPE_NONE = 0,
1009     /** non alphabetic */
1010     AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
1011     /** alphabetic */
1012     AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
1013 };
1014 
1015 /**
1016  * Constants used to retrieve information about the range of motion for a particular
1017  * coordinate of a motion event.
1018  *
1019  * Refer to the documentation on android.view.InputDevice for more details about input sources
1020  * and their correct interpretation.
1021  *
1022  * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*}
1023  * constants instead.
1024  */
1025 enum {
1026     /** x */
1027     AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
1028     /** y */
1029     AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
1030     /** pressure */
1031     AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
1032     /** size */
1033     AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
1034     /** touch major */
1035     AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
1036     /** touch minor */
1037     AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
1038     /** tool major */
1039     AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
1040     /** tool minor */
1041     AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
1042     /** orientation */
1043     AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
1044 };
1045 
1046 
1047 /**
1048  * Input event accessors.
1049  *
1050  * Note that most functions can only be used on input events that are of a given type.
1051  * Calling these functions on input events of other types will yield undefined behavior.
1052  */
1053 
1054 /*** Accessors for all input events. ***/
1055 
1056 /** Get the input event type. */
1057 int32_t AInputEvent_getType(const AInputEvent* event);
1058 
1059 /** Get the id for the device that an input event came from.
1060  *
1061  * Input events can be generated by multiple different input devices.
1062  * Use the input device id to obtain information about the input
1063  * device that was responsible for generating a particular event.
1064  *
1065  * An input device id of 0 indicates that the event didn't come from a physical device;
1066  * other numbers are arbitrary and you shouldn't depend on the values.
1067  * Use the provided input device query API to obtain information about input devices.
1068  */
1069 int32_t AInputEvent_getDeviceId(const AInputEvent* event);
1070 
1071 /** Get the input event source. */
1072 int32_t AInputEvent_getSource(const AInputEvent* event);
1073 
1074 /**
1075  * Releases interface objects created by {@link AKeyEvent_fromJava()}
1076  * and {@link AMotionEvent_fromJava()}.
1077  * After returning, the specified {@link AInputEvent}* object becomes invalid and should no longer
1078  * be used. The underlying Java object remains valid and does not change its state.
1079  *
1080  * Available since API level 31.
1081  */
1082 void AInputEvent_release(const AInputEvent* event) __INTRODUCED_IN(31);
1083 
1084 /*** Accessors for key events only. ***/
1085 
1086 /** Get the key event action. */
1087 int32_t AKeyEvent_getAction(const AInputEvent* key_event);
1088 
1089 /** Get the key event flags. */
1090 int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
1091 
1092 /**
1093  * Get the key code of the key event.
1094  * This is the physical key that was pressed, not the Unicode character.
1095  */
1096 int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
1097 
1098 /**
1099  * Get the hardware key id of this key event.
1100  * These values are not reliable and vary from device to device.
1101  */
1102 int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
1103 
1104 /** Get the meta key state. */
1105 int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
1106 
1107 /**
1108  * Get the repeat count of the event.
1109  * For both key up an key down events, this is the number of times the key has
1110  * repeated with the first down starting at 0 and counting up from there.  For
1111  * multiple key events, this is the number of down/up pairs that have occurred.
1112  */
1113 int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
1114 
1115 /**
1116  * Get the time of the most recent key down event, in the
1117  * java.lang.System.nanoTime() time base.  If this is a down event,
1118  * this will be the same as eventTime.
1119  * Note that when chording keys, this value is the down time of the most recently
1120  * pressed key, which may not be the same physical key of this event.
1121  */
1122 int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
1123 
1124 /**
1125  * Get the time this event occurred, in the
1126  * java.lang.System.nanoTime() time base.
1127  */
1128 int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
1129 
1130 /**
1131  * Creates a native {@link AInputEvent}* object that is a copy of the specified Java
1132  * android.view.KeyEvent. The result may be used with generic and KeyEvent-specific AInputEvent_*
1133  * functions. The object returned by this function must be disposed using
1134  * {@link AInputEvent_release()}.
1135  *
1136  * Available since API level 31.
1137  */
1138 const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent) __INTRODUCED_IN(31);
1139 
1140 /*** Accessors for motion events only. ***/
1141 
1142 /** Get the combined motion event action code and pointer index. */
1143 int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
1144 
1145 /** Get the motion event flags. */
1146 int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
1147 
1148 /**
1149  * Get the state of any meta / modifier keys that were in effect when the
1150  * event was generated.
1151  */
1152 int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
1153 
1154 /** Get the button state of all buttons that are pressed. */
1155 int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
1156 
1157 /**
1158  * Get a bitfield indicating which edges, if any, were touched by this motion event.
1159  * For touch events, clients can use this to determine if the user's finger was
1160  * touching the edge of the display.
1161  */
1162 int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
1163 
1164 /**
1165  * Get the time when the user originally pressed down to start a stream of
1166  * position events, in the java.lang.System.nanoTime() time base.
1167  */
1168 int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
1169 
1170 /**
1171  * Get the time when this specific event was generated,
1172  * in the java.lang.System.nanoTime() time base.
1173  */
1174 int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
1175 
1176 /**
1177  * Get the X coordinate offset.
1178  * For touch events on the screen, this is the delta that was added to the raw
1179  * screen coordinates to adjust for the absolute position of the containing windows
1180  * and views.
1181  */
1182 float AMotionEvent_getXOffset(const AInputEvent* motion_event);
1183 
1184 /**
1185  * Get the Y coordinate offset.
1186  * For touch events on the screen, this is the delta that was added to the raw
1187  * screen coordinates to adjust for the absolute position of the containing windows
1188  * and views.
1189  */
1190 float AMotionEvent_getYOffset(const AInputEvent* motion_event);
1191 
1192 /**
1193  * Get the precision of the X coordinates being reported.
1194  * You can multiply this number with an X coordinate sample to find the
1195  * actual hardware value of the X coordinate.
1196  */
1197 float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
1198 
1199 /**
1200  * Get the precision of the Y coordinates being reported.
1201  * You can multiply this number with a Y coordinate sample to find the
1202  * actual hardware value of the Y coordinate.
1203  */
1204 float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
1205 
1206 /**
1207  * Get the number of pointers of data contained in this event.
1208  * Always >= 1.
1209  */
1210 size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
1211 
1212 /**
1213  * Get the pointer identifier associated with a particular pointer
1214  * data index in this event.  The identifier tells you the actual pointer
1215  * number associated with the data, accounting for individual pointers
1216  * going up and down since the start of the current gesture.
1217  */
1218 int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
1219 
1220 /**
1221  * Get the tool type of a pointer for the given pointer index.
1222  * The tool type indicates the type of tool used to make contact such as a
1223  * finger or stylus, if known.
1224  */
1225 int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
1226 
1227 /**
1228  * Get the original raw X coordinate of this event.
1229  * For touch events on the screen, this is the original location of the event
1230  * on the screen, before it had been adjusted for the containing window
1231  * and views.
1232  */
1233 float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
1234 
1235 /**
1236  * Get the original raw X coordinate of this event.
1237  * For touch events on the screen, this is the original location of the event
1238  * on the screen, before it had been adjusted for the containing window
1239  * and views.
1240  */
1241 float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
1242 
1243 /**
1244  * Get the current X coordinate of this event for the given pointer index.
1245  * Whole numbers are pixels; the value may have a fraction for input devices
1246  * that are sub-pixel precise.
1247  */
1248 float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
1249 
1250 /**
1251  * Get the current Y coordinate of this event for the given pointer index.
1252  * Whole numbers are pixels; the value may have a fraction for input devices
1253  * that are sub-pixel precise.
1254  */
1255 float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
1256 
1257 /**
1258  * Get the current pressure of this event for the given pointer index.
1259  * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1260  * although values higher than 1 may be generated depending on the calibration of
1261  * the input device.
1262  */
1263 float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
1264 
1265 /**
1266  * Get the current scaled value of the approximate size for the given pointer index.
1267  * This represents some approximation of the area of the screen being
1268  * pressed; the actual value in pixels corresponding to the
1269  * touch is normalized with the device specific range of values
1270  * and scaled to a value between 0 and 1.  The value of size can be used to
1271  * determine fat touch events.
1272  */
1273 float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
1274 
1275 /**
1276  * Get the current length of the major axis of an ellipse that describes the touch area
1277  * at the point of contact for the given pointer index.
1278  */
1279 float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
1280 
1281 /**
1282  * Get the current length of the minor axis of an ellipse that describes the touch area
1283  * at the point of contact for the given pointer index.
1284  */
1285 float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
1286 
1287 /**
1288  * Get the current length of the major axis of an ellipse that describes the size
1289  * of the approaching tool for the given pointer index.
1290  * The tool area represents the estimated size of the finger or pen that is
1291  * touching the device independent of its actual touch area at the point of contact.
1292  */
1293 float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
1294 
1295 /**
1296  * Get the current length of the minor axis of an ellipse that describes the size
1297  * of the approaching tool for the given pointer index.
1298  * The tool area represents the estimated size of the finger or pen that is
1299  * touching the device independent of its actual touch area at the point of contact.
1300  */
1301 float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
1302 
1303 /**
1304  * Get the current orientation of the touch area and tool area in radians clockwise from
1305  * vertical for the given pointer index.
1306  * An angle of 0 degrees indicates that the major axis of contact is oriented
1307  * upwards, is perfectly circular or is of unknown orientation.  A positive angle
1308  * indicates that the major axis of contact is oriented to the right.  A negative angle
1309  * indicates that the major axis of contact is oriented to the left.
1310  * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
1311  * (finger pointing fully right).
1312  */
1313 float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
1314 
1315 /** Get the value of the request axis for the given pointer index. */
1316 float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
1317         int32_t axis, size_t pointer_index);
1318 
1319 /**
1320  * Get the number of historical points in this event.  These are movements that
1321  * have occurred between this event and the previous event.  This only applies
1322  * to #AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
1323  * Historical samples are indexed from oldest to newest.
1324  */
1325 size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
1326 
1327 /**
1328  * Get the time that a historical movement occurred between this event and
1329  * the previous event, in the java.lang.System.nanoTime() time base.
1330  */
1331 int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
1332         size_t history_index);
1333 
1334 /**
1335  * Get the historical raw X coordinate of this event for the given pointer index that
1336  * occurred between this event and the previous motion event.
1337  * For touch events on the screen, this is the original location of the event
1338  * on the screen, before it had been adjusted for the containing window
1339  * and views.
1340  * Whole numbers are pixels; the value may have a fraction for input devices
1341  * that are sub-pixel precise.
1342  */
1343 float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
1344         size_t history_index);
1345 
1346 /**
1347  * Get the historical raw Y coordinate of this event for the given pointer index that
1348  * occurred between this event and the previous motion event.
1349  * For touch events on the screen, this is the original location of the event
1350  * on the screen, before it had been adjusted for the containing window
1351  * and views.
1352  * Whole numbers are pixels; the value may have a fraction for input devices
1353  * that are sub-pixel precise.
1354  */
1355 float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
1356         size_t history_index);
1357 
1358 /**
1359  * Get the historical X coordinate of this event for the given pointer index that
1360  * occurred between this event and the previous motion event.
1361  * Whole numbers are pixels; the value may have a fraction for input devices
1362  * that are sub-pixel precise.
1363  */
1364 float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
1365         size_t history_index);
1366 
1367 /**
1368  * Get the historical Y coordinate of this event for the given pointer index that
1369  * occurred between this event and the previous motion event.
1370  * Whole numbers are pixels; the value may have a fraction for input devices
1371  * that are sub-pixel precise.
1372  */
1373 float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
1374         size_t history_index);
1375 
1376 /**
1377  * Get the historical pressure of this event for the given pointer index that
1378  * occurred between this event and the previous motion event.
1379  * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1380  * although values higher than 1 may be generated depending on the calibration of
1381  * the input device.
1382  */
1383 float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
1384         size_t history_index);
1385 
1386 /**
1387  * Get the current scaled value of the approximate size for the given pointer index that
1388  * occurred between this event and the previous motion event.
1389  * This represents some approximation of the area of the screen being
1390  * pressed; the actual value in pixels corresponding to the
1391  * touch is normalized with the device specific range of values
1392  * and scaled to a value between 0 and 1.  The value of size can be used to
1393  * determine fat touch events.
1394  */
1395 float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
1396         size_t history_index);
1397 
1398 /**
1399  * Get the historical length of the major axis of an ellipse that describes the touch area
1400  * at the point of contact for the given pointer index that
1401  * occurred between this event and the previous motion event.
1402  */
1403 float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
1404         size_t history_index);
1405 
1406 /**
1407  * Get the historical length of the minor axis of an ellipse that describes the touch area
1408  * at the point of contact for the given pointer index that
1409  * occurred between this event and the previous motion event.
1410  */
1411 float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
1412         size_t history_index);
1413 
1414 /**
1415  * Get the historical length of the major axis of an ellipse that describes the size
1416  * of the approaching tool for the given pointer index that
1417  * occurred between this event and the previous motion event.
1418  * The tool area represents the estimated size of the finger or pen that is
1419  * touching the device independent of its actual touch area at the point of contact.
1420  */
1421 float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
1422         size_t history_index);
1423 
1424 /**
1425  * Get the historical length of the minor axis of an ellipse that describes the size
1426  * of the approaching tool for the given pointer index that
1427  * occurred between this event and the previous motion event.
1428  * The tool area represents the estimated size of the finger or pen that is
1429  * touching the device independent of its actual touch area at the point of contact.
1430  */
1431 float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
1432         size_t history_index);
1433 
1434 /**
1435  * Get the historical orientation of the touch area and tool area in radians clockwise from
1436  * vertical for the given pointer index that
1437  * occurred between this event and the previous motion event.
1438  * An angle of 0 degrees indicates that the major axis of contact is oriented
1439  * upwards, is perfectly circular or is of unknown orientation.  A positive angle
1440  * indicates that the major axis of contact is oriented to the right.  A negative angle
1441  * indicates that the major axis of contact is oriented to the left.
1442  * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
1443  * (finger pointing fully right).
1444  */
1445 float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
1446         size_t history_index);
1447 
1448 /**
1449  * Get the historical value of the request axis for the given pointer index
1450  * that occurred between this event and the previous motion event.
1451  */
1452 float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
1453         int32_t axis, size_t pointer_index, size_t history_index);
1454 
1455 /**
1456  * Get the action button for the motion event. Returns a valid action button when the
1457  * event is associated with a button press or button release action. For other actions
1458  * the return value is undefined.
1459  *
1460  * @see #AMOTION_EVENT_BUTTON_PRIMARY
1461  * @see #AMOTION_EVENT_BUTTON_SECONDARY
1462  * @see #AMOTION_EVENT_BUTTON_TERTIARY
1463  * @see #AMOTION_EVENT_BUTTON_BACK
1464  * @see #AMOTION_EVENT_BUTTON_FORWARD
1465  * @see #AMOTION_EVENT_BUTTON_STYLUS_PRIMARY
1466  * @see #AMOTION_EVENT_BUTTON_STYLUS_SECONDARY
1467  */
1468 int32_t AMotionEvent_getActionButton(const AInputEvent* motion_event)
1469         __INTRODUCED_IN(__ANDROID_API_T__);
1470 
1471 /**
1472  * Returns the classification for the current gesture.
1473  * The classification may change as more events become available for the same gesture.
1474  *
1475  * @see #AMOTION_EVENT_CLASSIFICATION_NONE
1476  * @see #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE
1477  * @see #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS
1478 */
1479 int32_t AMotionEvent_getClassification(const AInputEvent* motion_event)
1480         __INTRODUCED_IN(__ANDROID_API_T__);
1481 
1482 /**
1483  * Creates a native {@link AInputEvent}* object that is a copy of the specified Java
1484  * android.view.MotionEvent. The result may be used with generic and MotionEvent-specific
1485  * AInputEvent_* functions. The object returned by this function must be disposed using
1486  * {@link AInputEvent_release()}.
1487  *
1488  * Available since API level 31.
1489  */
1490 const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) __INTRODUCED_IN(31);
1491 
1492 /**
1493  * Creates a java android.view.InputEvent object that is a copy of the specified native
1494  * {@link AInputEvent}.
1495  *
1496  * Specified {@link AInputEvent} is require to be a valid {@link MotionEvent} or {@link KeyEvent}
1497  * object.
1498  *
1499  *  Available since API level 35.
1500  */
1501 jobject AInputEvent_toJava(JNIEnv* env, const AInputEvent* aInputEvent) __INTRODUCED_IN(35);
1502 
1503 struct AInputQueue;
1504 /**
1505  * Input queue
1506  *
1507  * An input queue is the facility through which you retrieve input
1508  * events.
1509  */
1510 typedef struct AInputQueue AInputQueue;
1511 
1512 /**
1513  * Add this input queue to a looper for processing.  See
1514  * {@link ALooper_addFd()} for information on the ident, callback, and data params.
1515  */
1516 void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
1517         int ident, ALooper_callbackFunc callback, void* data);
1518 
1519 /**
1520  * Remove the input queue from the looper it is currently attached to.
1521  */
1522 void AInputQueue_detachLooper(AInputQueue* queue);
1523 
1524 /**
1525  * Returns true if there are one or more events available in the
1526  * input queue.  Returns 1 if the queue has events; 0 if
1527  * it does not have events; and a negative value if there is an error.
1528  */
1529 int32_t AInputQueue_hasEvents(AInputQueue* queue);
1530 
1531 /**
1532  * Returns the next available event from the queue.  Returns a negative
1533  * value if no events are available or an error has occurred.
1534  */
1535 int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
1536 
1537 /**
1538  * Sends the key for standard pre-dispatching -- that is, possibly deliver
1539  * it to the current IME to be consumed before the app.  Returns 0 if it
1540  * was not pre-dispatched, meaning you can process it right now.  If non-zero
1541  * is returned, you must abandon the current event processing and allow the
1542  * event to appear again in the event queue (if it does not get consumed during
1543  * pre-dispatching).
1544  */
1545 int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
1546 
1547 /**
1548  * Report that dispatching has finished with the given event.
1549  * This must be called after receiving an event with {@link AInputQueue_getEvent()}.
1550  */
1551 void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
1552 
1553 /**
1554  * Returns the {@link AInputQueue}* object associated with the supplied Java InputQueue
1555  * object. The returned native object holds a weak reference to the Java object,
1556  * and is only valid as long as the Java object has not yet been disposed. You
1557  * should ensure that there is a strong reference to the Java object and that it
1558  * has not been disposed before using the returned object.
1559  *
1560  * Available since API level 33.
1561  */
1562 AInputQueue* AInputQueue_fromJava(JNIEnv* env, jobject inputQueue) __INTRODUCED_IN(33);
1563 
1564 #ifdef __cplusplus
1565 }
1566 #endif
1567 
1568 #endif // _ANDROID_INPUT_H
1569 
1570 /** @} */
1571