blob: ee98d7aee99af3e8e498b000065fc5815e198d84 [file] [log] [blame]
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001/*
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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070017/**
18 * @addtogroup Input
19 * @{
20 */
21
22/**
23 * @file input.h
24 */
25
Mathias Agopiane1c61d32012-03-23 14:19:36 -070026#ifndef _ANDROID_INPUT_H
27#define _ANDROID_INPUT_H
28
Dan Albert494ed552016-09-23 15:57:45 -070029#include <sys/cdefs.h>
30
Mathias Agopiane1c61d32012-03-23 14:19:36 -070031/******************************************************************
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>
Ady Abraham2a6c1862022-07-28 22:54:19 +000058
Chris Ye1aaa2122020-04-07 19:38:15 -070059#include <jni.h>
Mathias Agopiane1c61d32012-03-23 14:19:36 -070060
Prashanth Swaminathan8b75d502023-07-11 10:48:18 -070061// This file may also be built on glibc or on Windows/MacOS libc's, so no-op
62// definitions are provided.
Elliott Hughes9db409b2018-06-18 12:28:46 -070063#if !defined(__INTRODUCED_IN)
64#define __INTRODUCED_IN(__api_level) /* nothing */
65#endif
66
Mathias Agopiane1c61d32012-03-23 14:19:36 -070067#ifdef __cplusplus
68extern "C" {
69#endif
70
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070071/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070072 * Key states (may be returned by queries about the current state of a
73 * particular key code, scan code or switch).
74 */
75enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070076 /** The key state is unknown or the requested key itself is not supported. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070077 AKEY_STATE_UNKNOWN = -1,
78
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070079 /** The key is up. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070080 AKEY_STATE_UP = 0,
81
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070082 /** The key is down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070083 AKEY_STATE_DOWN = 1,
84
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070085 /** The key is down but is a virtual key press that is being emulated by the system. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070086 AKEY_STATE_VIRTUAL = 2
87};
88
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070089/**
Siarhei Vishniakou61fafdd2018-04-13 11:00:58 -050090 * Meta key / modifier state.
Mathias Agopiane1c61d32012-03-23 14:19:36 -070091 */
92enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070093 /** No meta keys are pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070094 AMETA_NONE = 0,
95
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070096 /** This mask is used to check whether one of the ALT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070097 AMETA_ALT_ON = 0x02,
98
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070099 /** This mask is used to check whether the left ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700100 AMETA_ALT_LEFT_ON = 0x10,
101
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700102 /** This mask is used to check whether the right ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700103 AMETA_ALT_RIGHT_ON = 0x20,
104
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700105 /** This mask is used to check whether one of the SHIFT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700106 AMETA_SHIFT_ON = 0x01,
107
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700108 /** This mask is used to check whether the left SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700109 AMETA_SHIFT_LEFT_ON = 0x40,
110
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700111 /** This mask is used to check whether the right SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700112 AMETA_SHIFT_RIGHT_ON = 0x80,
113
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700114 /** This mask is used to check whether the SYM meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700115 AMETA_SYM_ON = 0x04,
116
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700117 /** This mask is used to check whether the FUNCTION meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700118 AMETA_FUNCTION_ON = 0x08,
119
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700120 /** This mask is used to check whether one of the CTRL meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700121 AMETA_CTRL_ON = 0x1000,
122
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700123 /** This mask is used to check whether the left CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700124 AMETA_CTRL_LEFT_ON = 0x2000,
125
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700126 /** This mask is used to check whether the right CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700127 AMETA_CTRL_RIGHT_ON = 0x4000,
128
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700129 /** This mask is used to check whether one of the META meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700130 AMETA_META_ON = 0x10000,
131
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700132 /** This mask is used to check whether the left META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700133 AMETA_META_LEFT_ON = 0x20000,
134
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700135 /** This mask is used to check whether the right META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700136 AMETA_META_RIGHT_ON = 0x40000,
137
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700138 /** This mask is used to check whether the CAPS LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700139 AMETA_CAPS_LOCK_ON = 0x100000,
140
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700141 /** This mask is used to check whether the NUM LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700142 AMETA_NUM_LOCK_ON = 0x200000,
143
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700144 /** This mask is used to check whether the SCROLL LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700145 AMETA_SCROLL_LOCK_ON = 0x400000,
146};
147
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700148struct AInputEvent;
149/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700150 * Input events.
151 *
152 * Input events are opaque structures. Use the provided accessors functions to
153 * read their properties.
154 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700155typedef struct AInputEvent AInputEvent;
156
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700157/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700158 * Input event types.
159 */
160enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700161 /** Indicates that the input event is a key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700162 AINPUT_EVENT_TYPE_KEY = 1,
163
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700164 /** Indicates that the input event is a motion event. */
Siarhei Vishniakou7feb2ea2019-11-25 15:11:23 -0800165 AINPUT_EVENT_TYPE_MOTION = 2,
166
167 /** Focus event */
168 AINPUT_EVENT_TYPE_FOCUS = 3,
Prabir Pradhan3f37b7b2020-11-10 16:50:18 -0800169
170 /** Capture event */
171 AINPUT_EVENT_TYPE_CAPTURE = 4,
arthurhung7632c332020-12-30 16:58:01 +0800172
173 /** Drag event */
174 AINPUT_EVENT_TYPE_DRAG = 5,
Antonio Kantek7cdf8ef2021-07-13 18:04:53 -0700175
176 /** TouchMode event */
177 AINPUT_EVENT_TYPE_TOUCH_MODE = 6,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700178};
179
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700180/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700181 * Key event actions.
182 */
183enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700184 /** The key has been pressed down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700185 AKEY_EVENT_ACTION_DOWN = 0,
186
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700187 /** The key has been released. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700188 AKEY_EVENT_ACTION_UP = 1,
189
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700190 /**
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.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700195 */
196 AKEY_EVENT_ACTION_MULTIPLE = 2
197};
198
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700199/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700200 * Key event flags.
201 */
202enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700203 /** This mask is set if the device woke because of this key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700204 AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
205
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700206 /** This mask is set if the key event was generated by a software keyboard. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700207 AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
208
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700209 /** This mask is set if we don't want the key event to cause us to leave touch mode. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700210 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
211
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700212 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700218 AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
219
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700220 /**
221 * This mask is used for compatibility, to identify enter keys that are
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700222 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700225 * receiving them.
226 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700227 AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
228
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700229 /**
230 * When associated with up key events, this indicates that the key press
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700231 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700237 * expired.
238 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700239 AKEY_EVENT_FLAG_CANCELED = 0x20,
240
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700241 /**
242 * This key event was generated by a virtual (on-screen) hard key area.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700243 * Typically this is an area of the touchscreen, outside of the regular
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700244 * display, dedicated to "hardware" buttons.
245 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700246 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
247
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700248 /**
249 * This flag is set for the first key repeat that occurs after the
250 * long press timeout.
251 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700252 AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
253
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700254 /**
Greg Patakye153adc2023-04-04 23:34:52 +0000255 * Set when a key event has #AKEY_EVENT_FLAG_CANCELED set because a long
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700256 * press action was executed while it was down.
257 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700258 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
259
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700260 /**
Greg Patakye153adc2023-04-04 23:34:52 +0000261 * Set for #AKEY_EVENT_ACTION_UP when this event's key code is still being
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700262 * tracked from its initial down. That is, somebody requested that tracking
263 * started on the key down and a long press has not caused
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700264 * the tracking to be canceled.
265 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700266 AKEY_EVENT_FLAG_TRACKING = 0x200,
267
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700268 /**
269 * Set when a key event has been synthesized to implement default behavior
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700270 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700274 * keys when numlock is off).
275 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700276 AKEY_EVENT_FLAG_FALLBACK = 0x400,
277};
278
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700279/**
280 * Bit shift for the action bits holding the pointer index as
Greg Patakye153adc2023-04-04 23:34:52 +0000281 * defined by #AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700282 */
283#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
284
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700285/** Motion event actions */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700286enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700287 /** Bit mask of the parts of the action code that are the action itself. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700288 AMOTION_EVENT_ACTION_MASK = 0xff,
289
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700290 /**
291 * Bits in the action code that represent a pointer index, used with
Greg Patakye153adc2023-04-04 23:34:52 +0000292 * #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
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700294 * index where the data for the pointer going up or down can be found.
295 */
296 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
297
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700298 /** A pressed gesture has started, the motion contains the initial starting location. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700299 AMOTION_EVENT_ACTION_DOWN = 0,
300
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700301 /**
302 * A pressed gesture has finished, the motion contains the final release location
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700303 * as well as any intermediate points since the last down or move event.
304 */
305 AMOTION_EVENT_ACTION_UP = 1,
306
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700307 /**
Greg Patakye153adc2023-04-04 23:34:52 +0000308 * 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
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700310 * any intermediate points since the last down or move event.
311 */
312 AMOTION_EVENT_ACTION_MOVE = 2,
313
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700314 /**
315 * The current gesture has been aborted.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700316 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700321 /**
322 * A movement has happened outside of the normal bounds of the UI element.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700323 * This does not provide a full gesture, but only the initial location of the movement/touch.
324 */
325 AMOTION_EVENT_ACTION_OUTSIDE = 4,
326
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700327 /**
328 * A non-primary pointer has gone down.
Greg Patakye153adc2023-04-04 23:34:52 +0000329 * The bits in #AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700330 */
331 AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
332
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700333 /**
334 * A non-primary pointer has gone up.
Greg Patakye153adc2023-04-04 23:34:52 +0000335 * The bits in #AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700336 */
337 AMOTION_EVENT_ACTION_POINTER_UP = 6,
338
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700339 /**
Greg Patakye153adc2023-04-04 23:34:52 +0000340 * A change happened but the pointer is not down (unlike #AMOTION_EVENT_ACTION_MOVE).
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700341 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700346 /**
347 * The motion event contains relative vertical and/or horizontal scroll offsets.
Greg Patakye153adc2023-04-04 23:34:52 +0000348 * Use {@link AMotionEvent_getAxisValue} to retrieve the information from
349 * #AMOTION_EVENT_AXIS_VSCROLL and #AMOTION_EVENT_AXIS_HSCROLL.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700350 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700356 /** The pointer is not down but has entered the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700357 AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
358
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700359 /** The pointer is not down but has exited the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700360 AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
Michael Wright7b159c92015-05-14 14:48:03 +0100361
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,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700367};
368
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700369/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700370 * Motion event flags.
371 */
372enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700373 /**
374 * This flag indicates that the window that received this motion event is partly
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700375 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700386/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700387 * Motion event edge touch flags.
388 */
389enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700390 /** No edges intersected. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700391 AMOTION_EVENT_EDGE_FLAG_NONE = 0,
392
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700393 /** Flag indicating the motion event intersected the top edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700394 AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
395
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700396 /** Flag indicating the motion event intersected the bottom edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700397 AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
398
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700399 /** Flag indicating the motion event intersected the left edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700400 AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
401
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700402 /** Flag indicating the motion event intersected the right edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700403 AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
404};
405
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700406/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700407 * Constants that identify each individual axis of a motion event.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700408 * @anchor AMOTION_EVENT_AXIS
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700409 */
410enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700411 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700425 AMOTION_EVENT_AXIS_X = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700426 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700440 AMOTION_EVENT_AXIS_Y = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700441 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700453 AMOTION_EVENT_AXIS_PRESSURE = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700454 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700464 AMOTION_EVENT_AXIS_SIZE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700465 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700475 AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700476 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700488 AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700489 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700503 AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700504 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700518 AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700519 /**
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
Greg Patakye153adc2023-04-04 23:34:52 +0000534 * is pointing right. See also #AMOTION_EVENT_AXIS_TILT.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700535 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700536 AMOTION_EVENT_AXIS_ORIENTATION = 8,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700537 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700545 AMOTION_EVENT_AXIS_VSCROLL = 9,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700546 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700554 AMOTION_EVENT_AXIS_HSCROLL = 10,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700555 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700563 AMOTION_EVENT_AXIS_Z = 11,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700564 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700570 AMOTION_EVENT_AXIS_RX = 12,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700571 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700577 AMOTION_EVENT_AXIS_RY = 13,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700578 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700586 AMOTION_EVENT_AXIS_RZ = 14,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700587 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700593 AMOTION_EVENT_AXIS_HAT_X = 15,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700594 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700600 AMOTION_EVENT_AXIS_HAT_Y = 16,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700601 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700607 AMOTION_EVENT_AXIS_LTRIGGER = 17,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700608 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700614 AMOTION_EVENT_AXIS_RTRIGGER = 18,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700615 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700621 AMOTION_EVENT_AXIS_THROTTLE = 19,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700622 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700628 AMOTION_EVENT_AXIS_RUDDER = 20,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700629 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700635 AMOTION_EVENT_AXIS_WHEEL = 21,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700636 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700643 AMOTION_EVENT_AXIS_GAS = 22,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700644 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700650 AMOTION_EVENT_AXIS_BRAKE = 23,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700651 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700658 AMOTION_EVENT_AXIS_DISTANCE = 24,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700659 /**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700667 AMOTION_EVENT_AXIS_TILT = 25,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700668 /**
Prashant Malani1941ff52015-08-11 18:29:28 -0700669 * 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 /**
Jun Mukaifa1706a2015-12-03 01:14:46 -0800676 * 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 *
Greg Patakye153adc2023-04-04 23:34:52 +0000687 * Same as #AMOTION_EVENT_AXIS_RELATIVE_X, but for y position.
Jun Mukaifa1706a2015-12-03 01:14:46 -0800688 */
689 AMOTION_EVENT_AXIS_RELATIVE_Y = 28,
690 /**
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700691 * Axis constant: Generic 1 axis of a motion event.
692 * The interpretation of a generic axis is device-specific.
693 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700694 AMOTION_EVENT_AXIS_GENERIC_1 = 32,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700695 /**
696 * Axis constant: Generic 2 axis of a motion event.
697 * The interpretation of a generic axis is device-specific.
698 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700699 AMOTION_EVENT_AXIS_GENERIC_2 = 33,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700700 /**
701 * Axis constant: Generic 3 axis of a motion event.
702 * The interpretation of a generic axis is device-specific.
703 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700704 AMOTION_EVENT_AXIS_GENERIC_3 = 34,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700705 /**
706 * Axis constant: Generic 4 axis of a motion event.
707 * The interpretation of a generic axis is device-specific.
708 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700709 AMOTION_EVENT_AXIS_GENERIC_4 = 35,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700710 /**
711 * Axis constant: Generic 5 axis of a motion event.
712 * The interpretation of a generic axis is device-specific.
713 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700714 AMOTION_EVENT_AXIS_GENERIC_5 = 36,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700715 /**
716 * Axis constant: Generic 6 axis of a motion event.
717 * The interpretation of a generic axis is device-specific.
718 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700719 AMOTION_EVENT_AXIS_GENERIC_6 = 37,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700720 /**
721 * Axis constant: Generic 7 axis of a motion event.
722 * The interpretation of a generic axis is device-specific.
723 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700724 AMOTION_EVENT_AXIS_GENERIC_7 = 38,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700725 /**
726 * Axis constant: Generic 8 axis of a motion event.
727 * The interpretation of a generic axis is device-specific.
728 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700729 AMOTION_EVENT_AXIS_GENERIC_8 = 39,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700730 /**
731 * Axis constant: Generic 9 axis of a motion event.
732 * The interpretation of a generic axis is device-specific.
733 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700734 AMOTION_EVENT_AXIS_GENERIC_9 = 40,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700735 /**
736 * Axis constant: Generic 10 axis of a motion event.
737 * The interpretation of a generic axis is device-specific.
738 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700739 AMOTION_EVENT_AXIS_GENERIC_10 = 41,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700740 /**
741 * Axis constant: Generic 11 axis of a motion event.
742 * The interpretation of a generic axis is device-specific.
743 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700744 AMOTION_EVENT_AXIS_GENERIC_11 = 42,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700745 /**
746 * Axis constant: Generic 12 axis of a motion event.
747 * The interpretation of a generic axis is device-specific.
748 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700749 AMOTION_EVENT_AXIS_GENERIC_12 = 43,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700750 /**
751 * Axis constant: Generic 13 axis of a motion event.
752 * The interpretation of a generic axis is device-specific.
753 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700754 AMOTION_EVENT_AXIS_GENERIC_13 = 44,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700755 /**
756 * Axis constant: Generic 14 axis of a motion event.
757 * The interpretation of a generic axis is device-specific.
758 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700759 AMOTION_EVENT_AXIS_GENERIC_14 = 45,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700760 /**
761 * Axis constant: Generic 15 axis of a motion event.
762 * The interpretation of a generic axis is device-specific.
763 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700764 AMOTION_EVENT_AXIS_GENERIC_15 = 46,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700765 /**
766 * Axis constant: Generic 16 axis of a motion event.
767 * The interpretation of a generic axis is device-specific.
768 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700769 AMOTION_EVENT_AXIS_GENERIC_16 = 47,
Harry Cutts39b7ca22022-10-05 15:55:48 +0000770 /**
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.
Harry Cuttsb1e83552022-12-20 11:02:26 +0000777 *
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.
Harry Cutts8743f182023-05-17 12:03:49 +0000780 *
781 * This axis is only set on the first pointer in a motion event.
Harry Cutts39b7ca22022-10-05 15:55:48 +0000782 */
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,
Harry Cuttsef400b22022-12-16 21:26:24 +0000790 /**
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.
Harry Cuttsb1e83552022-12-20 11:02:26 +0000795 *
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.
Harry Cutts8743f182023-05-17 12:03:49 +0000798 *
799 * This axis is only set on the first pointer in a motion event.
Harry Cuttsef400b22022-12-16 21:26:24 +0000800 */
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,
Harry Cuttsb1e83552022-12-20 11:02:26 +0000808 /**
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.
Harry Cutts8743f182023-05-17 12:03:49 +0000818 *
819 * This axis is only set on the first pointer in a motion event.
Harry Cuttsb1e83552022-12-20 11:02:26 +0000820 */
821 AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR = 52,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700822
Yeabkal Wubshiteee671e2022-10-06 15:13:34 -0700823 /**
Harry Cutts8743f182023-05-17 12:03:49 +0000824 * 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 /**
Yeabkal Wubshiteee671e2022-10-06 15:13:34 -0700835 * 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 */
Harry Cutts8743f182023-05-17 12:03:49 +0000840 AMOTION_EVENT_MAXIMUM_VALID_AXIS_VALUE = AMOTION_EVENT_AXIS_GESTURE_SWIPE_FINGER_COUNT,
Yeabkal Wubshiteee671e2022-10-06 15:13:34 -0700841
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700842 // 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.
Yeabkal Wubshiteee671e2022-10-06 15:13:34 -0700844 // Update AMOTION_EVENT_MAXIMUM_VALID_AXIS_VALUE accordingly as well.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700845};
846
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700847/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700848 * 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 */
851enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700852 /** primary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700853 AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700854 /** secondary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700855 AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700856 /** tertiary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700857 AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700858 /** back */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700859 AMOTION_EVENT_BUTTON_BACK = 1 << 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700860 /** forward */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700861 AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
Michael Wright7b159c92015-05-14 14:48:03 +0100862 AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
863 AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700864};
865
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700866/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700867 * Constants that identify tool types.
868 * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
869 */
870enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700871 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700872 AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700873 /** finger */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700874 AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700875 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700876 AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700877 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700878 AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700879 /** eraser */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700880 AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
Arthur Hung421eb1c2020-01-16 00:09:42 +0800881 /** palm */
882 AMOTION_EVENT_TOOL_TYPE_PALM = 5,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700883};
884
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700885/**
Vaibhav8576dd72022-02-11 18:19:06 +0530886 * Constants that identify different gesture classification types.
887 */
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +0000888enum AMotionClassification : uint32_t {
Vaibhav8576dd72022-02-11 18:19:06 +0530889 /**
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 *
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +0000898 * The user's intent with respect to the current event stream is not yet determined. Events
Greg Patakye153adc2023-04-04 23:34:52 +0000899 * starting in #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE will eventually resolve into
900 * either #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS or #AMOTION_EVENT_CLASSIFICATION_NONE.
Vaibhav8576dd72022-02-11 18:19:06 +0530901 * 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,
Harry Cutts2800fb02022-09-15 13:49:23 +0000912 /**
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,
Harry Cuttsc5748d12022-12-02 17:30:18 +0000918 /**
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,
Harry Cuttsb1e83552022-12-20 11:02:26 +0000926 /**
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,
Vaibhav8576dd72022-02-11 18:19:06 +0530933};
934
935/**
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700936 * Input source masks.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700937 *
938 * Refer to the documentation on android.view.InputDevice for more details about input sources
939 * and their correct interpretation.
940 */
941enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700942 /** mask */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700943 AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
944
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700945 /** none */
Michael Wrightaadaca72013-03-11 14:20:14 -0700946 AINPUT_SOURCE_CLASS_NONE = 0x00000000,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700947 /** button */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700948 AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700949 /** pointer */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700950 AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700951 /** navigation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700952 AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700953 /** position */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700954 AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700955 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700956 AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
957};
958
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700959/**
960 * Input sources.
961 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700962enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700963 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700964 AINPUT_SOURCE_UNKNOWN = 0x00000000,
965
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700966 /** keyboard */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700967 AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700968 /** dpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700969 AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700970 /** gamepad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700971 AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700972 /** touchscreen */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700973 AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700974 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700975 AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700976 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700977 AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
Michael Wright7d3ad692015-06-23 19:04:31 +0100978 /** bluetooth stylus */
Michael Wright2f78b682015-06-12 15:25:08 +0100979 AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700980 /** trackball */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700981 AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Vladislav Kaznacheev78f97b32016-12-15 18:14:58 -0800982 /** mouse relative */
983 AINPUT_SOURCE_MOUSE_RELATIVE = 0x00020000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700984 /** touchpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700985 AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700986 /** navigation */
Michael Wrightaadaca72013-03-11 14:20:14 -0700987 AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700988 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700989 AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
Chris Ye02303442021-01-26 13:21:01 -0800990 /** HDMI */
991 AINPUT_SOURCE_HDMI = 0x02000000 | AINPUT_SOURCE_CLASS_BUTTON,
Chris Yef59a2f42020-10-16 12:55:26 -0700992 /** sensor */
Chris Ye3fdbfef2021-01-06 18:45:18 -0800993 AINPUT_SOURCE_SENSOR = 0x04000000 | AINPUT_SOURCE_CLASS_NONE,
Prashant Malani1941ff52015-08-11 18:29:28 -0700994 /** rotary encoder */
995 AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700996
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700997 /** any */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700998 AINPUT_SOURCE_ANY = 0xffffff00,
999};
1000
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001001/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001002 * Keyboard types.
1003 *
1004 * Refer to the documentation on android.view.InputDevice for more details.
1005 */
1006enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001007 /** none */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001008 AINPUT_KEYBOARD_TYPE_NONE = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001009 /** non alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001010 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001011 /** alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001012 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
1013};
1014
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001015/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001016 * 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 *
Greg Patakye153adc2023-04-04 23:34:52 +00001022 * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*}
1023 * constants instead.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001024 */
1025enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001026 /** x */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001027 AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001028 /** y */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001029 AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001030 /** pressure */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001031 AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001032 /** size */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001033 AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001034 /** touch major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001035 AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001036 /** touch minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001037 AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001038 /** tool major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001039 AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001040 /** tool minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001041 AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001042 /** orientation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001043 AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001044};
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001045
1046
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001047/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001048 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001056/** Get the input event type. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001057int32_t AInputEvent_getType(const AInputEvent* event);
1058
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001059/** Get the id for the device that an input event came from.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001060 *
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 */
1069int32_t AInputEvent_getDeviceId(const AInputEvent* event);
1070
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001071/** Get the input event source. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001072int32_t AInputEvent_getSource(const AInputEvent* event);
1073
Chris Ye1aaa2122020-04-07 19:38:15 -07001074/**
1075 * Releases interface objects created by {@link AKeyEvent_fromJava()}
1076 * and {@link AMotionEvent_fromJava()}.
Greg Patakye153adc2023-04-04 23:34:52 +00001077 * 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.
Elliott Hughesdbfde642021-09-14 10:31:47 -07001079 *
1080 * Available since API level 31.
Chris Ye1aaa2122020-04-07 19:38:15 -07001081 */
Elliott Hughesdbfde642021-09-14 10:31:47 -07001082void AInputEvent_release(const AInputEvent* event) __INTRODUCED_IN(31);
Chris Ye1aaa2122020-04-07 19:38:15 -07001083
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001084/*** Accessors for key events only. ***/
1085
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001086/** Get the key event action. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001087int32_t AKeyEvent_getAction(const AInputEvent* key_event);
1088
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001089/** Get the key event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001090int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
1091
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001092/**
1093 * Get the key code of the key event.
1094 * This is the physical key that was pressed, not the Unicode character.
1095 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001096int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
1097
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001098/**
1099 * Get the hardware key id of this key event.
1100 * These values are not reliable and vary from device to device.
1101 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001102int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
1103
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001104/** Get the meta key state. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001105int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
1106
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001107/**
1108 * Get the repeat count of the event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001109 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001111 * multiple key events, this is the number of down/up pairs that have occurred.
1112 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001113int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
1114
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001115/**
1116 * Get the time of the most recent key down event, in the
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001117 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001120 * pressed key, which may not be the same physical key of this event.
1121 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001122int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
1123
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001124/**
1125 * Get the time this event occurred, in the
1126 * java.lang.System.nanoTime() time base.
1127 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001128int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
1129
Chris Ye1aaa2122020-04-07 19:38:15 -07001130/**
Greg Patakye153adc2023-04-04 23:34:52 +00001131 * 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()}.
Elliott Hughesdbfde642021-09-14 10:31:47 -07001135 *
1136 * Available since API level 31.
Chris Ye1aaa2122020-04-07 19:38:15 -07001137 */
Elliott Hughesdbfde642021-09-14 10:31:47 -07001138const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent) __INTRODUCED_IN(31);
Chris Ye1aaa2122020-04-07 19:38:15 -07001139
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001140/*** Accessors for motion events only. ***/
1141
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001142/** Get the combined motion event action code and pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001143int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
1144
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001145/** Get the motion event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001146int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
1147
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001148/**
1149 * Get the state of any meta / modifier keys that were in effect when the
1150 * event was generated.
1151 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001152int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
1153
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001154/** Get the button state of all buttons that are pressed. */
Elliott Hughes3d70e532019-10-29 08:59:39 -07001155int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001156
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001157/**
1158 * Get a bitfield indicating which edges, if any, were touched by this motion event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001159 * For touch events, clients can use this to determine if the user's finger was
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001160 * touching the edge of the display.
1161 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001162int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
1163
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001164/**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001168int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
1169
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001170/**
1171 * Get the time when this specific event was generated,
1172 * in the java.lang.System.nanoTime() time base.
1173 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001174int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
1175
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001176/**
1177 * Get the X coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001178 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001180 * and views.
1181 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001182float AMotionEvent_getXOffset(const AInputEvent* motion_event);
1183
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001184/**
1185 * Get the Y coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001186 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001188 * and views.
1189 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001190float AMotionEvent_getYOffset(const AInputEvent* motion_event);
1191
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001192/**
1193 * Get the precision of the X coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001194 * You can multiply this number with an X coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001195 * actual hardware value of the X coordinate.
1196 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001197float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
1198
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001199/**
1200 * Get the precision of the Y coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001201 * You can multiply this number with a Y coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001202 * actual hardware value of the Y coordinate.
1203 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001204float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
1205
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001206/**
1207 * Get the number of pointers of data contained in this event.
1208 * Always >= 1.
1209 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001210size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
1211
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001212/**
1213 * Get the pointer identifier associated with a particular pointer
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001214 * data index in this event. The identifier tells you the actual pointer
1215 * number associated with the data, accounting for individual pointers
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001216 * going up and down since the start of the current gesture.
1217 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001218int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
1219
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001220/**
1221 * Get the tool type of a pointer for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001222 * The tool type indicates the type of tool used to make contact such as a
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001223 * finger or stylus, if known.
1224 */
Elliott Hughes3d70e532019-10-29 08:59:39 -07001225int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001226
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001227/**
1228 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001229 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001231 * and views.
1232 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001233float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
1234
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001235/**
1236 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001237 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001239 * and views.
1240 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001241float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
1242
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001243/**
1244 * Get the current X coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001245 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001246 * that are sub-pixel precise.
1247 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001248float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
1249
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001250/**
1251 * Get the current Y coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001252 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001253 * that are sub-pixel precise.
1254 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001255float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
1256
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001257/**
1258 * Get the current pressure of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001259 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001261 * the input device.
1262 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001263float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
1264
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001265/**
1266 * Get the current scaled value of the approximate size for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001267 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001271 * determine fat touch events.
1272 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001273float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
1274
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001275/**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001279float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
1280
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001281/**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001285float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
1286
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001287/**
1288 * Get the current length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001289 * of the approaching tool for the given pointer index.
1290 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001291 * touching the device independent of its actual touch area at the point of contact.
1292 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001293float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
1294
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001295/**
1296 * Get the current length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001297 * of the approaching tool for the given pointer index.
1298 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001299 * touching the device independent of its actual touch area at the point of contact.
1300 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001301float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
1302
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001303/**
1304 * Get the current orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001305 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001311 * (finger pointing fully right).
1312 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001313float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
1314
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001315/** Get the value of the request axis for the given pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001316float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001317 int32_t axis, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001318
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001319/**
1320 * Get the number of historical points in this event. These are movements that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001321 * have occurred between this event and the previous event. This only applies
Greg Patakye153adc2023-04-04 23:34:52 +00001322 * to #AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001323 * Historical samples are indexed from oldest to newest.
1324 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001325size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
1326
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001327/**
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 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001331int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001332 size_t history_index);
1333
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001334/**
1335 * Get the historical raw X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001336 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001341 * that are sub-pixel precise.
1342 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001343float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
1344 size_t history_index);
1345
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001346/**
1347 * Get the historical raw Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001348 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001353 * that are sub-pixel precise.
1354 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001355float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
1356 size_t history_index);
1357
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001358/**
1359 * Get the historical X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001360 * occurred between this event and the previous motion event.
1361 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001362 * that are sub-pixel precise.
1363 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001364float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001365 size_t history_index);
1366
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001367/**
1368 * Get the historical Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001369 * occurred between this event and the previous motion event.
1370 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001371 * that are sub-pixel precise.
1372 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001373float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001374 size_t history_index);
1375
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001376/**
1377 * Get the historical pressure of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001378 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001381 * the input device.
1382 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001383float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001384 size_t history_index);
1385
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001386/**
1387 * Get the current scaled value of the approximate size for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001388 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001393 * determine fat touch events.
1394 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001395float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001396 size_t history_index);
1397
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001398/**
1399 * Get the historical length of the major axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001400 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001401 * occurred between this event and the previous motion event.
1402 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001403float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
1404 size_t history_index);
1405
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001406/**
1407 * Get the historical length of the minor axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001408 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001409 * occurred between this event and the previous motion event.
1410 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001411float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
1412 size_t history_index);
1413
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001414/**
1415 * Get the historical length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001416 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001419 * touching the device independent of its actual touch area at the point of contact.
1420 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001421float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
1422 size_t history_index);
1423
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001424/**
1425 * Get the historical length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001426 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001429 * touching the device independent of its actual touch area at the point of contact.
1430 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001431float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
1432 size_t history_index);
1433
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001434/**
1435 * Get the historical orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001436 * 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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001443 * (finger pointing fully right).
1444 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001445float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
1446 size_t history_index);
1447
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001448/**
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 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001452float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001453 int32_t axis, size_t pointer_index, size_t history_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001454
Chris Ye1aaa2122020-04-07 19:38:15 -07001455/**
Vaibhav8576dd72022-02-11 18:19:06 +05301456 * 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.
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +00001459 *
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
Vaibhav8576dd72022-02-11 18:19:06 +05301467 */
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +00001468int32_t AMotionEvent_getActionButton(const AInputEvent* motion_event)
1469 __INTRODUCED_IN(__ANDROID_API_T__);
Vaibhav8576dd72022-02-11 18:19:06 +05301470
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*/
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +00001479int32_t AMotionEvent_getClassification(const AInputEvent* motion_event)
1480 __INTRODUCED_IN(__ANDROID_API_T__);
Vaibhav8576dd72022-02-11 18:19:06 +05301481
1482/**
Greg Patakye153adc2023-04-04 23:34:52 +00001483 * Creates a native {@link AInputEvent}* object that is a copy of the specified Java
Siarhei Vishniakoua53d8652020-08-13 23:59:50 -05001484 * 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()}.
Elliott Hughesdbfde642021-09-14 10:31:47 -07001487 *
1488 * Available since API level 31.
Chris Ye1aaa2122020-04-07 19:38:15 -07001489 */
Elliott Hughesdbfde642021-09-14 10:31:47 -07001490const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) __INTRODUCED_IN(31);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001491
Arpit Singhf8680e62024-01-17 15:30:16 +00001492/**
1493 * Creates a java android.view.InputEvent object that is a copy of the specified native
Arpit Singhc91c6442024-02-16 11:42:38 +00001494 * {@link AInputEvent}.
1495 *
1496 * Specified {@link AInputEvent} is require to be a valid {@link MotionEvent} or {@link KeyEvent}
1497 * object.
Arpit Singhf8680e62024-01-17 15:30:16 +00001498 *
1499 * Available since API level 35.
1500 */
1501jobject AInputEvent_toJava(JNIEnv* env, const AInputEvent* aInputEvent) __INTRODUCED_IN(35);
1502
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001503struct AInputQueue;
1504/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001505 * Input queue
1506 *
1507 * An input queue is the facility through which you retrieve input
1508 * events.
1509 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001510typedef struct AInputQueue AInputQueue;
1511
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001512/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001513 * Add this input queue to a looper for processing. See
Greg Patakye153adc2023-04-04 23:34:52 +00001514 * {@link ALooper_addFd()} for information on the ident, callback, and data params.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001515 */
1516void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
1517 int ident, ALooper_callbackFunc callback, void* data);
1518
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001519/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001520 * Remove the input queue from the looper it is currently attached to.
1521 */
1522void AInputQueue_detachLooper(AInputQueue* queue);
1523
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001524/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001525 * 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 */
1529int32_t AInputQueue_hasEvents(AInputQueue* queue);
1530
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001531/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001532 * Returns the next available event from the queue. Returns a negative
1533 * value if no events are available or an error has occurred.
1534 */
1535int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
1536
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001537/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001538 * 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 */
1545int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
1546
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001547/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001548 * Report that dispatching has finished with the given event.
Greg Patakye153adc2023-04-04 23:34:52 +00001549 * This must be called after receiving an event with {@link AInputQueue_getEvent()}.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001550 */
1551void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
1552
Jim Blacklera64c2722021-09-01 16:39:16 +01001553/**
Greg Patakye153adc2023-04-04 23:34:52 +00001554 * Returns the {@link AInputQueue}* object associated with the supplied Java InputQueue
Prabir Pradhan9d439742021-12-16 03:32:30 -08001555 * 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.
Jim Blacklera64c2722021-09-01 16:39:16 +01001559 *
1560 * Available since API level 33.
1561 */
Prabir Pradhanb1e1e392021-12-16 03:28:20 -08001562AInputQueue* AInputQueue_fromJava(JNIEnv* env, jobject inputQueue) __INTRODUCED_IN(33);
Jim Blacklera64c2722021-09-01 16:39:16 +01001563
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001564#ifdef __cplusplus
1565}
1566#endif
1567
1568#endif // _ANDROID_INPUT_H
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001569
1570/** @} */