blob: b70d42427dc11a9ed9e00e39dbc32684449722ab [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,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700169};
170
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700171/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700172 * Key event actions.
173 */
174enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700175 /** The key has been pressed down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700176 AKEY_EVENT_ACTION_DOWN = 0,
177
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700178 /** The key has been released. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700179 AKEY_EVENT_ACTION_UP = 1,
180
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700181 /**
182 * Multiple duplicate key events have occurred in a row, or a
183 * complex string is being delivered. The repeat_count property
184 * of the key event contains the number of times the given key
185 * code should be executed.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700186 */
187 AKEY_EVENT_ACTION_MULTIPLE = 2
188};
189
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700190/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700191 * Key event flags.
192 */
193enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700194 /** This mask is set if the device woke because of this key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700195 AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
196
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700197 /** This mask is set if the key event was generated by a software keyboard. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700198 AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
199
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700200 /** 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 -0700201 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
202
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700203 /**
204 * This mask is set if an event was known to come from a trusted
205 * part of the system. That is, the event is known to come from
206 * the user, and could not have been spoofed by a third party
207 * component.
208 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700209 AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
210
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700211 /**
212 * This mask is used for compatibility, to identify enter keys that are
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700213 * coming from an IME whose enter key has been auto-labelled "next" or
214 * "done". This allows TextView to dispatch these as normal enter keys
215 * for old applications, but still do the appropriate action when
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700216 * receiving them.
217 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700218 AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
219
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700220 /**
221 * When associated with up key events, this indicates that the key press
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700222 * has been canceled. Typically this is used with virtual touch screen
223 * keys, where the user can slide from the virtual key area on to the
224 * display: in that case, the application will receive a canceled up
225 * event and should not perform the action normally associated with the
226 * key. Note that for this to work, the application can not perform an
227 * action for a key until it receives an up or the long press timeout has
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700228 * expired.
229 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700230 AKEY_EVENT_FLAG_CANCELED = 0x20,
231
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700232 /**
233 * This key event was generated by a virtual (on-screen) hard key area.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700234 * Typically this is an area of the touchscreen, outside of the regular
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700235 * display, dedicated to "hardware" buttons.
236 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700237 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
238
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700239 /**
240 * This flag is set for the first key repeat that occurs after the
241 * long press timeout.
242 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700243 AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
244
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700245 /**
246 * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
247 * press action was executed while it was down.
248 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700249 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
250
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700251 /**
252 * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700253 * tracked from its initial down. That is, somebody requested that tracking
254 * started on the key down and a long press has not caused
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700255 * the tracking to be canceled.
256 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700257 AKEY_EVENT_FLAG_TRACKING = 0x200,
258
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700259 /**
260 * Set when a key event has been synthesized to implement default behavior
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700261 * for an event that the application did not handle.
262 * Fallback key events are generated by unhandled trackball motions
263 * (to emulate a directional keypad) and by certain unhandled key presses
264 * that are declared in the key map (such as special function numeric keypad
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700265 * keys when numlock is off).
266 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700267 AKEY_EVENT_FLAG_FALLBACK = 0x400,
268};
269
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700270/**
271 * Bit shift for the action bits holding the pointer index as
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700272 * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
273 */
274#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
275
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700276/** Motion event actions */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700277enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700278 /** Bit mask of the parts of the action code that are the action itself. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700279 AMOTION_EVENT_ACTION_MASK = 0xff,
280
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700281 /**
282 * Bits in the action code that represent a pointer index, used with
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700283 * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
284 * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
285 * index where the data for the pointer going up or down can be found.
286 */
287 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
288
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700289 /** A pressed gesture has started, the motion contains the initial starting location. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700290 AMOTION_EVENT_ACTION_DOWN = 0,
291
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700292 /**
293 * A pressed gesture has finished, the motion contains the final release location
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700294 * as well as any intermediate points since the last down or move event.
295 */
296 AMOTION_EVENT_ACTION_UP = 1,
297
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700298 /**
299 * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700300 * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
301 * any intermediate points since the last down or move event.
302 */
303 AMOTION_EVENT_ACTION_MOVE = 2,
304
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700305 /**
306 * The current gesture has been aborted.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700307 * You will not receive any more points in it. You should treat this as
308 * an up event, but not perform any action that you normally would.
309 */
310 AMOTION_EVENT_ACTION_CANCEL = 3,
311
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700312 /**
313 * A movement has happened outside of the normal bounds of the UI element.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700314 * This does not provide a full gesture, but only the initial location of the movement/touch.
315 */
316 AMOTION_EVENT_ACTION_OUTSIDE = 4,
317
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700318 /**
319 * A non-primary pointer has gone down.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700320 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
321 */
322 AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
323
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700324 /**
325 * A non-primary pointer has gone up.
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_UP = 6,
329
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700330 /**
331 * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700332 * The motion contains the most recent point, as well as any intermediate points since
333 * the last hover move event.
334 */
335 AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
336
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700337 /**
338 * The motion event contains relative vertical and/or horizontal scroll offsets.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700339 * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
340 * and AMOTION_EVENT_AXIS_HSCROLL.
341 * The pointer may or may not be down when this event is dispatched.
342 * This action is always delivered to the winder under the pointer, which
343 * may not be the window currently touched.
344 */
345 AMOTION_EVENT_ACTION_SCROLL = 8,
346
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700347 /** The pointer is not down but has entered the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700348 AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
349
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700350 /** The pointer is not down but has exited the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700351 AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
Michael Wright7b159c92015-05-14 14:48:03 +0100352
353 /* One or more buttons have been pressed. */
354 AMOTION_EVENT_ACTION_BUTTON_PRESS = 11,
355
356 /* One or more buttons have been released. */
357 AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700358};
359
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700360/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700361 * Motion event flags.
362 */
363enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700364 /**
365 * This flag indicates that the window that received this motion event is partly
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700366 * or wholly obscured by another visible window above it. This flag is set to true
367 * even if the event did not directly pass through the obscured area.
368 * A security sensitive application can check this flag to identify situations in which
369 * a malicious application may have covered up part of its content for the purpose
370 * of misleading the user or hijacking touches. An appropriate response might be
371 * to drop the suspect touches or to take additional precautions to confirm the user's
372 * actual intent.
373 */
374 AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
375};
376
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700377/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700378 * Motion event edge touch flags.
379 */
380enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700381 /** No edges intersected. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700382 AMOTION_EVENT_EDGE_FLAG_NONE = 0,
383
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700384 /** Flag indicating the motion event intersected the top edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700385 AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
386
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700387 /** Flag indicating the motion event intersected the bottom edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700388 AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
389
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700390 /** Flag indicating the motion event intersected the left edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700391 AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
392
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700393 /** Flag indicating the motion event intersected the right edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700394 AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
395};
396
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700397/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700398 * Constants that identify each individual axis of a motion event.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700399 * @anchor AMOTION_EVENT_AXIS
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700400 */
401enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700402 /**
403 * Axis constant: X axis of a motion event.
404 *
405 * - For a touch screen, reports the absolute X screen position of the center of
406 * the touch contact area. The units are display pixels.
407 * - For a touch pad, reports the absolute X surface position of the center of the touch
408 * contact area. The units are device-dependent.
409 * - For a mouse, reports the absolute X screen position of the mouse pointer.
410 * The units are display pixels.
411 * - For a trackball, reports the relative horizontal displacement of the trackball.
412 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
413 * - For a joystick, reports the absolute X position of the joystick.
414 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
415 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700416 AMOTION_EVENT_AXIS_X = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700417 /**
418 * Axis constant: Y axis of a motion event.
419 *
420 * - For a touch screen, reports the absolute Y screen position of the center of
421 * the touch contact area. The units are display pixels.
422 * - For a touch pad, reports the absolute Y surface position of the center of the touch
423 * contact area. The units are device-dependent.
424 * - For a mouse, reports the absolute Y screen position of the mouse pointer.
425 * The units are display pixels.
426 * - For a trackball, reports the relative vertical displacement of the trackball.
427 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
428 * - For a joystick, reports the absolute Y position of the joystick.
429 * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
430 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700431 AMOTION_EVENT_AXIS_Y = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700432 /**
433 * Axis constant: Pressure axis of a motion event.
434 *
435 * - For a touch screen or touch pad, reports the approximate pressure applied to the surface
436 * by a finger or other tool. The value is normalized to a range from
437 * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
438 * may be generated depending on the calibration of the input device.
439 * - For a trackball, the value is set to 1 if the trackball button is pressed
440 * or 0 otherwise.
441 * - For a mouse, the value is set to 1 if the primary mouse button is pressed
442 * or 0 otherwise.
443 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700444 AMOTION_EVENT_AXIS_PRESSURE = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700445 /**
446 * Axis constant: Size axis of a motion event.
447 *
448 * - For a touch screen or touch pad, reports the approximate size of the contact area in
449 * relation to the maximum detectable size for the device. The value is normalized
450 * to a range from 0 (smallest detectable size) to 1 (largest detectable size),
451 * although it is not a linear scale. This value is of limited use.
452 * To obtain calibrated size information, see
453 * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}.
454 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700455 AMOTION_EVENT_AXIS_SIZE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700456 /**
457 * Axis constant: TouchMajor axis of a motion event.
458 *
459 * - For a touch screen, reports the length of the major axis of an ellipse that
460 * represents the touch area at the point of contact.
461 * The units are display pixels.
462 * - For a touch pad, reports the length of the major axis of an ellipse that
463 * represents the touch area at the point of contact.
464 * The units are device-dependent.
465 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700466 AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700467 /**
468 * Axis constant: TouchMinor axis of a motion event.
469 *
470 * - For a touch screen, reports the length of the minor axis of an ellipse that
471 * represents the touch area at the point of contact.
472 * The units are display pixels.
473 * - For a touch pad, reports the length of the minor axis of an ellipse that
474 * represents the touch area at the point of contact.
475 * The units are device-dependent.
476 *
477 * When the touch is circular, the major and minor axis lengths will be equal to one another.
478 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700479 AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700480 /**
481 * Axis constant: ToolMajor axis of a motion event.
482 *
483 * - For a touch screen, reports the length of the major axis of an ellipse that
484 * represents the size of the approaching finger or tool used to make contact.
485 * - For a touch pad, reports the length of the major axis of an ellipse that
486 * represents the size of the approaching finger or tool used to make contact.
487 * The units are device-dependent.
488 *
489 * When the touch is circular, the major and minor axis lengths will be equal to one another.
490 *
491 * The tool size may be larger than the touch size since the tool may not be fully
492 * in contact with the touch sensor.
493 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700494 AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700495 /**
496 * Axis constant: ToolMinor axis of a motion event.
497 *
498 * - For a touch screen, reports the length of the minor axis of an ellipse that
499 * represents the size of the approaching finger or tool used to make contact.
500 * - For a touch pad, reports the length of the minor axis of an ellipse that
501 * represents the size of the approaching finger or tool used to make contact.
502 * The units are device-dependent.
503 *
504 * When the touch is circular, the major and minor axis lengths will be equal to one another.
505 *
506 * The tool size may be larger than the touch size since the tool may not be fully
507 * in contact with the touch sensor.
508 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700509 AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700510 /**
511 * Axis constant: Orientation axis of a motion event.
512 *
513 * - For a touch screen or touch pad, reports the orientation of the finger
514 * or tool in radians relative to the vertical plane of the device.
515 * An angle of 0 radians indicates that the major axis of contact is oriented
516 * upwards, is perfectly circular or is of unknown orientation. A positive angle
517 * indicates that the major axis of contact is oriented to the right. A negative angle
518 * indicates that the major axis of contact is oriented to the left.
519 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
520 * (finger pointing fully right).
521 * - For a stylus, the orientation indicates the direction in which the stylus
522 * is pointing in relation to the vertical axis of the current orientation of the screen.
523 * The range is from -PI radians to PI radians, where 0 is pointing up,
524 * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
525 * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}.
526 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700527 AMOTION_EVENT_AXIS_ORIENTATION = 8,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700528 /**
529 * Axis constant: Vertical Scroll axis of a motion event.
530 *
531 * - For a mouse, reports the relative movement of the vertical scroll wheel.
532 * The value is normalized to a range from -1.0 (down) to 1.0 (up).
533 *
534 * This axis should be used to scroll views vertically.
535 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700536 AMOTION_EVENT_AXIS_VSCROLL = 9,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700537 /**
538 * Axis constant: Horizontal Scroll axis of a motion event.
539 *
540 * - For a mouse, reports the relative movement of the horizontal scroll wheel.
541 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
542 *
543 * This axis should be used to scroll views horizontally.
544 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700545 AMOTION_EVENT_AXIS_HSCROLL = 10,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700546 /**
547 * Axis constant: Z axis of a motion event.
548 *
549 * - For a joystick, reports the absolute Z position of the joystick.
550 * The value is normalized to a range from -1.0 (high) to 1.0 (low).
551 * <em>On game pads with two analog joysticks, this axis is often reinterpreted
552 * to report the absolute X position of the second joystick instead.</em>
553 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700554 AMOTION_EVENT_AXIS_Z = 11,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700555 /**
556 * Axis constant: X Rotation axis of a motion event.
557 *
558 * - For a joystick, reports the absolute rotation angle about the X axis.
559 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
560 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700561 AMOTION_EVENT_AXIS_RX = 12,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700562 /**
563 * Axis constant: Y Rotation axis of a motion event.
564 *
565 * - For a joystick, reports the absolute rotation angle about the Y axis.
566 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
567 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700568 AMOTION_EVENT_AXIS_RY = 13,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700569 /**
570 * Axis constant: Z Rotation axis of a motion event.
571 *
572 * - For a joystick, reports the absolute rotation angle about the Z axis.
573 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
574 * On game pads with two analog joysticks, this axis is often reinterpreted
575 * to report the absolute Y position of the second joystick instead.
576 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700577 AMOTION_EVENT_AXIS_RZ = 14,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700578 /**
579 * Axis constant: Hat X axis of a motion event.
580 *
581 * - For a joystick, reports the absolute X position of the directional hat control.
582 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
583 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700584 AMOTION_EVENT_AXIS_HAT_X = 15,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700585 /**
586 * Axis constant: Hat Y axis of a motion event.
587 *
588 * - For a joystick, reports the absolute Y position of the directional hat control.
589 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
590 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700591 AMOTION_EVENT_AXIS_HAT_Y = 16,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700592 /**
593 * Axis constant: Left Trigger axis of a motion event.
594 *
595 * - For a joystick, reports the absolute position of the left trigger control.
596 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
597 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700598 AMOTION_EVENT_AXIS_LTRIGGER = 17,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700599 /**
600 * Axis constant: Right Trigger axis of a motion event.
601 *
602 * - For a joystick, reports the absolute position of the right trigger control.
603 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
604 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700605 AMOTION_EVENT_AXIS_RTRIGGER = 18,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700606 /**
607 * Axis constant: Throttle axis of a motion event.
608 *
609 * - For a joystick, reports the absolute position of the throttle control.
610 * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
611 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700612 AMOTION_EVENT_AXIS_THROTTLE = 19,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700613 /**
614 * Axis constant: Rudder axis of a motion event.
615 *
616 * - For a joystick, reports the absolute position of the rudder control.
617 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
618 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700619 AMOTION_EVENT_AXIS_RUDDER = 20,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700620 /**
621 * Axis constant: Wheel axis of a motion event.
622 *
623 * - For a joystick, reports the absolute position of the steering wheel control.
624 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
625 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700626 AMOTION_EVENT_AXIS_WHEEL = 21,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700627 /**
628 * Axis constant: Gas axis of a motion event.
629 *
630 * - For a joystick, reports the absolute position of the gas (accelerator) control.
631 * The value is normalized to a range from 0.0 (no acceleration)
632 * to 1.0 (maximum acceleration).
633 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700634 AMOTION_EVENT_AXIS_GAS = 22,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700635 /**
636 * Axis constant: Brake axis of a motion event.
637 *
638 * - For a joystick, reports the absolute position of the brake control.
639 * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
640 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700641 AMOTION_EVENT_AXIS_BRAKE = 23,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700642 /**
643 * Axis constant: Distance axis of a motion event.
644 *
645 * - For a stylus, reports the distance of the stylus from the screen.
646 * A value of 0.0 indicates direct contact and larger values indicate increasing
647 * distance from the surface.
648 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700649 AMOTION_EVENT_AXIS_DISTANCE = 24,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700650 /**
651 * Axis constant: Tilt axis of a motion event.
652 *
653 * - For a stylus, reports the tilt angle of the stylus in radians where
654 * 0 radians indicates that the stylus is being held perpendicular to the
655 * surface, and PI/2 radians indicates that the stylus is being held flat
656 * against the surface.
657 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700658 AMOTION_EVENT_AXIS_TILT = 25,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700659 /**
Prashant Malani1941ff52015-08-11 18:29:28 -0700660 * Axis constant: Generic scroll axis of a motion event.
661 *
662 * - This is used for scroll axis motion events that can't be classified as strictly
663 * vertical or horizontal. The movement of a rotating scroller is an example of this.
664 */
665 AMOTION_EVENT_AXIS_SCROLL = 26,
666 /**
Jun Mukaifa1706a2015-12-03 01:14:46 -0800667 * Axis constant: The movement of x position of a motion event.
668 *
669 * - For a mouse, reports a difference of x position between the previous position.
670 * This is useful when pointer is captured, in that case the mouse pointer doesn't
671 * change the location but this axis reports the difference which allows the app
672 * to see how the mouse is moved.
673 */
674 AMOTION_EVENT_AXIS_RELATIVE_X = 27,
675 /**
676 * Axis constant: The movement of y position of a motion event.
677 *
678 * Same as {@link RELATIVE_X}, but for y position.
679 */
680 AMOTION_EVENT_AXIS_RELATIVE_Y = 28,
681 /**
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700682 * Axis constant: Generic 1 axis of a motion event.
683 * The interpretation of a generic axis is device-specific.
684 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700685 AMOTION_EVENT_AXIS_GENERIC_1 = 32,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700686 /**
687 * Axis constant: Generic 2 axis of a motion event.
688 * The interpretation of a generic axis is device-specific.
689 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700690 AMOTION_EVENT_AXIS_GENERIC_2 = 33,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700691 /**
692 * Axis constant: Generic 3 axis of a motion event.
693 * The interpretation of a generic axis is device-specific.
694 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700695 AMOTION_EVENT_AXIS_GENERIC_3 = 34,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700696 /**
697 * Axis constant: Generic 4 axis of a motion event.
698 * The interpretation of a generic axis is device-specific.
699 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700700 AMOTION_EVENT_AXIS_GENERIC_4 = 35,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700701 /**
702 * Axis constant: Generic 5 axis of a motion event.
703 * The interpretation of a generic axis is device-specific.
704 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700705 AMOTION_EVENT_AXIS_GENERIC_5 = 36,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700706 /**
707 * Axis constant: Generic 6 axis of a motion event.
708 * The interpretation of a generic axis is device-specific.
709 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700710 AMOTION_EVENT_AXIS_GENERIC_6 = 37,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700711 /**
712 * Axis constant: Generic 7 axis of a motion event.
713 * The interpretation of a generic axis is device-specific.
714 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700715 AMOTION_EVENT_AXIS_GENERIC_7 = 38,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700716 /**
717 * Axis constant: Generic 8 axis of a motion event.
718 * The interpretation of a generic axis is device-specific.
719 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700720 AMOTION_EVENT_AXIS_GENERIC_8 = 39,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700721 /**
722 * Axis constant: Generic 9 axis of a motion event.
723 * The interpretation of a generic axis is device-specific.
724 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700725 AMOTION_EVENT_AXIS_GENERIC_9 = 40,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700726 /**
727 * Axis constant: Generic 10 axis of a motion event.
728 * The interpretation of a generic axis is device-specific.
729 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700730 AMOTION_EVENT_AXIS_GENERIC_10 = 41,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700731 /**
732 * Axis constant: Generic 11 axis of a motion event.
733 * The interpretation of a generic axis is device-specific.
734 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700735 AMOTION_EVENT_AXIS_GENERIC_11 = 42,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700736 /**
737 * Axis constant: Generic 12 axis of a motion event.
738 * The interpretation of a generic axis is device-specific.
739 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700740 AMOTION_EVENT_AXIS_GENERIC_12 = 43,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700741 /**
742 * Axis constant: Generic 13 axis of a motion event.
743 * The interpretation of a generic axis is device-specific.
744 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700745 AMOTION_EVENT_AXIS_GENERIC_13 = 44,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700746 /**
747 * Axis constant: Generic 14 axis of a motion event.
748 * The interpretation of a generic axis is device-specific.
749 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700750 AMOTION_EVENT_AXIS_GENERIC_14 = 45,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700751 /**
752 * Axis constant: Generic 15 axis of a motion event.
753 * The interpretation of a generic axis is device-specific.
754 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700755 AMOTION_EVENT_AXIS_GENERIC_15 = 46,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700756 /**
757 * Axis constant: Generic 16 axis of a motion event.
758 * The interpretation of a generic axis is device-specific.
759 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700760 AMOTION_EVENT_AXIS_GENERIC_16 = 47,
761
762 // NOTE: If you add a new axis here you must also add it to several other files.
763 // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
764};
765
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700766/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700767 * Constants that identify buttons that are associated with motion events.
768 * Refer to the documentation on the MotionEvent class for descriptions of each button.
769 */
770enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700771 /** primary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700772 AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700773 /** secondary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700774 AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700775 /** tertiary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700776 AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700777 /** back */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700778 AMOTION_EVENT_BUTTON_BACK = 1 << 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700779 /** forward */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700780 AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
Michael Wright7b159c92015-05-14 14:48:03 +0100781 AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
782 AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700783};
784
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700785/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700786 * Constants that identify tool types.
787 * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
788 */
789enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700790 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700791 AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700792 /** finger */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700793 AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700794 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700795 AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700796 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700797 AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700798 /** eraser */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700799 AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
Arthur Hung421eb1c2020-01-16 00:09:42 +0800800 /** palm */
801 AMOTION_EVENT_TOOL_TYPE_PALM = 5,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700802};
803
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700804/**
805 * Input source masks.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700806 *
807 * Refer to the documentation on android.view.InputDevice for more details about input sources
808 * and their correct interpretation.
809 */
810enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700811 /** mask */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700812 AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
813
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700814 /** none */
Michael Wrightaadaca72013-03-11 14:20:14 -0700815 AINPUT_SOURCE_CLASS_NONE = 0x00000000,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700816 /** button */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700817 AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700818 /** pointer */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700819 AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700820 /** navigation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700821 AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700822 /** position */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700823 AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700824 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700825 AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
826};
827
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700828/**
829 * Input sources.
830 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700831enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700832 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700833 AINPUT_SOURCE_UNKNOWN = 0x00000000,
834
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700835 /** keyboard */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700836 AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700837 /** dpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700838 AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700839 /** gamepad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700840 AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700841 /** touchscreen */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700842 AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700843 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700844 AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700845 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700846 AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
Michael Wright7d3ad692015-06-23 19:04:31 +0100847 /** bluetooth stylus */
Michael Wright2f78b682015-06-12 15:25:08 +0100848 AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700849 /** trackball */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700850 AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Vladislav Kaznacheev78f97b32016-12-15 18:14:58 -0800851 /** mouse relative */
852 AINPUT_SOURCE_MOUSE_RELATIVE = 0x00020000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700853 /** touchpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700854 AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700855 /** navigation */
Michael Wrightaadaca72013-03-11 14:20:14 -0700856 AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700857 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700858 AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
Chris Ye02303442021-01-26 13:21:01 -0800859 /** HDMI */
860 AINPUT_SOURCE_HDMI = 0x02000000 | AINPUT_SOURCE_CLASS_BUTTON,
Chris Yef59a2f42020-10-16 12:55:26 -0700861 /** sensor */
Chris Ye02303442021-01-26 13:21:01 -0800862 AINPUT_SOURCE_SENSOR = 0x04000000 | AINPUT_SOURCE_UNKNOWN,
Prashant Malani1941ff52015-08-11 18:29:28 -0700863 /** rotary encoder */
864 AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700865
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700866 /** any */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700867 AINPUT_SOURCE_ANY = 0xffffff00,
868};
869
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700870/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700871 * Keyboard types.
872 *
873 * Refer to the documentation on android.view.InputDevice for more details.
874 */
875enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700876 /** none */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700877 AINPUT_KEYBOARD_TYPE_NONE = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700878 /** non alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700879 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700880 /** alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700881 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
882};
883
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700884/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700885 * Constants used to retrieve information about the range of motion for a particular
886 * coordinate of a motion event.
887 *
888 * Refer to the documentation on android.view.InputDevice for more details about input sources
889 * and their correct interpretation.
890 *
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700891 * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700892 */
893enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700894 /** x */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700895 AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700896 /** y */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700897 AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700898 /** pressure */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700899 AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700900 /** size */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700901 AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700902 /** touch major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700903 AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700904 /** touch minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700905 AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700906 /** tool major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700907 AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700908 /** tool minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700909 AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700910 /** orientation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700911 AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700912};
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700913
914
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700915/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700916 * Input event accessors.
917 *
918 * Note that most functions can only be used on input events that are of a given type.
919 * Calling these functions on input events of other types will yield undefined behavior.
920 */
921
922/*** Accessors for all input events. ***/
923
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700924/** Get the input event type. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700925int32_t AInputEvent_getType(const AInputEvent* event);
926
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700927/** Get the id for the device that an input event came from.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700928 *
929 * Input events can be generated by multiple different input devices.
930 * Use the input device id to obtain information about the input
931 * device that was responsible for generating a particular event.
932 *
933 * An input device id of 0 indicates that the event didn't come from a physical device;
934 * other numbers are arbitrary and you shouldn't depend on the values.
935 * Use the provided input device query API to obtain information about input devices.
936 */
937int32_t AInputEvent_getDeviceId(const AInputEvent* event);
938
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700939/** Get the input event source. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700940int32_t AInputEvent_getSource(const AInputEvent* event);
941
Chris Ye1aaa2122020-04-07 19:38:15 -0700942/**
943 * Releases interface objects created by {@link AKeyEvent_fromJava()}
944 * and {@link AMotionEvent_fromJava()}.
945 * After returning, the specified AInputEvent* object becomes invalid and should no longer be used.
946 * The underlying Java object remains valid and does not change its state.
947 */
948
949void AInputEvent_release(const AInputEvent* event);
950
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700951/*** Accessors for key events only. ***/
952
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700953/** Get the key event action. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700954int32_t AKeyEvent_getAction(const AInputEvent* key_event);
955
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700956/** Get the key event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700957int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
958
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700959/**
960 * Get the key code of the key event.
961 * This is the physical key that was pressed, not the Unicode character.
962 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700963int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
964
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700965/**
966 * Get the hardware key id of this key event.
967 * These values are not reliable and vary from device to device.
968 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700969int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
970
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700971/** Get the meta key state. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700972int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
973
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700974/**
975 * Get the repeat count of the event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700976 * For both key up an key down events, this is the number of times the key has
977 * repeated with the first down starting at 0 and counting up from there. For
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700978 * multiple key events, this is the number of down/up pairs that have occurred.
979 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700980int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
981
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700982/**
983 * Get the time of the most recent key down event, in the
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700984 * java.lang.System.nanoTime() time base. If this is a down event,
985 * this will be the same as eventTime.
986 * Note that when chording keys, this value is the down time of the most recently
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700987 * pressed key, which may not be the same physical key of this event.
988 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700989int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
990
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700991/**
992 * Get the time this event occurred, in the
993 * java.lang.System.nanoTime() time base.
994 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700995int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
996
Chris Ye1aaa2122020-04-07 19:38:15 -0700997/**
Siarhei Vishniakoua53d8652020-08-13 23:59:50 -0500998 * Creates a native AInputEvent* object that is a copy of the specified Java android.view.KeyEvent.
999 * The result may be used with generic and KeyEvent-specific AInputEvent_* functions. The object
1000 * returned by this function must be disposed using {@link AInputEvent_release()}.
Chris Ye1aaa2122020-04-07 19:38:15 -07001001 */
1002const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent);
1003
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001004/*** Accessors for motion events only. ***/
1005
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001006/** Get the combined motion event action code and pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001007int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
1008
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001009/** Get the motion event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001010int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
1011
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001012/**
1013 * Get the state of any meta / modifier keys that were in effect when the
1014 * event was generated.
1015 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001016int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
1017
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001018/** Get the button state of all buttons that are pressed. */
Elliott Hughes3d70e532019-10-29 08:59:39 -07001019int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001020
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001021/**
1022 * Get a bitfield indicating which edges, if any, were touched by this motion event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001023 * For touch events, clients can use this to determine if the user's finger was
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001024 * touching the edge of the display.
1025 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001026int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
1027
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001028/**
1029 * Get the time when the user originally pressed down to start a stream of
1030 * position events, in the java.lang.System.nanoTime() time base.
1031 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001032int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
1033
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001034/**
1035 * Get the time when this specific event was generated,
1036 * in the java.lang.System.nanoTime() time base.
1037 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001038int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
1039
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001040/**
1041 * Get the X coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001042 * For touch events on the screen, this is the delta that was added to the raw
1043 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001044 * and views.
1045 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001046float AMotionEvent_getXOffset(const AInputEvent* motion_event);
1047
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001048/**
1049 * Get the Y coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001050 * For touch events on the screen, this is the delta that was added to the raw
1051 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001052 * and views.
1053 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001054float AMotionEvent_getYOffset(const AInputEvent* motion_event);
1055
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001056/**
1057 * Get the precision of the X coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001058 * You can multiply this number with an X coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001059 * actual hardware value of the X coordinate.
1060 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001061float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
1062
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001063/**
1064 * Get the precision of the Y coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001065 * You can multiply this number with a Y coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001066 * actual hardware value of the Y coordinate.
1067 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001068float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
1069
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001070/**
1071 * Get the number of pointers of data contained in this event.
1072 * Always >= 1.
1073 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001074size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
1075
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001076/**
1077 * Get the pointer identifier associated with a particular pointer
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001078 * data index in this event. The identifier tells you the actual pointer
1079 * number associated with the data, accounting for individual pointers
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001080 * going up and down since the start of the current gesture.
1081 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001082int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
1083
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001084/**
1085 * Get the tool type of a pointer for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001086 * The tool type indicates the type of tool used to make contact such as a
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001087 * finger or stylus, if known.
1088 */
Elliott Hughes3d70e532019-10-29 08:59:39 -07001089int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001090
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001091/**
1092 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001093 * For touch events on the screen, this is the original location of the event
1094 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001095 * and views.
1096 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001097float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
1098
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001099/**
1100 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001101 * For touch events on the screen, this is the original location of the event
1102 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001103 * and views.
1104 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001105float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
1106
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001107/**
1108 * Get the current X coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001109 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001110 * that are sub-pixel precise.
1111 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001112float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
1113
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001114/**
1115 * Get the current Y coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001116 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001117 * that are sub-pixel precise.
1118 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001119float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
1120
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001121/**
1122 * Get the current pressure of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001123 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1124 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001125 * the input device.
1126 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001127float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
1128
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001129/**
1130 * Get the current scaled value of the approximate size for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001131 * This represents some approximation of the area of the screen being
1132 * pressed; the actual value in pixels corresponding to the
1133 * touch is normalized with the device specific range of values
1134 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001135 * determine fat touch events.
1136 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001137float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
1138
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001139/**
1140 * Get the current length of the major axis of an ellipse that describes the touch area
1141 * at the point of contact for the given pointer index.
1142 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001143float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
1144
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001145/**
1146 * Get the current length of the minor axis of an ellipse that describes the touch area
1147 * at the point of contact for the given pointer index.
1148 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001149float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
1150
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001151/**
1152 * Get the current length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001153 * of the approaching tool for the given pointer index.
1154 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001155 * touching the device independent of its actual touch area at the point of contact.
1156 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001157float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
1158
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001159/**
1160 * Get the current length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001161 * of the approaching tool for the given pointer index.
1162 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001163 * touching the device independent of its actual touch area at the point of contact.
1164 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001165float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
1166
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001167/**
1168 * Get the current orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001169 * vertical for the given pointer index.
1170 * An angle of 0 degrees indicates that the major axis of contact is oriented
1171 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1172 * indicates that the major axis of contact is oriented to the right. A negative angle
1173 * indicates that the major axis of contact is oriented to the left.
1174 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001175 * (finger pointing fully right).
1176 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001177float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
1178
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001179/** Get the value of the request axis for the given pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001180float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001181 int32_t axis, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001182
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001183/**
1184 * Get the number of historical points in this event. These are movements that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001185 * have occurred between this event and the previous event. This only applies
1186 * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001187 * Historical samples are indexed from oldest to newest.
1188 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001189size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
1190
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001191/**
1192 * Get the time that a historical movement occurred between this event and
1193 * the previous event, in the java.lang.System.nanoTime() time base.
1194 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001195int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001196 size_t history_index);
1197
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001198/**
1199 * Get the historical raw X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001200 * occurred between this event and the previous motion event.
1201 * For touch events on the screen, this is the original location of the event
1202 * on the screen, before it had been adjusted for the containing window
1203 * and views.
1204 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001205 * that are sub-pixel precise.
1206 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001207float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
1208 size_t history_index);
1209
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001210/**
1211 * Get the historical raw Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001212 * occurred between this event and the previous motion event.
1213 * For touch events on the screen, this is the original location of the event
1214 * on the screen, before it had been adjusted for the containing window
1215 * and views.
1216 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001217 * that are sub-pixel precise.
1218 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001219float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
1220 size_t history_index);
1221
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001222/**
1223 * Get the historical X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001224 * occurred between this event and the previous motion event.
1225 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001226 * that are sub-pixel precise.
1227 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001228float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001229 size_t history_index);
1230
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001231/**
1232 * Get the historical Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001233 * occurred between this event and the previous motion event.
1234 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001235 * that are sub-pixel precise.
1236 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001237float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001238 size_t history_index);
1239
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001240/**
1241 * Get the historical pressure of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001242 * occurred between this event and the previous motion event.
1243 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1244 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001245 * the input device.
1246 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001247float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001248 size_t history_index);
1249
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001250/**
1251 * Get the current scaled value of the approximate size for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001252 * occurred between this event and the previous motion event.
1253 * This represents some approximation of the area of the screen being
1254 * pressed; the actual value in pixels corresponding to the
1255 * touch is normalized with the device specific range of values
1256 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001257 * determine fat touch events.
1258 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001259float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001260 size_t history_index);
1261
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001262/**
1263 * Get the historical length of the major axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001264 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001265 * occurred between this event and the previous motion event.
1266 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001267float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
1268 size_t history_index);
1269
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001270/**
1271 * Get the historical length of the minor axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001272 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001273 * occurred between this event and the previous motion event.
1274 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001275float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
1276 size_t history_index);
1277
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001278/**
1279 * Get the historical length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001280 * of the approaching tool for the given pointer index that
1281 * occurred between this event and the previous motion event.
1282 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001283 * touching the device independent of its actual touch area at the point of contact.
1284 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001285float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
1286 size_t history_index);
1287
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001288/**
1289 * Get the historical length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001290 * of the approaching tool for the given pointer index that
1291 * occurred between this event and the previous motion event.
1292 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001293 * touching the device independent of its actual touch area at the point of contact.
1294 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001295float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
1296 size_t history_index);
1297
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001298/**
1299 * Get the historical orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001300 * vertical for the given pointer index that
1301 * occurred between this event and the previous motion event.
1302 * An angle of 0 degrees indicates that the major axis of contact is oriented
1303 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1304 * indicates that the major axis of contact is oriented to the right. A negative angle
1305 * indicates that the major axis of contact is oriented to the left.
1306 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001307 * (finger pointing fully right).
1308 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001309float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
1310 size_t history_index);
1311
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001312/**
1313 * Get the historical value of the request axis for the given pointer index
1314 * that occurred between this event and the previous motion event.
1315 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001316float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001317 int32_t axis, size_t pointer_index, size_t history_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001318
Chris Ye1aaa2122020-04-07 19:38:15 -07001319/**
Siarhei Vishniakoua53d8652020-08-13 23:59:50 -05001320 * Creates a native AInputEvent* object that is a copy of the specified Java
1321 * android.view.MotionEvent. The result may be used with generic and MotionEvent-specific
1322 * AInputEvent_* functions. The object returned by this function must be disposed using
1323 * {@link AInputEvent_release()}.
Chris Ye1aaa2122020-04-07 19:38:15 -07001324 */
1325const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001326
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001327struct AInputQueue;
1328/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001329 * Input queue
1330 *
1331 * An input queue is the facility through which you retrieve input
1332 * events.
1333 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001334typedef struct AInputQueue AInputQueue;
1335
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001336/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001337 * Add this input queue to a looper for processing. See
1338 * ALooper_addFd() for information on the ident, callback, and data params.
1339 */
1340void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
1341 int ident, ALooper_callbackFunc callback, void* data);
1342
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001343/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001344 * Remove the input queue from the looper it is currently attached to.
1345 */
1346void AInputQueue_detachLooper(AInputQueue* queue);
1347
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001348/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001349 * Returns true if there are one or more events available in the
1350 * input queue. Returns 1 if the queue has events; 0 if
1351 * it does not have events; and a negative value if there is an error.
1352 */
1353int32_t AInputQueue_hasEvents(AInputQueue* queue);
1354
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001355/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001356 * Returns the next available event from the queue. Returns a negative
1357 * value if no events are available or an error has occurred.
1358 */
1359int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
1360
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001361/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001362 * Sends the key for standard pre-dispatching -- that is, possibly deliver
1363 * it to the current IME to be consumed before the app. Returns 0 if it
1364 * was not pre-dispatched, meaning you can process it right now. If non-zero
1365 * is returned, you must abandon the current event processing and allow the
1366 * event to appear again in the event queue (if it does not get consumed during
1367 * pre-dispatching).
1368 */
1369int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
1370
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001371/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001372 * Report that dispatching has finished with the given event.
1373 * This must be called after receiving an event with AInputQueue_get_event().
1374 */
1375void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
1376
1377#ifdef __cplusplus
1378}
1379#endif
1380
1381#endif // _ANDROID_INPUT_H
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001382
1383/** @} */