blob: fb5e204450da47aede6280bbb209ca218155a460 [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>
Chris Ye1aaa2122020-04-07 19:38:15 -070058#include <jni.h>
Mathias Agopiane1c61d32012-03-23 14:19:36 -070059
Elliott Hughes9db409b2018-06-18 12:28:46 -070060#if !defined(__INTRODUCED_IN)
61#define __INTRODUCED_IN(__api_level) /* nothing */
62#endif
63
Mathias Agopiane1c61d32012-03-23 14:19:36 -070064#ifdef __cplusplus
65extern "C" {
66#endif
67
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070068/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070069 * Key states (may be returned by queries about the current state of a
70 * particular key code, scan code or switch).
71 */
72enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070073 /** The key state is unknown or the requested key itself is not supported. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070074 AKEY_STATE_UNKNOWN = -1,
75
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070076 /** The key is up. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070077 AKEY_STATE_UP = 0,
78
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070079 /** The key is down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070080 AKEY_STATE_DOWN = 1,
81
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070082 /** The key is down but is a virtual key press that is being emulated by the system. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070083 AKEY_STATE_VIRTUAL = 2
84};
85
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070086/**
Siarhei Vishniakou61fafdd2018-04-13 11:00:58 -050087 * Meta key / modifier state.
Mathias Agopiane1c61d32012-03-23 14:19:36 -070088 */
89enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070090 /** No meta keys are pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070091 AMETA_NONE = 0,
92
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070093 /** This mask is used to check whether one of the ALT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070094 AMETA_ALT_ON = 0x02,
95
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070096 /** This mask is used to check whether the left ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070097 AMETA_ALT_LEFT_ON = 0x10,
98
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070099 /** This mask is used to check whether the right ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700100 AMETA_ALT_RIGHT_ON = 0x20,
101
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700102 /** This mask is used to check whether one of the SHIFT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700103 AMETA_SHIFT_ON = 0x01,
104
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700105 /** This mask is used to check whether the left SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700106 AMETA_SHIFT_LEFT_ON = 0x40,
107
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700108 /** This mask is used to check whether the right SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700109 AMETA_SHIFT_RIGHT_ON = 0x80,
110
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700111 /** This mask is used to check whether the SYM meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700112 AMETA_SYM_ON = 0x04,
113
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700114 /** This mask is used to check whether the FUNCTION meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700115 AMETA_FUNCTION_ON = 0x08,
116
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700117 /** This mask is used to check whether one of the CTRL meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700118 AMETA_CTRL_ON = 0x1000,
119
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700120 /** This mask is used to check whether the left CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700121 AMETA_CTRL_LEFT_ON = 0x2000,
122
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700123 /** This mask is used to check whether the right CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700124 AMETA_CTRL_RIGHT_ON = 0x4000,
125
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700126 /** This mask is used to check whether one of the META meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700127 AMETA_META_ON = 0x10000,
128
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700129 /** This mask is used to check whether the left META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700130 AMETA_META_LEFT_ON = 0x20000,
131
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700132 /** This mask is used to check whether the right META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700133 AMETA_META_RIGHT_ON = 0x40000,
134
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700135 /** This mask is used to check whether the CAPS LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700136 AMETA_CAPS_LOCK_ON = 0x100000,
137
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700138 /** This mask is used to check whether the NUM LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700139 AMETA_NUM_LOCK_ON = 0x200000,
140
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700141 /** This mask is used to check whether the SCROLL LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700142 AMETA_SCROLL_LOCK_ON = 0x400000,
143};
144
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700145struct AInputEvent;
146/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700147 * Input events.
148 *
149 * Input events are opaque structures. Use the provided accessors functions to
150 * read their properties.
151 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700152typedef struct AInputEvent AInputEvent;
153
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700154/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700155 * Input event types.
156 */
157enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700158 /** Indicates that the input event is a key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700159 AINPUT_EVENT_TYPE_KEY = 1,
160
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700161 /** Indicates that the input event is a motion event. */
Siarhei Vishniakou7feb2ea2019-11-25 15:11:23 -0800162 AINPUT_EVENT_TYPE_MOTION = 2,
163
164 /** Focus event */
165 AINPUT_EVENT_TYPE_FOCUS = 3,
Prabir Pradhan3f37b7b2020-11-10 16:50:18 -0800166
167 /** Capture event */
168 AINPUT_EVENT_TYPE_CAPTURE = 4,
arthurhung7632c332020-12-30 16:58:01 +0800169
170 /** Drag event */
171 AINPUT_EVENT_TYPE_DRAG = 5,
Antonio Kantek7cdf8ef2021-07-13 18:04:53 -0700172
173 /** TouchMode event */
174 AINPUT_EVENT_TYPE_TOUCH_MODE = 6,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700175};
176
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700177/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700178 * Key event actions.
179 */
180enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700181 /** The key has been pressed down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700182 AKEY_EVENT_ACTION_DOWN = 0,
183
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700184 /** The key has been released. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700185 AKEY_EVENT_ACTION_UP = 1,
186
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700187 /**
188 * Multiple duplicate key events have occurred in a row, or a
189 * complex string is being delivered. The repeat_count property
190 * of the key event contains the number of times the given key
191 * code should be executed.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700192 */
193 AKEY_EVENT_ACTION_MULTIPLE = 2
194};
195
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700196/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700197 * Key event flags.
198 */
199enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700200 /** This mask is set if the device woke because of this key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700201 AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
202
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700203 /** This mask is set if the key event was generated by a software keyboard. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700204 AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
205
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700206 /** 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 -0700207 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
208
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700209 /**
210 * This mask is set if an event was known to come from a trusted
211 * part of the system. That is, the event is known to come from
212 * the user, and could not have been spoofed by a third party
213 * component.
214 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700215 AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
216
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700217 /**
218 * This mask is used for compatibility, to identify enter keys that are
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700219 * coming from an IME whose enter key has been auto-labelled "next" or
220 * "done". This allows TextView to dispatch these as normal enter keys
221 * for old applications, but still do the appropriate action when
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700222 * receiving them.
223 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700224 AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
225
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700226 /**
227 * When associated with up key events, this indicates that the key press
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700228 * has been canceled. Typically this is used with virtual touch screen
229 * keys, where the user can slide from the virtual key area on to the
230 * display: in that case, the application will receive a canceled up
231 * event and should not perform the action normally associated with the
232 * key. Note that for this to work, the application can not perform an
233 * action for a key until it receives an up or the long press timeout has
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700234 * expired.
235 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700236 AKEY_EVENT_FLAG_CANCELED = 0x20,
237
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700238 /**
239 * This key event was generated by a virtual (on-screen) hard key area.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700240 * Typically this is an area of the touchscreen, outside of the regular
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700241 * display, dedicated to "hardware" buttons.
242 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700243 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
244
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700245 /**
246 * This flag is set for the first key repeat that occurs after the
247 * long press timeout.
248 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700249 AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
250
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700251 /**
252 * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
253 * press action was executed while it was down.
254 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700255 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
256
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700257 /**
258 * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700259 * tracked from its initial down. That is, somebody requested that tracking
260 * started on the key down and a long press has not caused
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700261 * the tracking to be canceled.
262 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700263 AKEY_EVENT_FLAG_TRACKING = 0x200,
264
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700265 /**
266 * Set when a key event has been synthesized to implement default behavior
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700267 * for an event that the application did not handle.
268 * Fallback key events are generated by unhandled trackball motions
269 * (to emulate a directional keypad) and by certain unhandled key presses
270 * that are declared in the key map (such as special function numeric keypad
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700271 * keys when numlock is off).
272 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700273 AKEY_EVENT_FLAG_FALLBACK = 0x400,
274};
275
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700276/**
277 * Bit shift for the action bits holding the pointer index as
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700278 * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
279 */
280#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
281
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700282/** Motion event actions */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700283enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700284 /** Bit mask of the parts of the action code that are the action itself. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700285 AMOTION_EVENT_ACTION_MASK = 0xff,
286
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700287 /**
288 * Bits in the action code that represent a pointer index, used with
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700289 * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
290 * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
291 * index where the data for the pointer going up or down can be found.
292 */
293 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
294
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700295 /** A pressed gesture has started, the motion contains the initial starting location. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700296 AMOTION_EVENT_ACTION_DOWN = 0,
297
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700298 /**
299 * A pressed gesture has finished, the motion contains the final release location
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700300 * as well as any intermediate points since the last down or move event.
301 */
302 AMOTION_EVENT_ACTION_UP = 1,
303
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700304 /**
305 * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700306 * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
307 * any intermediate points since the last down or move event.
308 */
309 AMOTION_EVENT_ACTION_MOVE = 2,
310
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700311 /**
312 * The current gesture has been aborted.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700313 * You will not receive any more points in it. You should treat this as
314 * an up event, but not perform any action that you normally would.
315 */
316 AMOTION_EVENT_ACTION_CANCEL = 3,
317
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700318 /**
319 * A movement has happened outside of the normal bounds of the UI element.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700320 * This does not provide a full gesture, but only the initial location of the movement/touch.
321 */
322 AMOTION_EVENT_ACTION_OUTSIDE = 4,
323
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700324 /**
325 * A non-primary pointer has gone down.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700326 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
327 */
328 AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
329
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700330 /**
331 * A non-primary pointer has gone up.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700332 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
333 */
334 AMOTION_EVENT_ACTION_POINTER_UP = 6,
335
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700336 /**
337 * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700338 * The motion contains the most recent point, as well as any intermediate points since
339 * the last hover move event.
340 */
341 AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
342
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700343 /**
344 * The motion event contains relative vertical and/or horizontal scroll offsets.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700345 * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
346 * and AMOTION_EVENT_AXIS_HSCROLL.
347 * The pointer may or may not be down when this event is dispatched.
348 * This action is always delivered to the winder under the pointer, which
349 * may not be the window currently touched.
350 */
351 AMOTION_EVENT_ACTION_SCROLL = 8,
352
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700353 /** The pointer is not down but has entered the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700354 AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
355
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700356 /** The pointer is not down but has exited the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700357 AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
Michael Wright7b159c92015-05-14 14:48:03 +0100358
359 /* One or more buttons have been pressed. */
360 AMOTION_EVENT_ACTION_BUTTON_PRESS = 11,
361
362 /* One or more buttons have been released. */
363 AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700364};
365
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700366/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700367 * Motion event flags.
368 */
369enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700370 /**
371 * This flag indicates that the window that received this motion event is partly
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700372 * or wholly obscured by another visible window above it. This flag is set to true
373 * even if the event did not directly pass through the obscured area.
374 * A security sensitive application can check this flag to identify situations in which
375 * a malicious application may have covered up part of its content for the purpose
376 * of misleading the user or hijacking touches. An appropriate response might be
377 * to drop the suspect touches or to take additional precautions to confirm the user's
378 * actual intent.
379 */
380 AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
381};
382
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700383/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700384 * Motion event edge touch flags.
385 */
386enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700387 /** No edges intersected. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700388 AMOTION_EVENT_EDGE_FLAG_NONE = 0,
389
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700390 /** Flag indicating the motion event intersected the top edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700391 AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
392
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700393 /** Flag indicating the motion event intersected the bottom edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700394 AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
395
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700396 /** Flag indicating the motion event intersected the left edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700397 AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
398
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700399 /** Flag indicating the motion event intersected the right edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700400 AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
401};
402
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700403/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700404 * Constants that identify each individual axis of a motion event.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700405 * @anchor AMOTION_EVENT_AXIS
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700406 */
407enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700408 /**
409 * Axis constant: X axis of a motion event.
410 *
411 * - For a touch screen, reports the absolute X screen position of the center of
412 * the touch contact area. The units are display pixels.
413 * - For a touch pad, reports the absolute X surface position of the center of the touch
414 * contact area. The units are device-dependent.
415 * - For a mouse, reports the absolute X screen position of the mouse pointer.
416 * The units are display pixels.
417 * - For a trackball, reports the relative horizontal displacement of the trackball.
418 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
419 * - For a joystick, reports the absolute X position of the joystick.
420 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
421 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700422 AMOTION_EVENT_AXIS_X = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700423 /**
424 * Axis constant: Y axis of a motion event.
425 *
426 * - For a touch screen, reports the absolute Y screen position of the center of
427 * the touch contact area. The units are display pixels.
428 * - For a touch pad, reports the absolute Y surface position of the center of the touch
429 * contact area. The units are device-dependent.
430 * - For a mouse, reports the absolute Y screen position of the mouse pointer.
431 * The units are display pixels.
432 * - For a trackball, reports the relative vertical displacement of the trackball.
433 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
434 * - For a joystick, reports the absolute Y position of the joystick.
435 * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
436 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700437 AMOTION_EVENT_AXIS_Y = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700438 /**
439 * Axis constant: Pressure axis of a motion event.
440 *
441 * - For a touch screen or touch pad, reports the approximate pressure applied to the surface
442 * by a finger or other tool. The value is normalized to a range from
443 * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
444 * may be generated depending on the calibration of the input device.
445 * - For a trackball, the value is set to 1 if the trackball button is pressed
446 * or 0 otherwise.
447 * - For a mouse, the value is set to 1 if the primary mouse button is pressed
448 * or 0 otherwise.
449 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700450 AMOTION_EVENT_AXIS_PRESSURE = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700451 /**
452 * Axis constant: Size axis of a motion event.
453 *
454 * - For a touch screen or touch pad, reports the approximate size of the contact area in
455 * relation to the maximum detectable size for the device. The value is normalized
456 * to a range from 0 (smallest detectable size) to 1 (largest detectable size),
457 * although it is not a linear scale. This value is of limited use.
458 * To obtain calibrated size information, see
459 * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}.
460 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700461 AMOTION_EVENT_AXIS_SIZE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700462 /**
463 * Axis constant: TouchMajor axis of a motion event.
464 *
465 * - For a touch screen, reports the length of the major axis of an ellipse that
466 * represents the touch area at the point of contact.
467 * The units are display pixels.
468 * - For a touch pad, 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 device-dependent.
471 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700472 AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700473 /**
474 * Axis constant: TouchMinor axis of a motion event.
475 *
476 * - For a touch screen, reports the length of the minor axis of an ellipse that
477 * represents the touch area at the point of contact.
478 * The units are display pixels.
479 * - For a touch pad, 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 device-dependent.
482 *
483 * When the touch is circular, the major and minor axis lengths will be equal to one another.
484 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700485 AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700486 /**
487 * Axis constant: ToolMajor axis of a motion event.
488 *
489 * - For a touch screen, reports the length of the major axis of an ellipse that
490 * represents the size of the approaching finger or tool used to make contact.
491 * - For a touch pad, reports the length of the major axis of an ellipse that
492 * represents the size of the approaching finger or tool used to make contact.
493 * The units are device-dependent.
494 *
495 * When the touch is circular, the major and minor axis lengths will be equal to one another.
496 *
497 * The tool size may be larger than the touch size since the tool may not be fully
498 * in contact with the touch sensor.
499 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700500 AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700501 /**
502 * Axis constant: ToolMinor axis of a motion event.
503 *
504 * - For a touch screen, reports the length of the minor axis of an ellipse that
505 * represents the size of the approaching finger or tool used to make contact.
506 * - For a touch pad, reports the length of the minor axis of an ellipse that
507 * represents the size of the approaching finger or tool used to make contact.
508 * The units are device-dependent.
509 *
510 * When the touch is circular, the major and minor axis lengths will be equal to one another.
511 *
512 * The tool size may be larger than the touch size since the tool may not be fully
513 * in contact with the touch sensor.
514 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700515 AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700516 /**
517 * Axis constant: Orientation axis of a motion event.
518 *
519 * - For a touch screen or touch pad, reports the orientation of the finger
520 * or tool in radians relative to the vertical plane of the device.
521 * An angle of 0 radians indicates that the major axis of contact is oriented
522 * upwards, is perfectly circular or is of unknown orientation. A positive angle
523 * indicates that the major axis of contact is oriented to the right. A negative angle
524 * indicates that the major axis of contact is oriented to the left.
525 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
526 * (finger pointing fully right).
527 * - For a stylus, the orientation indicates the direction in which the stylus
528 * is pointing in relation to the vertical axis of the current orientation of the screen.
529 * The range is from -PI radians to PI radians, where 0 is pointing up,
530 * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
531 * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}.
532 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700533 AMOTION_EVENT_AXIS_ORIENTATION = 8,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700534 /**
535 * Axis constant: Vertical Scroll axis of a motion event.
536 *
537 * - For a mouse, reports the relative movement of the vertical scroll wheel.
538 * The value is normalized to a range from -1.0 (down) to 1.0 (up).
539 *
540 * This axis should be used to scroll views vertically.
541 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700542 AMOTION_EVENT_AXIS_VSCROLL = 9,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700543 /**
544 * Axis constant: Horizontal Scroll axis of a motion event.
545 *
546 * - For a mouse, reports the relative movement of the horizontal scroll wheel.
547 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
548 *
549 * This axis should be used to scroll views horizontally.
550 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700551 AMOTION_EVENT_AXIS_HSCROLL = 10,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700552 /**
553 * Axis constant: Z axis of a motion event.
554 *
555 * - For a joystick, reports the absolute Z position of the joystick.
556 * The value is normalized to a range from -1.0 (high) to 1.0 (low).
557 * <em>On game pads with two analog joysticks, this axis is often reinterpreted
558 * to report the absolute X position of the second joystick instead.</em>
559 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700560 AMOTION_EVENT_AXIS_Z = 11,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700561 /**
562 * Axis constant: X Rotation axis of a motion event.
563 *
564 * - For a joystick, reports the absolute rotation angle about the X axis.
565 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
566 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700567 AMOTION_EVENT_AXIS_RX = 12,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700568 /**
569 * Axis constant: Y Rotation axis of a motion event.
570 *
571 * - For a joystick, reports the absolute rotation angle about the Y axis.
572 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
573 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700574 AMOTION_EVENT_AXIS_RY = 13,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700575 /**
576 * Axis constant: Z Rotation axis of a motion event.
577 *
578 * - For a joystick, reports the absolute rotation angle about the Z axis.
579 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
580 * On game pads with two analog joysticks, this axis is often reinterpreted
581 * to report the absolute Y position of the second joystick instead.
582 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700583 AMOTION_EVENT_AXIS_RZ = 14,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700584 /**
585 * Axis constant: Hat X axis of a motion event.
586 *
587 * - For a joystick, reports the absolute X position of the directional hat control.
588 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
589 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700590 AMOTION_EVENT_AXIS_HAT_X = 15,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700591 /**
592 * Axis constant: Hat Y axis of a motion event.
593 *
594 * - For a joystick, reports the absolute Y position of the directional hat control.
595 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
596 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700597 AMOTION_EVENT_AXIS_HAT_Y = 16,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700598 /**
599 * Axis constant: Left Trigger axis of a motion event.
600 *
601 * - For a joystick, reports the absolute position of the left trigger control.
602 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
603 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700604 AMOTION_EVENT_AXIS_LTRIGGER = 17,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700605 /**
606 * Axis constant: Right Trigger axis of a motion event.
607 *
608 * - For a joystick, reports the absolute position of the right trigger control.
609 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
610 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700611 AMOTION_EVENT_AXIS_RTRIGGER = 18,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700612 /**
613 * Axis constant: Throttle axis of a motion event.
614 *
615 * - For a joystick, reports the absolute position of the throttle control.
616 * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
617 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700618 AMOTION_EVENT_AXIS_THROTTLE = 19,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700619 /**
620 * Axis constant: Rudder axis of a motion event.
621 *
622 * - For a joystick, reports the absolute position of the rudder control.
623 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
624 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700625 AMOTION_EVENT_AXIS_RUDDER = 20,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700626 /**
627 * Axis constant: Wheel axis of a motion event.
628 *
629 * - For a joystick, reports the absolute position of the steering wheel control.
630 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
631 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700632 AMOTION_EVENT_AXIS_WHEEL = 21,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700633 /**
634 * Axis constant: Gas axis of a motion event.
635 *
636 * - For a joystick, reports the absolute position of the gas (accelerator) control.
637 * The value is normalized to a range from 0.0 (no acceleration)
638 * to 1.0 (maximum acceleration).
639 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700640 AMOTION_EVENT_AXIS_GAS = 22,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700641 /**
642 * Axis constant: Brake axis of a motion event.
643 *
644 * - For a joystick, reports the absolute position of the brake control.
645 * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
646 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700647 AMOTION_EVENT_AXIS_BRAKE = 23,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700648 /**
649 * Axis constant: Distance axis of a motion event.
650 *
651 * - For a stylus, reports the distance of the stylus from the screen.
652 * A value of 0.0 indicates direct contact and larger values indicate increasing
653 * distance from the surface.
654 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700655 AMOTION_EVENT_AXIS_DISTANCE = 24,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700656 /**
657 * Axis constant: Tilt axis of a motion event.
658 *
659 * - For a stylus, reports the tilt angle of the stylus in radians where
660 * 0 radians indicates that the stylus is being held perpendicular to the
661 * surface, and PI/2 radians indicates that the stylus is being held flat
662 * against the surface.
663 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700664 AMOTION_EVENT_AXIS_TILT = 25,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700665 /**
Prashant Malani1941ff52015-08-11 18:29:28 -0700666 * Axis constant: Generic scroll axis of a motion event.
667 *
668 * - This is used for scroll axis motion events that can't be classified as strictly
669 * vertical or horizontal. The movement of a rotating scroller is an example of this.
670 */
671 AMOTION_EVENT_AXIS_SCROLL = 26,
672 /**
Jun Mukaifa1706a2015-12-03 01:14:46 -0800673 * Axis constant: The movement of x position of a motion event.
674 *
675 * - For a mouse, reports a difference of x position between the previous position.
676 * This is useful when pointer is captured, in that case the mouse pointer doesn't
677 * change the location but this axis reports the difference which allows the app
678 * to see how the mouse is moved.
679 */
680 AMOTION_EVENT_AXIS_RELATIVE_X = 27,
681 /**
682 * Axis constant: The movement of y position of a motion event.
683 *
Siarhei Vishniakou2745c952021-03-17 20:27:41 +0000684 * Same as {@link AMOTION_EVENT_AXIS_RELATIVE_X}, but for y position.
Jun Mukaifa1706a2015-12-03 01:14:46 -0800685 */
686 AMOTION_EVENT_AXIS_RELATIVE_Y = 28,
687 /**
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700688 * Axis constant: Generic 1 axis of a motion event.
689 * The interpretation of a generic axis is device-specific.
690 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700691 AMOTION_EVENT_AXIS_GENERIC_1 = 32,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700692 /**
693 * Axis constant: Generic 2 axis of a motion event.
694 * The interpretation of a generic axis is device-specific.
695 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700696 AMOTION_EVENT_AXIS_GENERIC_2 = 33,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700697 /**
698 * Axis constant: Generic 3 axis of a motion event.
699 * The interpretation of a generic axis is device-specific.
700 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700701 AMOTION_EVENT_AXIS_GENERIC_3 = 34,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700702 /**
703 * Axis constant: Generic 4 axis of a motion event.
704 * The interpretation of a generic axis is device-specific.
705 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700706 AMOTION_EVENT_AXIS_GENERIC_4 = 35,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700707 /**
708 * Axis constant: Generic 5 axis of a motion event.
709 * The interpretation of a generic axis is device-specific.
710 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700711 AMOTION_EVENT_AXIS_GENERIC_5 = 36,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700712 /**
713 * Axis constant: Generic 6 axis of a motion event.
714 * The interpretation of a generic axis is device-specific.
715 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700716 AMOTION_EVENT_AXIS_GENERIC_6 = 37,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700717 /**
718 * Axis constant: Generic 7 axis of a motion event.
719 * The interpretation of a generic axis is device-specific.
720 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700721 AMOTION_EVENT_AXIS_GENERIC_7 = 38,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700722 /**
723 * Axis constant: Generic 8 axis of a motion event.
724 * The interpretation of a generic axis is device-specific.
725 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700726 AMOTION_EVENT_AXIS_GENERIC_8 = 39,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700727 /**
728 * Axis constant: Generic 9 axis of a motion event.
729 * The interpretation of a generic axis is device-specific.
730 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700731 AMOTION_EVENT_AXIS_GENERIC_9 = 40,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700732 /**
733 * Axis constant: Generic 10 axis of a motion event.
734 * The interpretation of a generic axis is device-specific.
735 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700736 AMOTION_EVENT_AXIS_GENERIC_10 = 41,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700737 /**
738 * Axis constant: Generic 11 axis of a motion event.
739 * The interpretation of a generic axis is device-specific.
740 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700741 AMOTION_EVENT_AXIS_GENERIC_11 = 42,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700742 /**
743 * Axis constant: Generic 12 axis of a motion event.
744 * The interpretation of a generic axis is device-specific.
745 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700746 AMOTION_EVENT_AXIS_GENERIC_12 = 43,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700747 /**
748 * Axis constant: Generic 13 axis of a motion event.
749 * The interpretation of a generic axis is device-specific.
750 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700751 AMOTION_EVENT_AXIS_GENERIC_13 = 44,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700752 /**
753 * Axis constant: Generic 14 axis of a motion event.
754 * The interpretation of a generic axis is device-specific.
755 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700756 AMOTION_EVENT_AXIS_GENERIC_14 = 45,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700757 /**
758 * Axis constant: Generic 15 axis of a motion event.
759 * The interpretation of a generic axis is device-specific.
760 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700761 AMOTION_EVENT_AXIS_GENERIC_15 = 46,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700762 /**
763 * Axis constant: Generic 16 axis of a motion event.
764 * The interpretation of a generic axis is device-specific.
765 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700766 AMOTION_EVENT_AXIS_GENERIC_16 = 47,
767
768 // NOTE: If you add a new axis here you must also add it to several other files.
769 // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
770};
771
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700772/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700773 * Constants that identify buttons that are associated with motion events.
774 * Refer to the documentation on the MotionEvent class for descriptions of each button.
775 */
776enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700777 /** primary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700778 AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700779 /** secondary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700780 AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700781 /** tertiary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700782 AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700783 /** back */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700784 AMOTION_EVENT_BUTTON_BACK = 1 << 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700785 /** forward */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700786 AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
Michael Wright7b159c92015-05-14 14:48:03 +0100787 AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
788 AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700789};
790
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700791/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700792 * Constants that identify tool types.
793 * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
794 */
795enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700796 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700797 AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700798 /** finger */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700799 AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700800 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700801 AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700802 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700803 AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700804 /** eraser */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700805 AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
Arthur Hung421eb1c2020-01-16 00:09:42 +0800806 /** palm */
807 AMOTION_EVENT_TOOL_TYPE_PALM = 5,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700808};
809
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700810/**
Vaibhav8576dd72022-02-11 18:19:06 +0530811 * Constants that identify different gesture classification types.
812 */
813enum {
814 /**
815 * Classification constant: None.
816 *
817 * No additional information is available about the current motion event stream.
818 */
819 AMOTION_EVENT_CLASSIFICATION_NONE = 0,
820 /**
821 * Classification constant: Ambiguous gesture.
822 *
823 * The user's intent with respect to the current event stream is not yet determined.
824 * Gestural actions, such as scrolling, should be inhibited until the classification resolves
825 * to another value or the event stream ends.
826 */
827 AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE = 1,
828 /**
829 * Classification constant: Deep press.
830 *
831 * The current event stream represents the user intentionally pressing harder on the screen.
832 * This classification type should be used to accelerate the long press behaviour.
833 */
834 AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS = 2,
835};
836
837/**
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700838 * Input source masks.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700839 *
840 * Refer to the documentation on android.view.InputDevice for more details about input sources
841 * and their correct interpretation.
842 */
843enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700844 /** mask */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700845 AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
846
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700847 /** none */
Michael Wrightaadaca72013-03-11 14:20:14 -0700848 AINPUT_SOURCE_CLASS_NONE = 0x00000000,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700849 /** button */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700850 AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700851 /** pointer */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700852 AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700853 /** navigation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700854 AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700855 /** position */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700856 AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700857 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700858 AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
859};
860
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700861/**
862 * Input sources.
863 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700864enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700865 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700866 AINPUT_SOURCE_UNKNOWN = 0x00000000,
867
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700868 /** keyboard */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700869 AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700870 /** dpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700871 AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700872 /** gamepad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700873 AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700874 /** touchscreen */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700875 AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700876 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700877 AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700878 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700879 AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
Michael Wright7d3ad692015-06-23 19:04:31 +0100880 /** bluetooth stylus */
Michael Wright2f78b682015-06-12 15:25:08 +0100881 AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700882 /** trackball */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700883 AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Vladislav Kaznacheev78f97b32016-12-15 18:14:58 -0800884 /** mouse relative */
885 AINPUT_SOURCE_MOUSE_RELATIVE = 0x00020000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700886 /** touchpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700887 AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700888 /** navigation */
Michael Wrightaadaca72013-03-11 14:20:14 -0700889 AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700890 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700891 AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
Chris Ye02303442021-01-26 13:21:01 -0800892 /** HDMI */
893 AINPUT_SOURCE_HDMI = 0x02000000 | AINPUT_SOURCE_CLASS_BUTTON,
Chris Yef59a2f42020-10-16 12:55:26 -0700894 /** sensor */
Chris Ye3fdbfef2021-01-06 18:45:18 -0800895 AINPUT_SOURCE_SENSOR = 0x04000000 | AINPUT_SOURCE_CLASS_NONE,
Prashant Malani1941ff52015-08-11 18:29:28 -0700896 /** rotary encoder */
897 AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700898
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700899 /** any */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700900 AINPUT_SOURCE_ANY = 0xffffff00,
901};
902
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700903/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700904 * Keyboard types.
905 *
906 * Refer to the documentation on android.view.InputDevice for more details.
Philip Junkerf8437962022-01-25 21:20:19 +0100907 * Note: When adding a new keyboard type here InputDeviceInfo::setKeyboardType needs to be updated.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700908 */
909enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700910 /** none */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700911 AINPUT_KEYBOARD_TYPE_NONE = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700912 /** non alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700913 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700914 /** alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700915 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
916};
917
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700918/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700919 * Constants used to retrieve information about the range of motion for a particular
920 * coordinate of a motion event.
921 *
922 * Refer to the documentation on android.view.InputDevice for more details about input sources
923 * and their correct interpretation.
924 *
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700925 * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700926 */
927enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700928 /** x */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700929 AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700930 /** y */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700931 AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700932 /** pressure */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700933 AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700934 /** size */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700935 AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700936 /** touch major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700937 AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700938 /** touch minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700939 AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700940 /** tool major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700941 AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700942 /** tool minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700943 AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700944 /** orientation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700945 AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700946};
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700947
948
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700949/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700950 * Input event accessors.
951 *
952 * Note that most functions can only be used on input events that are of a given type.
953 * Calling these functions on input events of other types will yield undefined behavior.
954 */
955
956/*** Accessors for all input events. ***/
957
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700958/** Get the input event type. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700959int32_t AInputEvent_getType(const AInputEvent* event);
960
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700961/** Get the id for the device that an input event came from.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700962 *
963 * Input events can be generated by multiple different input devices.
964 * Use the input device id to obtain information about the input
965 * device that was responsible for generating a particular event.
966 *
967 * An input device id of 0 indicates that the event didn't come from a physical device;
968 * other numbers are arbitrary and you shouldn't depend on the values.
969 * Use the provided input device query API to obtain information about input devices.
970 */
971int32_t AInputEvent_getDeviceId(const AInputEvent* event);
972
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700973/** Get the input event source. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700974int32_t AInputEvent_getSource(const AInputEvent* event);
975
Chris Ye1aaa2122020-04-07 19:38:15 -0700976/**
977 * Releases interface objects created by {@link AKeyEvent_fromJava()}
978 * and {@link AMotionEvent_fromJava()}.
979 * After returning, the specified AInputEvent* object becomes invalid and should no longer be used.
980 * The underlying Java object remains valid and does not change its state.
Elliott Hughesdbfde642021-09-14 10:31:47 -0700981 *
982 * Available since API level 31.
Chris Ye1aaa2122020-04-07 19:38:15 -0700983 */
Elliott Hughesdbfde642021-09-14 10:31:47 -0700984void AInputEvent_release(const AInputEvent* event) __INTRODUCED_IN(31);
Chris Ye1aaa2122020-04-07 19:38:15 -0700985
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700986/*** Accessors for key events only. ***/
987
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700988/** Get the key event action. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700989int32_t AKeyEvent_getAction(const AInputEvent* key_event);
990
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700991/** Get the key event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700992int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
993
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700994/**
995 * Get the key code of the key event.
996 * This is the physical key that was pressed, not the Unicode character.
997 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700998int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
999
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001000/**
1001 * Get the hardware key id of this key event.
1002 * These values are not reliable and vary from device to device.
1003 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001004int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
1005
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001006/** Get the meta key state. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001007int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
1008
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001009/**
1010 * Get the repeat count of the event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001011 * For both key up an key down events, this is the number of times the key has
1012 * repeated with the first down starting at 0 and counting up from there. For
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001013 * multiple key events, this is the number of down/up pairs that have occurred.
1014 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001015int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
1016
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001017/**
1018 * Get the time of the most recent key down event, in the
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001019 * java.lang.System.nanoTime() time base. If this is a down event,
1020 * this will be the same as eventTime.
1021 * Note that when chording keys, this value is the down time of the most recently
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001022 * pressed key, which may not be the same physical key of this event.
1023 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001024int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
1025
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001026/**
1027 * Get the time this event occurred, in the
1028 * java.lang.System.nanoTime() time base.
1029 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001030int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
1031
Chris Ye1aaa2122020-04-07 19:38:15 -07001032/**
Siarhei Vishniakoua53d8652020-08-13 23:59:50 -05001033 * Creates a native AInputEvent* object that is a copy of the specified Java android.view.KeyEvent.
1034 * The result may be used with generic and KeyEvent-specific AInputEvent_* functions. The object
1035 * returned by this function must be disposed using {@link AInputEvent_release()}.
Elliott Hughesdbfde642021-09-14 10:31:47 -07001036 *
1037 * Available since API level 31.
Chris Ye1aaa2122020-04-07 19:38:15 -07001038 */
Elliott Hughesdbfde642021-09-14 10:31:47 -07001039const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent) __INTRODUCED_IN(31);
Chris Ye1aaa2122020-04-07 19:38:15 -07001040
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001041/*** Accessors for motion events only. ***/
1042
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001043/** Get the combined motion event action code and pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001044int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
1045
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001046/** Get the motion event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001047int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
1048
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001049/**
1050 * Get the state of any meta / modifier keys that were in effect when the
1051 * event was generated.
1052 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001053int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
1054
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001055/** Get the button state of all buttons that are pressed. */
Elliott Hughes3d70e532019-10-29 08:59:39 -07001056int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001057
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001058/**
1059 * Get a bitfield indicating which edges, if any, were touched by this motion event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001060 * For touch events, clients can use this to determine if the user's finger was
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001061 * touching the edge of the display.
1062 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001063int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
1064
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001065/**
1066 * Get the time when the user originally pressed down to start a stream of
1067 * position events, in the java.lang.System.nanoTime() time base.
1068 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001069int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
1070
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001071/**
1072 * Get the time when this specific event was generated,
1073 * in the java.lang.System.nanoTime() time base.
1074 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001075int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
1076
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001077/**
1078 * Get the X coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001079 * For touch events on the screen, this is the delta that was added to the raw
1080 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001081 * and views.
1082 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001083float AMotionEvent_getXOffset(const AInputEvent* motion_event);
1084
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001085/**
1086 * Get the Y coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001087 * For touch events on the screen, this is the delta that was added to the raw
1088 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001089 * and views.
1090 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001091float AMotionEvent_getYOffset(const AInputEvent* motion_event);
1092
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001093/**
1094 * Get the precision of the X coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001095 * You can multiply this number with an X coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001096 * actual hardware value of the X coordinate.
1097 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001098float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
1099
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001100/**
1101 * Get the precision of the Y coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001102 * You can multiply this number with a Y coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001103 * actual hardware value of the Y coordinate.
1104 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001105float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
1106
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001107/**
1108 * Get the number of pointers of data contained in this event.
1109 * Always >= 1.
1110 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001111size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
1112
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001113/**
1114 * Get the pointer identifier associated with a particular pointer
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001115 * data index in this event. The identifier tells you the actual pointer
1116 * number associated with the data, accounting for individual pointers
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001117 * going up and down since the start of the current gesture.
1118 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001119int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
1120
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001121/**
1122 * Get the tool type of a pointer for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001123 * The tool type indicates the type of tool used to make contact such as a
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001124 * finger or stylus, if known.
1125 */
Elliott Hughes3d70e532019-10-29 08:59:39 -07001126int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001127
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001128/**
1129 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001130 * For touch events on the screen, this is the original location of the event
1131 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001132 * and views.
1133 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001134float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
1135
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001136/**
1137 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001138 * For touch events on the screen, this is the original location of the event
1139 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001140 * and views.
1141 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001142float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
1143
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001144/**
1145 * Get the current X coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001146 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001147 * that are sub-pixel precise.
1148 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001149float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
1150
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001151/**
1152 * Get the current Y coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001153 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001154 * that are sub-pixel precise.
1155 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001156float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
1157
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001158/**
1159 * Get the current pressure of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001160 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1161 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001162 * the input device.
1163 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001164float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
1165
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001166/**
1167 * Get the current scaled value of the approximate size for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001168 * This represents some approximation of the area of the screen being
1169 * pressed; the actual value in pixels corresponding to the
1170 * touch is normalized with the device specific range of values
1171 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001172 * determine fat touch events.
1173 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001174float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
1175
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001176/**
1177 * Get the current length of the major axis of an ellipse that describes the touch area
1178 * at the point of contact for the given pointer index.
1179 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001180float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
1181
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001182/**
1183 * Get the current length of the minor axis of an ellipse that describes the touch area
1184 * at the point of contact for the given pointer index.
1185 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001186float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
1187
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001188/**
1189 * Get the current length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001190 * of the approaching tool for the given pointer index.
1191 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001192 * touching the device independent of its actual touch area at the point of contact.
1193 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001194float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
1195
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001196/**
1197 * Get the current length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001198 * of the approaching tool for the given pointer index.
1199 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001200 * touching the device independent of its actual touch area at the point of contact.
1201 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001202float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
1203
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001204/**
1205 * Get the current orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001206 * vertical for the given pointer index.
1207 * An angle of 0 degrees indicates that the major axis of contact is oriented
1208 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1209 * indicates that the major axis of contact is oriented to the right. A negative angle
1210 * indicates that the major axis of contact is oriented to the left.
1211 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001212 * (finger pointing fully right).
1213 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001214float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
1215
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001216/** Get the value of the request axis for the given pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001217float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001218 int32_t axis, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001219
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001220/**
1221 * Get the number of historical points in this event. These are movements that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001222 * have occurred between this event and the previous event. This only applies
1223 * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001224 * Historical samples are indexed from oldest to newest.
1225 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001226size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
1227
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001228/**
1229 * Get the time that a historical movement occurred between this event and
1230 * the previous event, in the java.lang.System.nanoTime() time base.
1231 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001232int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001233 size_t history_index);
1234
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001235/**
1236 * Get the historical raw X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001237 * occurred between this event and the previous motion event.
1238 * For touch events on the screen, this is the original location of the event
1239 * on the screen, before it had been adjusted for the containing window
1240 * and views.
1241 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001242 * that are sub-pixel precise.
1243 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001244float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
1245 size_t history_index);
1246
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001247/**
1248 * Get the historical raw Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001249 * occurred between this event and the previous motion event.
1250 * For touch events on the screen, this is the original location of the event
1251 * on the screen, before it had been adjusted for the containing window
1252 * and views.
1253 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001254 * that are sub-pixel precise.
1255 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001256float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
1257 size_t history_index);
1258
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001259/**
1260 * Get the historical X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001261 * occurred between this event and the previous motion event.
1262 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001263 * that are sub-pixel precise.
1264 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001265float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001266 size_t history_index);
1267
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001268/**
1269 * Get the historical Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001270 * occurred between this event and the previous motion event.
1271 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001272 * that are sub-pixel precise.
1273 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001274float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001275 size_t history_index);
1276
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001277/**
1278 * Get the historical pressure of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001279 * occurred between this event and the previous motion event.
1280 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1281 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001282 * the input device.
1283 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001284float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001285 size_t history_index);
1286
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001287/**
1288 * Get the current scaled value of the approximate size for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001289 * occurred between this event and the previous motion event.
1290 * This represents some approximation of the area of the screen being
1291 * pressed; the actual value in pixels corresponding to the
1292 * touch is normalized with the device specific range of values
1293 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001294 * determine fat touch events.
1295 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001296float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001297 size_t history_index);
1298
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001299/**
1300 * Get the historical length of the major axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001301 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001302 * occurred between this event and the previous motion event.
1303 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001304float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
1305 size_t history_index);
1306
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001307/**
1308 * Get the historical length of the minor axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001309 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001310 * occurred between this event and the previous motion event.
1311 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001312float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
1313 size_t history_index);
1314
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001315/**
1316 * Get the historical length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001317 * of the approaching tool for the given pointer index that
1318 * occurred between this event and the previous motion event.
1319 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001320 * touching the device independent of its actual touch area at the point of contact.
1321 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001322float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
1323 size_t history_index);
1324
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001325/**
1326 * Get the historical length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001327 * of the approaching tool for the given pointer index that
1328 * occurred between this event and the previous motion event.
1329 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001330 * touching the device independent of its actual touch area at the point of contact.
1331 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001332float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
1333 size_t history_index);
1334
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001335/**
1336 * Get the historical orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001337 * vertical for the given pointer index that
1338 * occurred between this event and the previous motion event.
1339 * An angle of 0 degrees indicates that the major axis of contact is oriented
1340 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1341 * indicates that the major axis of contact is oriented to the right. A negative angle
1342 * indicates that the major axis of contact is oriented to the left.
1343 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001344 * (finger pointing fully right).
1345 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001346float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
1347 size_t history_index);
1348
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001349/**
1350 * Get the historical value of the request axis for the given pointer index
1351 * that occurred between this event and the previous motion event.
1352 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001353float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001354 int32_t axis, size_t pointer_index, size_t history_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001355
Chris Ye1aaa2122020-04-07 19:38:15 -07001356/**
Vaibhav8576dd72022-02-11 18:19:06 +05301357 * Get the action button for the motion event. Returns a valid action button when the
1358 * event is associated with a button press or button release action. For other actions
1359 * the return value is undefined.
1360 */
1361int32_t AMotionEvent_getActionButton(const AInputEvent* motion_event);
1362
1363/**
1364 * Returns the classification for the current gesture.
1365 * The classification may change as more events become available for the same gesture.
1366 *
1367 * @see #AMOTION_EVENT_CLASSIFICATION_NONE
1368 * @see #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE
1369 * @see #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS
1370*/
1371int32_t AMotionEvent_getClassification(const AInputEvent* motion_event);
1372
1373/**
Siarhei Vishniakoua53d8652020-08-13 23:59:50 -05001374 * Creates a native AInputEvent* object that is a copy of the specified Java
1375 * android.view.MotionEvent. The result may be used with generic and MotionEvent-specific
1376 * AInputEvent_* functions. The object returned by this function must be disposed using
1377 * {@link AInputEvent_release()}.
Elliott Hughesdbfde642021-09-14 10:31:47 -07001378 *
1379 * Available since API level 31.
Chris Ye1aaa2122020-04-07 19:38:15 -07001380 */
Elliott Hughesdbfde642021-09-14 10:31:47 -07001381const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) __INTRODUCED_IN(31);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001382
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001383struct AInputQueue;
1384/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001385 * Input queue
1386 *
1387 * An input queue is the facility through which you retrieve input
1388 * events.
1389 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001390typedef struct AInputQueue AInputQueue;
1391
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001392/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001393 * Add this input queue to a looper for processing. See
1394 * ALooper_addFd() for information on the ident, callback, and data params.
1395 */
1396void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
1397 int ident, ALooper_callbackFunc callback, void* data);
1398
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001399/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001400 * Remove the input queue from the looper it is currently attached to.
1401 */
1402void AInputQueue_detachLooper(AInputQueue* queue);
1403
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001404/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001405 * Returns true if there are one or more events available in the
1406 * input queue. Returns 1 if the queue has events; 0 if
1407 * it does not have events; and a negative value if there is an error.
1408 */
1409int32_t AInputQueue_hasEvents(AInputQueue* queue);
1410
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001411/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001412 * Returns the next available event from the queue. Returns a negative
1413 * value if no events are available or an error has occurred.
1414 */
1415int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
1416
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001417/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001418 * Sends the key for standard pre-dispatching -- that is, possibly deliver
1419 * it to the current IME to be consumed before the app. Returns 0 if it
1420 * was not pre-dispatched, meaning you can process it right now. If non-zero
1421 * is returned, you must abandon the current event processing and allow the
1422 * event to appear again in the event queue (if it does not get consumed during
1423 * pre-dispatching).
1424 */
1425int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
1426
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001427/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001428 * Report that dispatching has finished with the given event.
1429 * This must be called after receiving an event with AInputQueue_get_event().
1430 */
1431void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
1432
Jim Blacklera64c2722021-09-01 16:39:16 +01001433/**
Prabir Pradhan9d439742021-12-16 03:32:30 -08001434 * Returns the AInputQueue* object associated with the supplied Java InputQueue
1435 * object. The returned native object holds a weak reference to the Java object,
1436 * and is only valid as long as the Java object has not yet been disposed. You
1437 * should ensure that there is a strong reference to the Java object and that it
1438 * has not been disposed before using the returned object.
Jim Blacklera64c2722021-09-01 16:39:16 +01001439 *
1440 * Available since API level 33.
1441 */
Prabir Pradhanb1e1e392021-12-16 03:28:20 -08001442AInputQueue* AInputQueue_fromJava(JNIEnv* env, jobject inputQueue) __INTRODUCED_IN(33);
Jim Blacklera64c2722021-09-01 16:39:16 +01001443
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001444#ifdef __cplusplus
1445}
1446#endif
1447
1448#endif // _ANDROID_INPUT_H
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001449
1450/** @} */