blob: 7080386df7026594181defd2944d714c8326081e [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>
Ady Abraham2a6c1862022-07-28 22:54:19 +000057
58// This file is included by modules that have host support but android/looper.h is not supported
59// on host. __REMOVED_IN needs to be defined in order for android/looper.h to be compiled.
60#ifndef __BIONIC__
61#define __REMOVED_IN(x) __attribute__((deprecated))
62#endif
Mathias Agopiane1c61d32012-03-23 14:19:36 -070063#include <android/looper.h>
Ady Abraham2a6c1862022-07-28 22:54:19 +000064
Chris Ye1aaa2122020-04-07 19:38:15 -070065#include <jni.h>
Mathias Agopiane1c61d32012-03-23 14:19:36 -070066
Elliott Hughes9db409b2018-06-18 12:28:46 -070067#if !defined(__INTRODUCED_IN)
68#define __INTRODUCED_IN(__api_level) /* nothing */
69#endif
70
Mathias Agopiane1c61d32012-03-23 14:19:36 -070071#ifdef __cplusplus
72extern "C" {
73#endif
74
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070075/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070076 * Key states (may be returned by queries about the current state of a
77 * particular key code, scan code or switch).
78 */
79enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070080 /** The key state is unknown or the requested key itself is not supported. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070081 AKEY_STATE_UNKNOWN = -1,
82
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070083 /** The key is up. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070084 AKEY_STATE_UP = 0,
85
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070086 /** The key is down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070087 AKEY_STATE_DOWN = 1,
88
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070089 /** The key is down but is a virtual key press that is being emulated by the system. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070090 AKEY_STATE_VIRTUAL = 2
91};
92
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070093/**
Siarhei Vishniakou61fafdd2018-04-13 11:00:58 -050094 * Meta key / modifier state.
Mathias Agopiane1c61d32012-03-23 14:19:36 -070095 */
96enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070097 /** No meta keys are pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070098 AMETA_NONE = 0,
99
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700100 /** This mask is used to check whether one of the ALT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700101 AMETA_ALT_ON = 0x02,
102
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700103 /** This mask is used to check whether the left ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700104 AMETA_ALT_LEFT_ON = 0x10,
105
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700106 /** This mask is used to check whether the right ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700107 AMETA_ALT_RIGHT_ON = 0x20,
108
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700109 /** This mask is used to check whether one of the SHIFT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700110 AMETA_SHIFT_ON = 0x01,
111
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700112 /** This mask is used to check whether the left SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700113 AMETA_SHIFT_LEFT_ON = 0x40,
114
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700115 /** This mask is used to check whether the right SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700116 AMETA_SHIFT_RIGHT_ON = 0x80,
117
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700118 /** This mask is used to check whether the SYM meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700119 AMETA_SYM_ON = 0x04,
120
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700121 /** This mask is used to check whether the FUNCTION meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700122 AMETA_FUNCTION_ON = 0x08,
123
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700124 /** This mask is used to check whether one of the CTRL meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700125 AMETA_CTRL_ON = 0x1000,
126
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700127 /** This mask is used to check whether the left CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700128 AMETA_CTRL_LEFT_ON = 0x2000,
129
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700130 /** This mask is used to check whether the right CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700131 AMETA_CTRL_RIGHT_ON = 0x4000,
132
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700133 /** This mask is used to check whether one of the META meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700134 AMETA_META_ON = 0x10000,
135
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700136 /** This mask is used to check whether the left META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700137 AMETA_META_LEFT_ON = 0x20000,
138
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700139 /** This mask is used to check whether the right META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700140 AMETA_META_RIGHT_ON = 0x40000,
141
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700142 /** This mask is used to check whether the CAPS LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700143 AMETA_CAPS_LOCK_ON = 0x100000,
144
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700145 /** This mask is used to check whether the NUM LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700146 AMETA_NUM_LOCK_ON = 0x200000,
147
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700148 /** This mask is used to check whether the SCROLL LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700149 AMETA_SCROLL_LOCK_ON = 0x400000,
150};
151
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700152struct AInputEvent;
153/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700154 * Input events.
155 *
156 * Input events are opaque structures. Use the provided accessors functions to
157 * read their properties.
158 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700159typedef struct AInputEvent AInputEvent;
160
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700161/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700162 * Input event types.
163 */
164enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700165 /** Indicates that the input event is a key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700166 AINPUT_EVENT_TYPE_KEY = 1,
167
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700168 /** Indicates that the input event is a motion event. */
Siarhei Vishniakou7feb2ea2019-11-25 15:11:23 -0800169 AINPUT_EVENT_TYPE_MOTION = 2,
170
171 /** Focus event */
172 AINPUT_EVENT_TYPE_FOCUS = 3,
Prabir Pradhan3f37b7b2020-11-10 16:50:18 -0800173
174 /** Capture event */
175 AINPUT_EVENT_TYPE_CAPTURE = 4,
arthurhung7632c332020-12-30 16:58:01 +0800176
177 /** Drag event */
178 AINPUT_EVENT_TYPE_DRAG = 5,
Antonio Kantek7cdf8ef2021-07-13 18:04:53 -0700179
180 /** TouchMode event */
181 AINPUT_EVENT_TYPE_TOUCH_MODE = 6,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700182};
183
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700184/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700185 * Key event actions.
186 */
187enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700188 /** The key has been pressed down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700189 AKEY_EVENT_ACTION_DOWN = 0,
190
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700191 /** The key has been released. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700192 AKEY_EVENT_ACTION_UP = 1,
193
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700194 /**
195 * Multiple duplicate key events have occurred in a row, or a
196 * complex string is being delivered. The repeat_count property
197 * of the key event contains the number of times the given key
198 * code should be executed.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700199 */
200 AKEY_EVENT_ACTION_MULTIPLE = 2
201};
202
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700203/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700204 * Key event flags.
205 */
206enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700207 /** This mask is set if the device woke because of this key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700208 AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
209
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700210 /** This mask is set if the key event was generated by a software keyboard. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700211 AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
212
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700213 /** 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 -0700214 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
215
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700216 /**
217 * This mask is set if an event was known to come from a trusted
218 * part of the system. That is, the event is known to come from
219 * the user, and could not have been spoofed by a third party
220 * component.
221 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700222 AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
223
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700224 /**
225 * This mask is used for compatibility, to identify enter keys that are
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700226 * coming from an IME whose enter key has been auto-labelled "next" or
227 * "done". This allows TextView to dispatch these as normal enter keys
228 * for old applications, but still do the appropriate action when
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700229 * receiving them.
230 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700231 AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
232
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700233 /**
234 * When associated with up key events, this indicates that the key press
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700235 * has been canceled. Typically this is used with virtual touch screen
236 * keys, where the user can slide from the virtual key area on to the
237 * display: in that case, the application will receive a canceled up
238 * event and should not perform the action normally associated with the
239 * key. Note that for this to work, the application can not perform an
240 * action for a key until it receives an up or the long press timeout has
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700241 * expired.
242 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700243 AKEY_EVENT_FLAG_CANCELED = 0x20,
244
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700245 /**
246 * This key event was generated by a virtual (on-screen) hard key area.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700247 * Typically this is an area of the touchscreen, outside of the regular
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700248 * display, dedicated to "hardware" buttons.
249 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700250 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
251
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700252 /**
253 * This flag is set for the first key repeat that occurs after the
254 * long press timeout.
255 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700256 AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
257
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700258 /**
259 * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
260 * press action was executed while it was down.
261 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700262 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
263
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700264 /**
265 * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700266 * tracked from its initial down. That is, somebody requested that tracking
267 * started on the key down and a long press has not caused
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700268 * the tracking to be canceled.
269 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700270 AKEY_EVENT_FLAG_TRACKING = 0x200,
271
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700272 /**
273 * Set when a key event has been synthesized to implement default behavior
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700274 * for an event that the application did not handle.
275 * Fallback key events are generated by unhandled trackball motions
276 * (to emulate a directional keypad) and by certain unhandled key presses
277 * that are declared in the key map (such as special function numeric keypad
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700278 * keys when numlock is off).
279 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700280 AKEY_EVENT_FLAG_FALLBACK = 0x400,
281};
282
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700283/**
284 * Bit shift for the action bits holding the pointer index as
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700285 * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
286 */
287#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
288
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700289/** Motion event actions */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700290enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700291 /** Bit mask of the parts of the action code that are the action itself. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700292 AMOTION_EVENT_ACTION_MASK = 0xff,
293
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700294 /**
295 * Bits in the action code that represent a pointer index, used with
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700296 * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
297 * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
298 * index where the data for the pointer going up or down can be found.
299 */
300 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
301
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700302 /** A pressed gesture has started, the motion contains the initial starting location. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700303 AMOTION_EVENT_ACTION_DOWN = 0,
304
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700305 /**
306 * A pressed gesture has finished, the motion contains the final release location
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700307 * as well as any intermediate points since the last down or move event.
308 */
309 AMOTION_EVENT_ACTION_UP = 1,
310
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700311 /**
312 * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700313 * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
314 * any intermediate points since the last down or move event.
315 */
316 AMOTION_EVENT_ACTION_MOVE = 2,
317
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700318 /**
319 * The current gesture has been aborted.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700320 * You will not receive any more points in it. You should treat this as
321 * an up event, but not perform any action that you normally would.
322 */
323 AMOTION_EVENT_ACTION_CANCEL = 3,
324
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700325 /**
326 * A movement has happened outside of the normal bounds of the UI element.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700327 * This does not provide a full gesture, but only the initial location of the movement/touch.
328 */
329 AMOTION_EVENT_ACTION_OUTSIDE = 4,
330
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700331 /**
332 * A non-primary pointer has gone down.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700333 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
334 */
335 AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
336
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700337 /**
338 * A non-primary pointer has gone up.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700339 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
340 */
341 AMOTION_EVENT_ACTION_POINTER_UP = 6,
342
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700343 /**
344 * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700345 * The motion contains the most recent point, as well as any intermediate points since
346 * the last hover move event.
347 */
348 AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
349
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700350 /**
351 * The motion event contains relative vertical and/or horizontal scroll offsets.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700352 * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
353 * and AMOTION_EVENT_AXIS_HSCROLL.
354 * The pointer may or may not be down when this event is dispatched.
355 * This action is always delivered to the winder under the pointer, which
356 * may not be the window currently touched.
357 */
358 AMOTION_EVENT_ACTION_SCROLL = 8,
359
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700360 /** The pointer is not down but has entered the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700361 AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
362
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700363 /** The pointer is not down but has exited the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700364 AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
Michael Wright7b159c92015-05-14 14:48:03 +0100365
366 /* One or more buttons have been pressed. */
367 AMOTION_EVENT_ACTION_BUTTON_PRESS = 11,
368
369 /* One or more buttons have been released. */
370 AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700371};
372
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700373/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700374 * Motion event flags.
375 */
376enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700377 /**
378 * This flag indicates that the window that received this motion event is partly
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700379 * or wholly obscured by another visible window above it. This flag is set to true
380 * even if the event did not directly pass through the obscured area.
381 * A security sensitive application can check this flag to identify situations in which
382 * a malicious application may have covered up part of its content for the purpose
383 * of misleading the user or hijacking touches. An appropriate response might be
384 * to drop the suspect touches or to take additional precautions to confirm the user's
385 * actual intent.
386 */
387 AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
388};
389
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700390/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700391 * Motion event edge touch flags.
392 */
393enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700394 /** No edges intersected. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700395 AMOTION_EVENT_EDGE_FLAG_NONE = 0,
396
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700397 /** Flag indicating the motion event intersected the top edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700398 AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
399
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700400 /** Flag indicating the motion event intersected the bottom edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700401 AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
402
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700403 /** Flag indicating the motion event intersected the left edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700404 AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
405
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700406 /** Flag indicating the motion event intersected the right edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700407 AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
408};
409
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700410/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700411 * Constants that identify each individual axis of a motion event.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700412 * @anchor AMOTION_EVENT_AXIS
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700413 */
414enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700415 /**
416 * Axis constant: X axis of a motion event.
417 *
418 * - For a touch screen, reports the absolute X screen position of the center of
419 * the touch contact area. The units are display pixels.
420 * - For a touch pad, reports the absolute X surface position of the center of the touch
421 * contact area. The units are device-dependent.
422 * - For a mouse, reports the absolute X screen position of the mouse pointer.
423 * The units are display pixels.
424 * - For a trackball, reports the relative horizontal displacement of the trackball.
425 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
426 * - For a joystick, reports the absolute X position of the joystick.
427 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
428 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700429 AMOTION_EVENT_AXIS_X = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700430 /**
431 * Axis constant: Y axis of a motion event.
432 *
433 * - For a touch screen, reports the absolute Y screen position of the center of
434 * the touch contact area. The units are display pixels.
435 * - For a touch pad, reports the absolute Y surface position of the center of the touch
436 * contact area. The units are device-dependent.
437 * - For a mouse, reports the absolute Y screen position of the mouse pointer.
438 * The units are display pixels.
439 * - For a trackball, reports the relative vertical displacement of the trackball.
440 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
441 * - For a joystick, reports the absolute Y position of the joystick.
442 * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
443 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700444 AMOTION_EVENT_AXIS_Y = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700445 /**
446 * Axis constant: Pressure axis of a motion event.
447 *
448 * - For a touch screen or touch pad, reports the approximate pressure applied to the surface
449 * by a finger or other tool. The value is normalized to a range from
450 * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
451 * may be generated depending on the calibration of the input device.
452 * - For a trackball, the value is set to 1 if the trackball button is pressed
453 * or 0 otherwise.
454 * - For a mouse, the value is set to 1 if the primary mouse button is pressed
455 * or 0 otherwise.
456 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700457 AMOTION_EVENT_AXIS_PRESSURE = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700458 /**
459 * Axis constant: Size axis of a motion event.
460 *
461 * - For a touch screen or touch pad, reports the approximate size of the contact area in
462 * relation to the maximum detectable size for the device. The value is normalized
463 * to a range from 0 (smallest detectable size) to 1 (largest detectable size),
464 * although it is not a linear scale. This value is of limited use.
465 * To obtain calibrated size information, see
466 * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}.
467 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700468 AMOTION_EVENT_AXIS_SIZE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700469 /**
470 * Axis constant: TouchMajor axis of a motion event.
471 *
472 * - For a touch screen, reports the length of the major axis of an ellipse that
473 * represents the touch area at the point of contact.
474 * The units are display pixels.
475 * - For a touch pad, reports the length of the major axis of an ellipse that
476 * represents the touch area at the point of contact.
477 * The units are device-dependent.
478 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700479 AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700480 /**
481 * Axis constant: TouchMinor axis of a motion event.
482 *
483 * - For a touch screen, reports the length of the minor axis of an ellipse that
484 * represents the touch area at the point of contact.
485 * The units are display pixels.
486 * - For a touch pad, reports the length of the minor axis of an ellipse that
487 * represents the touch area at the point of contact.
488 * The units are device-dependent.
489 *
490 * When the touch is circular, the major and minor axis lengths will be equal to one another.
491 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700492 AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700493 /**
494 * Axis constant: ToolMajor axis of a motion event.
495 *
496 * - For a touch screen, reports the length of the major axis of an ellipse that
497 * represents the size of the approaching finger or tool used to make contact.
498 * - For a touch pad, reports the length of the major axis of an ellipse that
499 * represents the size of the approaching finger or tool used to make contact.
500 * The units are device-dependent.
501 *
502 * When the touch is circular, the major and minor axis lengths will be equal to one another.
503 *
504 * The tool size may be larger than the touch size since the tool may not be fully
505 * in contact with the touch sensor.
506 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700507 AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700508 /**
509 * Axis constant: ToolMinor axis of a motion event.
510 *
511 * - For a touch screen, reports the length of the minor axis of an ellipse that
512 * represents the size of the approaching finger or tool used to make contact.
513 * - For a touch pad, reports the length of the minor axis of an ellipse that
514 * represents the size of the approaching finger or tool used to make contact.
515 * The units are device-dependent.
516 *
517 * When the touch is circular, the major and minor axis lengths will be equal to one another.
518 *
519 * The tool size may be larger than the touch size since the tool may not be fully
520 * in contact with the touch sensor.
521 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700522 AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700523 /**
524 * Axis constant: Orientation axis of a motion event.
525 *
526 * - For a touch screen or touch pad, reports the orientation of the finger
527 * or tool in radians relative to the vertical plane of the device.
528 * An angle of 0 radians indicates that the major axis of contact is oriented
529 * upwards, is perfectly circular or is of unknown orientation. A positive angle
530 * indicates that the major axis of contact is oriented to the right. A negative angle
531 * indicates that the major axis of contact is oriented to the left.
532 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
533 * (finger pointing fully right).
534 * - For a stylus, the orientation indicates the direction in which the stylus
535 * is pointing in relation to the vertical axis of the current orientation of the screen.
536 * The range is from -PI radians to PI radians, where 0 is pointing up,
537 * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
538 * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}.
539 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700540 AMOTION_EVENT_AXIS_ORIENTATION = 8,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700541 /**
542 * Axis constant: Vertical Scroll axis of a motion event.
543 *
544 * - For a mouse, reports the relative movement of the vertical scroll wheel.
545 * The value is normalized to a range from -1.0 (down) to 1.0 (up).
546 *
547 * This axis should be used to scroll views vertically.
548 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700549 AMOTION_EVENT_AXIS_VSCROLL = 9,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700550 /**
551 * Axis constant: Horizontal Scroll axis of a motion event.
552 *
553 * - For a mouse, reports the relative movement of the horizontal scroll wheel.
554 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
555 *
556 * This axis should be used to scroll views horizontally.
557 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700558 AMOTION_EVENT_AXIS_HSCROLL = 10,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700559 /**
560 * Axis constant: Z axis of a motion event.
561 *
562 * - For a joystick, reports the absolute Z position of the joystick.
563 * The value is normalized to a range from -1.0 (high) to 1.0 (low).
564 * <em>On game pads with two analog joysticks, this axis is often reinterpreted
565 * to report the absolute X position of the second joystick instead.</em>
566 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700567 AMOTION_EVENT_AXIS_Z = 11,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700568 /**
569 * Axis constant: X Rotation axis of a motion event.
570 *
571 * - For a joystick, reports the absolute rotation angle about the X 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_RX = 12,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700575 /**
576 * Axis constant: Y Rotation axis of a motion event.
577 *
578 * - For a joystick, reports the absolute rotation angle about the Y axis.
579 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
580 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700581 AMOTION_EVENT_AXIS_RY = 13,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700582 /**
583 * Axis constant: Z Rotation axis of a motion event.
584 *
585 * - For a joystick, reports the absolute rotation angle about the Z axis.
586 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
587 * On game pads with two analog joysticks, this axis is often reinterpreted
588 * to report the absolute Y position of the second joystick instead.
589 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700590 AMOTION_EVENT_AXIS_RZ = 14,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700591 /**
592 * Axis constant: Hat X axis of a motion event.
593 *
594 * - For a joystick, reports the absolute X position of the directional hat control.
595 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
596 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700597 AMOTION_EVENT_AXIS_HAT_X = 15,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700598 /**
599 * Axis constant: Hat Y axis of a motion event.
600 *
601 * - For a joystick, reports the absolute Y position of the directional hat control.
602 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
603 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700604 AMOTION_EVENT_AXIS_HAT_Y = 16,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700605 /**
606 * Axis constant: Left Trigger axis of a motion event.
607 *
608 * - For a joystick, reports the absolute position of the left 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_LTRIGGER = 17,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700612 /**
613 * Axis constant: Right Trigger axis of a motion event.
614 *
615 * - For a joystick, reports the absolute position of the right trigger control.
616 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
617 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700618 AMOTION_EVENT_AXIS_RTRIGGER = 18,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700619 /**
620 * Axis constant: Throttle axis of a motion event.
621 *
622 * - For a joystick, reports the absolute position of the throttle control.
623 * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
624 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700625 AMOTION_EVENT_AXIS_THROTTLE = 19,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700626 /**
627 * Axis constant: Rudder axis of a motion event.
628 *
629 * - For a joystick, reports the absolute position of the rudder 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_RUDDER = 20,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700633 /**
634 * Axis constant: Wheel axis of a motion event.
635 *
636 * - For a joystick, reports the absolute position of the steering wheel control.
637 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
638 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700639 AMOTION_EVENT_AXIS_WHEEL = 21,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700640 /**
641 * Axis constant: Gas axis of a motion event.
642 *
643 * - For a joystick, reports the absolute position of the gas (accelerator) control.
644 * The value is normalized to a range from 0.0 (no acceleration)
645 * to 1.0 (maximum acceleration).
646 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700647 AMOTION_EVENT_AXIS_GAS = 22,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700648 /**
649 * Axis constant: Brake axis of a motion event.
650 *
651 * - For a joystick, reports the absolute position of the brake control.
652 * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
653 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700654 AMOTION_EVENT_AXIS_BRAKE = 23,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700655 /**
656 * Axis constant: Distance axis of a motion event.
657 *
658 * - For a stylus, reports the distance of the stylus from the screen.
659 * A value of 0.0 indicates direct contact and larger values indicate increasing
660 * distance from the surface.
661 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700662 AMOTION_EVENT_AXIS_DISTANCE = 24,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700663 /**
664 * Axis constant: Tilt axis of a motion event.
665 *
666 * - For a stylus, reports the tilt angle of the stylus in radians where
667 * 0 radians indicates that the stylus is being held perpendicular to the
668 * surface, and PI/2 radians indicates that the stylus is being held flat
669 * against the surface.
670 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700671 AMOTION_EVENT_AXIS_TILT = 25,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700672 /**
Prashant Malani1941ff52015-08-11 18:29:28 -0700673 * Axis constant: Generic scroll axis of a motion event.
674 *
675 * - This is used for scroll axis motion events that can't be classified as strictly
676 * vertical or horizontal. The movement of a rotating scroller is an example of this.
677 */
678 AMOTION_EVENT_AXIS_SCROLL = 26,
679 /**
Jun Mukaifa1706a2015-12-03 01:14:46 -0800680 * Axis constant: The movement of x position of a motion event.
681 *
682 * - For a mouse, reports a difference of x position between the previous position.
683 * This is useful when pointer is captured, in that case the mouse pointer doesn't
684 * change the location but this axis reports the difference which allows the app
685 * to see how the mouse is moved.
686 */
687 AMOTION_EVENT_AXIS_RELATIVE_X = 27,
688 /**
689 * Axis constant: The movement of y position of a motion event.
690 *
Siarhei Vishniakou2745c952021-03-17 20:27:41 +0000691 * Same as {@link AMOTION_EVENT_AXIS_RELATIVE_X}, but for y position.
Jun Mukaifa1706a2015-12-03 01:14:46 -0800692 */
693 AMOTION_EVENT_AXIS_RELATIVE_Y = 28,
694 /**
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700695 * Axis constant: Generic 1 axis of a motion event.
696 * The interpretation of a generic axis is device-specific.
697 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700698 AMOTION_EVENT_AXIS_GENERIC_1 = 32,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700699 /**
700 * Axis constant: Generic 2 axis of a motion event.
701 * The interpretation of a generic axis is device-specific.
702 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700703 AMOTION_EVENT_AXIS_GENERIC_2 = 33,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700704 /**
705 * Axis constant: Generic 3 axis of a motion event.
706 * The interpretation of a generic axis is device-specific.
707 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700708 AMOTION_EVENT_AXIS_GENERIC_3 = 34,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700709 /**
710 * Axis constant: Generic 4 axis of a motion event.
711 * The interpretation of a generic axis is device-specific.
712 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700713 AMOTION_EVENT_AXIS_GENERIC_4 = 35,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700714 /**
715 * Axis constant: Generic 5 axis of a motion event.
716 * The interpretation of a generic axis is device-specific.
717 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700718 AMOTION_EVENT_AXIS_GENERIC_5 = 36,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700719 /**
720 * Axis constant: Generic 6 axis of a motion event.
721 * The interpretation of a generic axis is device-specific.
722 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700723 AMOTION_EVENT_AXIS_GENERIC_6 = 37,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700724 /**
725 * Axis constant: Generic 7 axis of a motion event.
726 * The interpretation of a generic axis is device-specific.
727 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700728 AMOTION_EVENT_AXIS_GENERIC_7 = 38,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700729 /**
730 * Axis constant: Generic 8 axis of a motion event.
731 * The interpretation of a generic axis is device-specific.
732 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700733 AMOTION_EVENT_AXIS_GENERIC_8 = 39,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700734 /**
735 * Axis constant: Generic 9 axis of a motion event.
736 * The interpretation of a generic axis is device-specific.
737 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700738 AMOTION_EVENT_AXIS_GENERIC_9 = 40,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700739 /**
740 * Axis constant: Generic 10 axis of a motion event.
741 * The interpretation of a generic axis is device-specific.
742 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700743 AMOTION_EVENT_AXIS_GENERIC_10 = 41,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700744 /**
745 * Axis constant: Generic 11 axis of a motion event.
746 * The interpretation of a generic axis is device-specific.
747 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700748 AMOTION_EVENT_AXIS_GENERIC_11 = 42,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700749 /**
750 * Axis constant: Generic 12 axis of a motion event.
751 * The interpretation of a generic axis is device-specific.
752 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700753 AMOTION_EVENT_AXIS_GENERIC_12 = 43,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700754 /**
755 * Axis constant: Generic 13 axis of a motion event.
756 * The interpretation of a generic axis is device-specific.
757 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700758 AMOTION_EVENT_AXIS_GENERIC_13 = 44,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700759 /**
760 * Axis constant: Generic 14 axis of a motion event.
761 * The interpretation of a generic axis is device-specific.
762 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700763 AMOTION_EVENT_AXIS_GENERIC_14 = 45,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700764 /**
765 * Axis constant: Generic 15 axis of a motion event.
766 * The interpretation of a generic axis is device-specific.
767 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700768 AMOTION_EVENT_AXIS_GENERIC_15 = 46,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700769 /**
770 * Axis constant: Generic 16 axis of a motion event.
771 * The interpretation of a generic axis is device-specific.
772 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700773 AMOTION_EVENT_AXIS_GENERIC_16 = 47,
774
775 // NOTE: If you add a new axis here you must also add it to several other files.
776 // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
777};
778
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700779/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700780 * Constants that identify buttons that are associated with motion events.
781 * Refer to the documentation on the MotionEvent class for descriptions of each button.
782 */
783enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700784 /** primary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700785 AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700786 /** secondary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700787 AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700788 /** tertiary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700789 AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700790 /** back */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700791 AMOTION_EVENT_BUTTON_BACK = 1 << 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700792 /** forward */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700793 AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
Michael Wright7b159c92015-05-14 14:48:03 +0100794 AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
795 AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700796};
797
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700798/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700799 * Constants that identify tool types.
800 * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
801 */
802enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700803 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700804 AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700805 /** finger */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700806 AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700807 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700808 AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700809 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700810 AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700811 /** eraser */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700812 AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
Arthur Hung421eb1c2020-01-16 00:09:42 +0800813 /** palm */
814 AMOTION_EVENT_TOOL_TYPE_PALM = 5,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700815};
816
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700817/**
Vaibhav8576dd72022-02-11 18:19:06 +0530818 * Constants that identify different gesture classification types.
819 */
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +0000820enum AMotionClassification : uint32_t {
Vaibhav8576dd72022-02-11 18:19:06 +0530821 /**
822 * Classification constant: None.
823 *
824 * No additional information is available about the current motion event stream.
825 */
826 AMOTION_EVENT_CLASSIFICATION_NONE = 0,
827 /**
828 * Classification constant: Ambiguous gesture.
829 *
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +0000830 * The user's intent with respect to the current event stream is not yet determined. Events
831 * starting in AMBIGUOUS_GESTURE will eventually resolve into either DEEP_PRESS or NONE.
Vaibhav8576dd72022-02-11 18:19:06 +0530832 * Gestural actions, such as scrolling, should be inhibited until the classification resolves
833 * to another value or the event stream ends.
834 */
835 AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE = 1,
836 /**
837 * Classification constant: Deep press.
838 *
839 * The current event stream represents the user intentionally pressing harder on the screen.
840 * This classification type should be used to accelerate the long press behaviour.
841 */
842 AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS = 2,
Harry Cutts2800fb02022-09-15 13:49:23 +0000843 /**
844 * Classification constant: touchpad two-finger swipe.
845 *
846 * The current event stream represents the user swiping with two fingers on a touchpad.
847 */
848 AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE = 3,
Vaibhav8576dd72022-02-11 18:19:06 +0530849};
850
851/**
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700852 * Input source masks.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700853 *
854 * Refer to the documentation on android.view.InputDevice for more details about input sources
855 * and their correct interpretation.
856 */
857enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700858 /** mask */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700859 AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
860
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700861 /** none */
Michael Wrightaadaca72013-03-11 14:20:14 -0700862 AINPUT_SOURCE_CLASS_NONE = 0x00000000,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700863 /** button */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700864 AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700865 /** pointer */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700866 AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700867 /** navigation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700868 AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700869 /** position */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700870 AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700871 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700872 AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
873};
874
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700875/**
876 * Input sources.
877 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700878enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700879 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700880 AINPUT_SOURCE_UNKNOWN = 0x00000000,
881
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700882 /** keyboard */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700883 AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700884 /** dpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700885 AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700886 /** gamepad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700887 AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700888 /** touchscreen */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700889 AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700890 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700891 AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700892 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700893 AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
Michael Wright7d3ad692015-06-23 19:04:31 +0100894 /** bluetooth stylus */
Michael Wright2f78b682015-06-12 15:25:08 +0100895 AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700896 /** trackball */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700897 AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Vladislav Kaznacheev78f97b32016-12-15 18:14:58 -0800898 /** mouse relative */
899 AINPUT_SOURCE_MOUSE_RELATIVE = 0x00020000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700900 /** touchpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700901 AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700902 /** navigation */
Michael Wrightaadaca72013-03-11 14:20:14 -0700903 AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700904 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700905 AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
Chris Ye02303442021-01-26 13:21:01 -0800906 /** HDMI */
907 AINPUT_SOURCE_HDMI = 0x02000000 | AINPUT_SOURCE_CLASS_BUTTON,
Chris Yef59a2f42020-10-16 12:55:26 -0700908 /** sensor */
Chris Ye3fdbfef2021-01-06 18:45:18 -0800909 AINPUT_SOURCE_SENSOR = 0x04000000 | AINPUT_SOURCE_CLASS_NONE,
Prashant Malani1941ff52015-08-11 18:29:28 -0700910 /** rotary encoder */
911 AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700912
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700913 /** any */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700914 AINPUT_SOURCE_ANY = 0xffffff00,
915};
916
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700917/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700918 * Keyboard types.
919 *
920 * Refer to the documentation on android.view.InputDevice for more details.
Philip Junkerf8437962022-01-25 21:20:19 +0100921 * Note: When adding a new keyboard type here InputDeviceInfo::setKeyboardType needs to be updated.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700922 */
923enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700924 /** none */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700925 AINPUT_KEYBOARD_TYPE_NONE = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700926 /** non alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700927 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700928 /** alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700929 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
930};
931
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700932/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700933 * Constants used to retrieve information about the range of motion for a particular
934 * coordinate of a motion event.
935 *
936 * Refer to the documentation on android.view.InputDevice for more details about input sources
937 * and their correct interpretation.
938 *
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700939 * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700940 */
941enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700942 /** x */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700943 AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700944 /** y */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700945 AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700946 /** pressure */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700947 AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700948 /** size */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700949 AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700950 /** touch major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700951 AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700952 /** touch minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700953 AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700954 /** tool major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700955 AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700956 /** tool minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700957 AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700958 /** orientation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700959 AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700960};
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700961
962
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700963/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700964 * Input event accessors.
965 *
966 * Note that most functions can only be used on input events that are of a given type.
967 * Calling these functions on input events of other types will yield undefined behavior.
968 */
969
970/*** Accessors for all input events. ***/
971
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700972/** Get the input event type. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700973int32_t AInputEvent_getType(const AInputEvent* event);
974
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700975/** Get the id for the device that an input event came from.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700976 *
977 * Input events can be generated by multiple different input devices.
978 * Use the input device id to obtain information about the input
979 * device that was responsible for generating a particular event.
980 *
981 * An input device id of 0 indicates that the event didn't come from a physical device;
982 * other numbers are arbitrary and you shouldn't depend on the values.
983 * Use the provided input device query API to obtain information about input devices.
984 */
985int32_t AInputEvent_getDeviceId(const AInputEvent* event);
986
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700987/** Get the input event source. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700988int32_t AInputEvent_getSource(const AInputEvent* event);
989
Chris Ye1aaa2122020-04-07 19:38:15 -0700990/**
991 * Releases interface objects created by {@link AKeyEvent_fromJava()}
992 * and {@link AMotionEvent_fromJava()}.
993 * After returning, the specified AInputEvent* object becomes invalid and should no longer be used.
994 * The underlying Java object remains valid and does not change its state.
Elliott Hughesdbfde642021-09-14 10:31:47 -0700995 *
996 * Available since API level 31.
Chris Ye1aaa2122020-04-07 19:38:15 -0700997 */
Elliott Hughesdbfde642021-09-14 10:31:47 -0700998void AInputEvent_release(const AInputEvent* event) __INTRODUCED_IN(31);
Chris Ye1aaa2122020-04-07 19:38:15 -0700999
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001000/*** Accessors for key events only. ***/
1001
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001002/** Get the key event action. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001003int32_t AKeyEvent_getAction(const AInputEvent* key_event);
1004
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001005/** Get the key event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001006int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
1007
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001008/**
1009 * Get the key code of the key event.
1010 * This is the physical key that was pressed, not the Unicode character.
1011 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001012int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
1013
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001014/**
1015 * Get the hardware key id of this key event.
1016 * These values are not reliable and vary from device to device.
1017 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001018int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
1019
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001020/** Get the meta key state. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001021int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
1022
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001023/**
1024 * Get the repeat count of the event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001025 * For both key up an key down events, this is the number of times the key has
1026 * repeated with the first down starting at 0 and counting up from there. For
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001027 * multiple key events, this is the number of down/up pairs that have occurred.
1028 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001029int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
1030
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001031/**
1032 * Get the time of the most recent key down event, in the
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001033 * java.lang.System.nanoTime() time base. If this is a down event,
1034 * this will be the same as eventTime.
1035 * Note that when chording keys, this value is the down time of the most recently
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001036 * pressed key, which may not be the same physical key of this event.
1037 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001038int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
1039
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001040/**
1041 * Get the time this event occurred, in the
1042 * java.lang.System.nanoTime() time base.
1043 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001044int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
1045
Chris Ye1aaa2122020-04-07 19:38:15 -07001046/**
Siarhei Vishniakoua53d8652020-08-13 23:59:50 -05001047 * Creates a native AInputEvent* object that is a copy of the specified Java android.view.KeyEvent.
1048 * The result may be used with generic and KeyEvent-specific AInputEvent_* functions. The object
1049 * returned by this function must be disposed using {@link AInputEvent_release()}.
Elliott Hughesdbfde642021-09-14 10:31:47 -07001050 *
1051 * Available since API level 31.
Chris Ye1aaa2122020-04-07 19:38:15 -07001052 */
Elliott Hughesdbfde642021-09-14 10:31:47 -07001053const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent) __INTRODUCED_IN(31);
Chris Ye1aaa2122020-04-07 19:38:15 -07001054
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001055/*** Accessors for motion events only. ***/
1056
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001057/** Get the combined motion event action code and pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001058int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
1059
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001060/** Get the motion event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001061int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
1062
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001063/**
1064 * Get the state of any meta / modifier keys that were in effect when the
1065 * event was generated.
1066 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001067int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
1068
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001069/** Get the button state of all buttons that are pressed. */
Elliott Hughes3d70e532019-10-29 08:59:39 -07001070int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001071
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001072/**
1073 * Get a bitfield indicating which edges, if any, were touched by this motion event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001074 * For touch events, clients can use this to determine if the user's finger was
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001075 * touching the edge of the display.
1076 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001077int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
1078
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001079/**
1080 * Get the time when the user originally pressed down to start a stream of
1081 * position events, in the java.lang.System.nanoTime() time base.
1082 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001083int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
1084
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001085/**
1086 * Get the time when this specific event was generated,
1087 * in the java.lang.System.nanoTime() time base.
1088 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001089int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
1090
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001091/**
1092 * Get the X coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001093 * For touch events on the screen, this is the delta that was added to the raw
1094 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001095 * and views.
1096 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001097float AMotionEvent_getXOffset(const AInputEvent* motion_event);
1098
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001099/**
1100 * Get the Y coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001101 * For touch events on the screen, this is the delta that was added to the raw
1102 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001103 * and views.
1104 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001105float AMotionEvent_getYOffset(const AInputEvent* motion_event);
1106
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001107/**
1108 * Get the precision of the X coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001109 * You can multiply this number with an X coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001110 * actual hardware value of the X coordinate.
1111 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001112float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
1113
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001114/**
1115 * Get the precision of the Y coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001116 * You can multiply this number with a Y coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001117 * actual hardware value of the Y coordinate.
1118 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001119float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
1120
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001121/**
1122 * Get the number of pointers of data contained in this event.
1123 * Always >= 1.
1124 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001125size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
1126
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001127/**
1128 * Get the pointer identifier associated with a particular pointer
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001129 * data index in this event. The identifier tells you the actual pointer
1130 * number associated with the data, accounting for individual pointers
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001131 * going up and down since the start of the current gesture.
1132 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001133int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
1134
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001135/**
1136 * Get the tool type of a pointer for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001137 * The tool type indicates the type of tool used to make contact such as a
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001138 * finger or stylus, if known.
1139 */
Elliott Hughes3d70e532019-10-29 08:59:39 -07001140int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001141
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001142/**
1143 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001144 * For touch events on the screen, this is the original location of the event
1145 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001146 * and views.
1147 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001148float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
1149
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001150/**
1151 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001152 * For touch events on the screen, this is the original location of the event
1153 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001154 * and views.
1155 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001156float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
1157
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001158/**
1159 * Get the current X coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001160 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001161 * that are sub-pixel precise.
1162 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001163float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
1164
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001165/**
1166 * Get the current Y coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001167 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001168 * that are sub-pixel precise.
1169 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001170float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
1171
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001172/**
1173 * Get the current pressure of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001174 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1175 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001176 * the input device.
1177 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001178float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
1179
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001180/**
1181 * Get the current scaled value of the approximate size for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001182 * This represents some approximation of the area of the screen being
1183 * pressed; the actual value in pixels corresponding to the
1184 * touch is normalized with the device specific range of values
1185 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001186 * determine fat touch events.
1187 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001188float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
1189
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001190/**
1191 * Get the current length of the major axis of an ellipse that describes the touch area
1192 * at the point of contact for the given pointer index.
1193 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001194float AMotionEvent_getTouchMajor(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 touch area
1198 * at the point of contact for the given pointer index.
1199 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001200float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
1201
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001202/**
1203 * Get the current length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001204 * of the approaching tool for the given pointer index.
1205 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001206 * touching the device independent of its actual touch area at the point of contact.
1207 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001208float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
1209
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001210/**
1211 * Get the current length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001212 * of the approaching tool for the given pointer index.
1213 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001214 * touching the device independent of its actual touch area at the point of contact.
1215 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001216float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
1217
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001218/**
1219 * Get the current orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001220 * vertical for the given pointer index.
1221 * An angle of 0 degrees indicates that the major axis of contact is oriented
1222 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1223 * indicates that the major axis of contact is oriented to the right. A negative angle
1224 * indicates that the major axis of contact is oriented to the left.
1225 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001226 * (finger pointing fully right).
1227 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001228float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
1229
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001230/** Get the value of the request axis for the given pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001231float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001232 int32_t axis, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001233
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001234/**
1235 * Get the number of historical points in this event. These are movements that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001236 * have occurred between this event and the previous event. This only applies
1237 * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001238 * Historical samples are indexed from oldest to newest.
1239 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001240size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
1241
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001242/**
1243 * Get the time that a historical movement occurred between this event and
1244 * the previous event, in the java.lang.System.nanoTime() time base.
1245 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001246int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001247 size_t history_index);
1248
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001249/**
1250 * Get the historical raw X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001251 * occurred between this event and the previous motion event.
1252 * For touch events on the screen, this is the original location of the event
1253 * on the screen, before it had been adjusted for the containing window
1254 * and views.
1255 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001256 * that are sub-pixel precise.
1257 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001258float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
1259 size_t history_index);
1260
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001261/**
1262 * Get the historical raw Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001263 * occurred between this event and the previous motion event.
1264 * For touch events on the screen, this is the original location of the event
1265 * on the screen, before it had been adjusted for the containing window
1266 * and views.
1267 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001268 * that are sub-pixel precise.
1269 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001270float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
1271 size_t history_index);
1272
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001273/**
1274 * Get the historical X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001275 * occurred between this event and the previous motion event.
1276 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001277 * that are sub-pixel precise.
1278 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001279float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001280 size_t history_index);
1281
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001282/**
1283 * Get the historical Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001284 * occurred between this event and the previous motion event.
1285 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001286 * that are sub-pixel precise.
1287 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001288float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001289 size_t history_index);
1290
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001291/**
1292 * Get the historical pressure of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001293 * occurred between this event and the previous motion event.
1294 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1295 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001296 * the input device.
1297 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001298float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001299 size_t history_index);
1300
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001301/**
1302 * Get the current scaled value of the approximate size for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001303 * occurred between this event and the previous motion event.
1304 * This represents some approximation of the area of the screen being
1305 * pressed; the actual value in pixels corresponding to the
1306 * touch is normalized with the device specific range of values
1307 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001308 * determine fat touch events.
1309 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001310float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001311 size_t history_index);
1312
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001313/**
1314 * Get the historical length of the major axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001315 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001316 * occurred between this event and the previous motion event.
1317 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001318float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
1319 size_t history_index);
1320
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001321/**
1322 * Get the historical length of the minor axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001323 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001324 * occurred between this event and the previous motion event.
1325 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001326float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
1327 size_t history_index);
1328
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001329/**
1330 * Get the historical length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001331 * of the approaching tool for the given pointer index that
1332 * occurred between this event and the previous motion event.
1333 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001334 * touching the device independent of its actual touch area at the point of contact.
1335 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001336float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
1337 size_t history_index);
1338
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001339/**
1340 * Get the historical length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001341 * of the approaching tool for the given pointer index that
1342 * occurred between this event and the previous motion event.
1343 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001344 * touching the device independent of its actual touch area at the point of contact.
1345 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001346float AMotionEvent_getHistoricalToolMinor(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 orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001351 * vertical for the given pointer index that
1352 * occurred between this event and the previous motion event.
1353 * An angle of 0 degrees indicates that the major axis of contact is oriented
1354 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1355 * indicates that the major axis of contact is oriented to the right. A negative angle
1356 * indicates that the major axis of contact is oriented to the left.
1357 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001358 * (finger pointing fully right).
1359 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001360float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
1361 size_t history_index);
1362
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001363/**
1364 * Get the historical value of the request axis for the given pointer index
1365 * that occurred between this event and the previous motion event.
1366 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001367float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001368 int32_t axis, size_t pointer_index, size_t history_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001369
Chris Ye1aaa2122020-04-07 19:38:15 -07001370/**
Vaibhav8576dd72022-02-11 18:19:06 +05301371 * Get the action button for the motion event. Returns a valid action button when the
1372 * event is associated with a button press or button release action. For other actions
1373 * the return value is undefined.
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +00001374 *
1375 * @see #AMOTION_EVENT_BUTTON_PRIMARY
1376 * @see #AMOTION_EVENT_BUTTON_SECONDARY
1377 * @see #AMOTION_EVENT_BUTTON_TERTIARY
1378 * @see #AMOTION_EVENT_BUTTON_BACK
1379 * @see #AMOTION_EVENT_BUTTON_FORWARD
1380 * @see #AMOTION_EVENT_BUTTON_STYLUS_PRIMARY
1381 * @see #AMOTION_EVENT_BUTTON_STYLUS_SECONDARY
Vaibhav8576dd72022-02-11 18:19:06 +05301382 */
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +00001383int32_t AMotionEvent_getActionButton(const AInputEvent* motion_event)
1384 __INTRODUCED_IN(__ANDROID_API_T__);
Vaibhav8576dd72022-02-11 18:19:06 +05301385
1386/**
1387 * Returns the classification for the current gesture.
1388 * The classification may change as more events become available for the same gesture.
1389 *
1390 * @see #AMOTION_EVENT_CLASSIFICATION_NONE
1391 * @see #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE
1392 * @see #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS
1393*/
Vaibhav Devmurari38fae2a2022-03-17 14:21:39 +00001394int32_t AMotionEvent_getClassification(const AInputEvent* motion_event)
1395 __INTRODUCED_IN(__ANDROID_API_T__);
Vaibhav8576dd72022-02-11 18:19:06 +05301396
1397/**
Siarhei Vishniakoua53d8652020-08-13 23:59:50 -05001398 * Creates a native AInputEvent* object that is a copy of the specified Java
1399 * android.view.MotionEvent. The result may be used with generic and MotionEvent-specific
1400 * AInputEvent_* functions. The object returned by this function must be disposed using
1401 * {@link AInputEvent_release()}.
Elliott Hughesdbfde642021-09-14 10:31:47 -07001402 *
1403 * Available since API level 31.
Chris Ye1aaa2122020-04-07 19:38:15 -07001404 */
Elliott Hughesdbfde642021-09-14 10:31:47 -07001405const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) __INTRODUCED_IN(31);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001406
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001407struct AInputQueue;
1408/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001409 * Input queue
1410 *
1411 * An input queue is the facility through which you retrieve input
1412 * events.
1413 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001414typedef struct AInputQueue AInputQueue;
1415
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001416/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001417 * Add this input queue to a looper for processing. See
1418 * ALooper_addFd() for information on the ident, callback, and data params.
1419 */
1420void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
1421 int ident, ALooper_callbackFunc callback, void* data);
1422
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001423/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001424 * Remove the input queue from the looper it is currently attached to.
1425 */
1426void AInputQueue_detachLooper(AInputQueue* queue);
1427
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001428/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001429 * Returns true if there are one or more events available in the
1430 * input queue. Returns 1 if the queue has events; 0 if
1431 * it does not have events; and a negative value if there is an error.
1432 */
1433int32_t AInputQueue_hasEvents(AInputQueue* queue);
1434
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001435/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001436 * Returns the next available event from the queue. Returns a negative
1437 * value if no events are available or an error has occurred.
1438 */
1439int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
1440
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001441/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001442 * Sends the key for standard pre-dispatching -- that is, possibly deliver
1443 * it to the current IME to be consumed before the app. Returns 0 if it
1444 * was not pre-dispatched, meaning you can process it right now. If non-zero
1445 * is returned, you must abandon the current event processing and allow the
1446 * event to appear again in the event queue (if it does not get consumed during
1447 * pre-dispatching).
1448 */
1449int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
1450
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001451/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001452 * Report that dispatching has finished with the given event.
1453 * This must be called after receiving an event with AInputQueue_get_event().
1454 */
1455void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
1456
Jim Blacklera64c2722021-09-01 16:39:16 +01001457/**
Prabir Pradhan9d439742021-12-16 03:32:30 -08001458 * Returns the AInputQueue* object associated with the supplied Java InputQueue
1459 * object. The returned native object holds a weak reference to the Java object,
1460 * and is only valid as long as the Java object has not yet been disposed. You
1461 * should ensure that there is a strong reference to the Java object and that it
1462 * has not been disposed before using the returned object.
Jim Blacklera64c2722021-09-01 16:39:16 +01001463 *
1464 * Available since API level 33.
1465 */
Prabir Pradhanb1e1e392021-12-16 03:28:20 -08001466AInputQueue* AInputQueue_fromJava(JNIEnv* env, jobject inputQueue) __INTRODUCED_IN(33);
Jim Blacklera64c2722021-09-01 16:39:16 +01001467
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001468#ifdef __cplusplus
1469}
1470#endif
1471
1472#endif // _ANDROID_INPUT_H
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001473
1474/** @} */