blob: f51cd795044ad1947707b718eb7acc74d9f5a294 [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>
58
Elliott Hughes9db409b2018-06-18 12:28:46 -070059#if !defined(__INTRODUCED_IN)
60#define __INTRODUCED_IN(__api_level) /* nothing */
61#endif
62
Mathias Agopiane1c61d32012-03-23 14:19:36 -070063#ifdef __cplusplus
64extern "C" {
65#endif
66
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070067/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070068 * Key states (may be returned by queries about the current state of a
69 * particular key code, scan code or switch).
70 */
71enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070072 /** The key state is unknown or the requested key itself is not supported. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070073 AKEY_STATE_UNKNOWN = -1,
74
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070075 /** The key is up. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070076 AKEY_STATE_UP = 0,
77
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070078 /** The key is down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070079 AKEY_STATE_DOWN = 1,
80
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070081 /** The key is down but is a virtual key press that is being emulated by the system. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070082 AKEY_STATE_VIRTUAL = 2
83};
84
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070085/**
Siarhei Vishniakou61fafdd2018-04-13 11:00:58 -050086 * Meta key / modifier state.
Mathias Agopiane1c61d32012-03-23 14:19:36 -070087 */
88enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070089 /** No meta keys are pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070090 AMETA_NONE = 0,
91
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070092 /** This mask is used to check whether one of the ALT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070093 AMETA_ALT_ON = 0x02,
94
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070095 /** This mask is used to check whether the left ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070096 AMETA_ALT_LEFT_ON = 0x10,
97
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070098 /** This mask is used to check whether the right ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070099 AMETA_ALT_RIGHT_ON = 0x20,
100
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700101 /** This mask is used to check whether one of the SHIFT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700102 AMETA_SHIFT_ON = 0x01,
103
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700104 /** This mask is used to check whether the left SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700105 AMETA_SHIFT_LEFT_ON = 0x40,
106
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700107 /** This mask is used to check whether the right SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700108 AMETA_SHIFT_RIGHT_ON = 0x80,
109
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700110 /** This mask is used to check whether the SYM meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700111 AMETA_SYM_ON = 0x04,
112
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700113 /** This mask is used to check whether the FUNCTION meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700114 AMETA_FUNCTION_ON = 0x08,
115
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700116 /** This mask is used to check whether one of the CTRL meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700117 AMETA_CTRL_ON = 0x1000,
118
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700119 /** This mask is used to check whether the left CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700120 AMETA_CTRL_LEFT_ON = 0x2000,
121
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700122 /** This mask is used to check whether the right CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700123 AMETA_CTRL_RIGHT_ON = 0x4000,
124
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700125 /** This mask is used to check whether one of the META meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700126 AMETA_META_ON = 0x10000,
127
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700128 /** This mask is used to check whether the left META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700129 AMETA_META_LEFT_ON = 0x20000,
130
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700131 /** This mask is used to check whether the right META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700132 AMETA_META_RIGHT_ON = 0x40000,
133
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700134 /** This mask is used to check whether the CAPS LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700135 AMETA_CAPS_LOCK_ON = 0x100000,
136
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700137 /** This mask is used to check whether the NUM LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700138 AMETA_NUM_LOCK_ON = 0x200000,
139
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700140 /** This mask is used to check whether the SCROLL LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700141 AMETA_SCROLL_LOCK_ON = 0x400000,
142};
143
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700144struct AInputEvent;
145/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700146 * Input events.
147 *
148 * Input events are opaque structures. Use the provided accessors functions to
149 * read their properties.
150 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700151typedef struct AInputEvent AInputEvent;
152
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700153/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700154 * Input event types.
155 */
156enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700157 /** Indicates that the input event is a key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700158 AINPUT_EVENT_TYPE_KEY = 1,
159
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700160 /** Indicates that the input event is a motion event. */
Siarhei Vishniakou7feb2ea2019-11-25 15:11:23 -0800161 AINPUT_EVENT_TYPE_MOTION = 2,
162
163 /** Focus event */
164 AINPUT_EVENT_TYPE_FOCUS = 3,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700165};
166
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700167/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700168 * Key event actions.
169 */
170enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700171 /** The key has been pressed down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700172 AKEY_EVENT_ACTION_DOWN = 0,
173
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700174 /** The key has been released. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700175 AKEY_EVENT_ACTION_UP = 1,
176
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700177 /**
178 * Multiple duplicate key events have occurred in a row, or a
179 * complex string is being delivered. The repeat_count property
180 * of the key event contains the number of times the given key
181 * code should be executed.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700182 */
183 AKEY_EVENT_ACTION_MULTIPLE = 2
184};
185
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700186/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700187 * Key event flags.
188 */
189enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700190 /** This mask is set if the device woke because of this key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700191 AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
192
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700193 /** This mask is set if the key event was generated by a software keyboard. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700194 AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
195
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700196 /** 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 -0700197 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
198
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700199 /**
200 * This mask is set if an event was known to come from a trusted
201 * part of the system. That is, the event is known to come from
202 * the user, and could not have been spoofed by a third party
203 * component.
204 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700205 AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
206
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700207 /**
208 * This mask is used for compatibility, to identify enter keys that are
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700209 * coming from an IME whose enter key has been auto-labelled "next" or
210 * "done". This allows TextView to dispatch these as normal enter keys
211 * for old applications, but still do the appropriate action when
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700212 * receiving them.
213 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700214 AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
215
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700216 /**
217 * When associated with up key events, this indicates that the key press
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700218 * has been canceled. Typically this is used with virtual touch screen
219 * keys, where the user can slide from the virtual key area on to the
220 * display: in that case, the application will receive a canceled up
221 * event and should not perform the action normally associated with the
222 * key. Note that for this to work, the application can not perform an
223 * action for a key until it receives an up or the long press timeout has
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700224 * expired.
225 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700226 AKEY_EVENT_FLAG_CANCELED = 0x20,
227
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700228 /**
229 * This key event was generated by a virtual (on-screen) hard key area.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700230 * Typically this is an area of the touchscreen, outside of the regular
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700231 * display, dedicated to "hardware" buttons.
232 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700233 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
234
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700235 /**
236 * This flag is set for the first key repeat that occurs after the
237 * long press timeout.
238 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700239 AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
240
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700241 /**
242 * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
243 * press action was executed while it was down.
244 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700245 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
246
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700247 /**
248 * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700249 * tracked from its initial down. That is, somebody requested that tracking
250 * started on the key down and a long press has not caused
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700251 * the tracking to be canceled.
252 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700253 AKEY_EVENT_FLAG_TRACKING = 0x200,
254
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700255 /**
256 * Set when a key event has been synthesized to implement default behavior
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700257 * for an event that the application did not handle.
258 * Fallback key events are generated by unhandled trackball motions
259 * (to emulate a directional keypad) and by certain unhandled key presses
260 * that are declared in the key map (such as special function numeric keypad
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700261 * keys when numlock is off).
262 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700263 AKEY_EVENT_FLAG_FALLBACK = 0x400,
264};
265
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700266/**
267 * Bit shift for the action bits holding the pointer index as
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700268 * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
269 */
270#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
271
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700272/** Motion event actions */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700273enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700274 /** Bit mask of the parts of the action code that are the action itself. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700275 AMOTION_EVENT_ACTION_MASK = 0xff,
276
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700277 /**
278 * Bits in the action code that represent a pointer index, used with
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700279 * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
280 * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
281 * index where the data for the pointer going up or down can be found.
282 */
283 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
284
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700285 /** A pressed gesture has started, the motion contains the initial starting location. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700286 AMOTION_EVENT_ACTION_DOWN = 0,
287
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700288 /**
289 * A pressed gesture has finished, the motion contains the final release location
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700290 * as well as any intermediate points since the last down or move event.
291 */
292 AMOTION_EVENT_ACTION_UP = 1,
293
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700294 /**
295 * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700296 * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
297 * any intermediate points since the last down or move event.
298 */
299 AMOTION_EVENT_ACTION_MOVE = 2,
300
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700301 /**
302 * The current gesture has been aborted.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700303 * You will not receive any more points in it. You should treat this as
304 * an up event, but not perform any action that you normally would.
305 */
306 AMOTION_EVENT_ACTION_CANCEL = 3,
307
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700308 /**
309 * A movement has happened outside of the normal bounds of the UI element.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700310 * This does not provide a full gesture, but only the initial location of the movement/touch.
311 */
312 AMOTION_EVENT_ACTION_OUTSIDE = 4,
313
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700314 /**
315 * A non-primary pointer has gone down.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700316 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
317 */
318 AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
319
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700320 /**
321 * A non-primary pointer has gone up.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700322 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
323 */
324 AMOTION_EVENT_ACTION_POINTER_UP = 6,
325
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700326 /**
327 * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700328 * The motion contains the most recent point, as well as any intermediate points since
329 * the last hover move event.
330 */
331 AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
332
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700333 /**
334 * The motion event contains relative vertical and/or horizontal scroll offsets.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700335 * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
336 * and AMOTION_EVENT_AXIS_HSCROLL.
337 * The pointer may or may not be down when this event is dispatched.
338 * This action is always delivered to the winder under the pointer, which
339 * may not be the window currently touched.
340 */
341 AMOTION_EVENT_ACTION_SCROLL = 8,
342
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700343 /** The pointer is not down but has entered the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700344 AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
345
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700346 /** The pointer is not down but has exited the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700347 AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
Michael Wright7b159c92015-05-14 14:48:03 +0100348
349 /* One or more buttons have been pressed. */
350 AMOTION_EVENT_ACTION_BUTTON_PRESS = 11,
351
352 /* One or more buttons have been released. */
353 AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700354};
355
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700356/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700357 * Motion event flags.
358 */
359enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700360 /**
361 * This flag indicates that the window that received this motion event is partly
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700362 * or wholly obscured by another visible window above it. This flag is set to true
363 * even if the event did not directly pass through the obscured area.
364 * A security sensitive application can check this flag to identify situations in which
365 * a malicious application may have covered up part of its content for the purpose
366 * of misleading the user or hijacking touches. An appropriate response might be
367 * to drop the suspect touches or to take additional precautions to confirm the user's
368 * actual intent.
369 */
370 AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
371};
372
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700373/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700374 * Motion event edge touch flags.
375 */
376enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700377 /** No edges intersected. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700378 AMOTION_EVENT_EDGE_FLAG_NONE = 0,
379
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700380 /** Flag indicating the motion event intersected the top edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700381 AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
382
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700383 /** Flag indicating the motion event intersected the bottom edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700384 AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
385
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700386 /** Flag indicating the motion event intersected the left edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700387 AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
388
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700389 /** Flag indicating the motion event intersected the right edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700390 AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
391};
392
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700393/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700394 * Constants that identify each individual axis of a motion event.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700395 * @anchor AMOTION_EVENT_AXIS
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700396 */
397enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700398 /**
399 * Axis constant: X axis of a motion event.
400 *
401 * - For a touch screen, reports the absolute X screen position of the center of
402 * the touch contact area. The units are display pixels.
403 * - For a touch pad, reports the absolute X surface position of the center of the touch
404 * contact area. The units are device-dependent.
405 * - For a mouse, reports the absolute X screen position of the mouse pointer.
406 * The units are display pixels.
407 * - For a trackball, reports the relative horizontal displacement of the trackball.
408 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
409 * - For a joystick, reports the absolute X position of the joystick.
410 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
411 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700412 AMOTION_EVENT_AXIS_X = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700413 /**
414 * Axis constant: Y axis of a motion event.
415 *
416 * - For a touch screen, reports the absolute Y screen position of the center of
417 * the touch contact area. The units are display pixels.
418 * - For a touch pad, reports the absolute Y surface position of the center of the touch
419 * contact area. The units are device-dependent.
420 * - For a mouse, reports the absolute Y screen position of the mouse pointer.
421 * The units are display pixels.
422 * - For a trackball, reports the relative vertical displacement of the trackball.
423 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
424 * - For a joystick, reports the absolute Y position of the joystick.
425 * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
426 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700427 AMOTION_EVENT_AXIS_Y = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700428 /**
429 * Axis constant: Pressure axis of a motion event.
430 *
431 * - For a touch screen or touch pad, reports the approximate pressure applied to the surface
432 * by a finger or other tool. The value is normalized to a range from
433 * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
434 * may be generated depending on the calibration of the input device.
435 * - For a trackball, the value is set to 1 if the trackball button is pressed
436 * or 0 otherwise.
437 * - For a mouse, the value is set to 1 if the primary mouse button is pressed
438 * or 0 otherwise.
439 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700440 AMOTION_EVENT_AXIS_PRESSURE = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700441 /**
442 * Axis constant: Size axis of a motion event.
443 *
444 * - For a touch screen or touch pad, reports the approximate size of the contact area in
445 * relation to the maximum detectable size for the device. The value is normalized
446 * to a range from 0 (smallest detectable size) to 1 (largest detectable size),
447 * although it is not a linear scale. This value is of limited use.
448 * To obtain calibrated size information, see
449 * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}.
450 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700451 AMOTION_EVENT_AXIS_SIZE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700452 /**
453 * Axis constant: TouchMajor axis of a motion event.
454 *
455 * - For a touch screen, reports the length of the major axis of an ellipse that
456 * represents the touch area at the point of contact.
457 * The units are display pixels.
458 * - For a touch pad, reports the length of the major axis of an ellipse that
459 * represents the touch area at the point of contact.
460 * The units are device-dependent.
461 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700462 AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700463 /**
464 * Axis constant: TouchMinor axis of a motion event.
465 *
466 * - For a touch screen, reports the length of the minor axis of an ellipse that
467 * represents the touch area at the point of contact.
468 * The units are display pixels.
469 * - For a touch pad, reports the length of the minor axis of an ellipse that
470 * represents the touch area at the point of contact.
471 * The units are device-dependent.
472 *
473 * When the touch is circular, the major and minor axis lengths will be equal to one another.
474 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700475 AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700476 /**
477 * Axis constant: ToolMajor axis of a motion event.
478 *
479 * - For a touch screen, reports the length of the major axis of an ellipse that
480 * represents the size of the approaching finger or tool used to make contact.
481 * - For a touch pad, reports the length of the major axis of an ellipse that
482 * represents the size of the approaching finger or tool used to make contact.
483 * The units are device-dependent.
484 *
485 * When the touch is circular, the major and minor axis lengths will be equal to one another.
486 *
487 * The tool size may be larger than the touch size since the tool may not be fully
488 * in contact with the touch sensor.
489 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700490 AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700491 /**
492 * Axis constant: ToolMinor axis of a motion event.
493 *
494 * - For a touch screen, reports the length of the minor axis of an ellipse that
495 * represents the size of the approaching finger or tool used to make contact.
496 * - For a touch pad, reports the length of the minor axis of an ellipse that
497 * represents the size of the approaching finger or tool used to make contact.
498 * The units are device-dependent.
499 *
500 * When the touch is circular, the major and minor axis lengths will be equal to one another.
501 *
502 * The tool size may be larger than the touch size since the tool may not be fully
503 * in contact with the touch sensor.
504 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700505 AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700506 /**
507 * Axis constant: Orientation axis of a motion event.
508 *
509 * - For a touch screen or touch pad, reports the orientation of the finger
510 * or tool in radians relative to the vertical plane of the device.
511 * An angle of 0 radians indicates that the major axis of contact is oriented
512 * upwards, is perfectly circular or is of unknown orientation. A positive angle
513 * indicates that the major axis of contact is oriented to the right. A negative angle
514 * indicates that the major axis of contact is oriented to the left.
515 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
516 * (finger pointing fully right).
517 * - For a stylus, the orientation indicates the direction in which the stylus
518 * is pointing in relation to the vertical axis of the current orientation of the screen.
519 * The range is from -PI radians to PI radians, where 0 is pointing up,
520 * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
521 * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}.
522 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700523 AMOTION_EVENT_AXIS_ORIENTATION = 8,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700524 /**
525 * Axis constant: Vertical Scroll axis of a motion event.
526 *
527 * - For a mouse, reports the relative movement of the vertical scroll wheel.
528 * The value is normalized to a range from -1.0 (down) to 1.0 (up).
529 *
530 * This axis should be used to scroll views vertically.
531 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700532 AMOTION_EVENT_AXIS_VSCROLL = 9,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700533 /**
534 * Axis constant: Horizontal Scroll axis of a motion event.
535 *
536 * - For a mouse, reports the relative movement of the horizontal scroll wheel.
537 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
538 *
539 * This axis should be used to scroll views horizontally.
540 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700541 AMOTION_EVENT_AXIS_HSCROLL = 10,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700542 /**
543 * Axis constant: Z axis of a motion event.
544 *
545 * - For a joystick, reports the absolute Z position of the joystick.
546 * The value is normalized to a range from -1.0 (high) to 1.0 (low).
547 * <em>On game pads with two analog joysticks, this axis is often reinterpreted
548 * to report the absolute X position of the second joystick instead.</em>
549 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700550 AMOTION_EVENT_AXIS_Z = 11,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700551 /**
552 * Axis constant: X Rotation axis of a motion event.
553 *
554 * - For a joystick, reports the absolute rotation angle about the X axis.
555 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
556 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700557 AMOTION_EVENT_AXIS_RX = 12,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700558 /**
559 * Axis constant: Y Rotation axis of a motion event.
560 *
561 * - For a joystick, reports the absolute rotation angle about the Y axis.
562 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
563 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700564 AMOTION_EVENT_AXIS_RY = 13,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700565 /**
566 * Axis constant: Z Rotation axis of a motion event.
567 *
568 * - For a joystick, reports the absolute rotation angle about the Z axis.
569 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
570 * On game pads with two analog joysticks, this axis is often reinterpreted
571 * to report the absolute Y position of the second joystick instead.
572 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700573 AMOTION_EVENT_AXIS_RZ = 14,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700574 /**
575 * Axis constant: Hat X axis of a motion event.
576 *
577 * - For a joystick, reports the absolute X position of the directional hat control.
578 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
579 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700580 AMOTION_EVENT_AXIS_HAT_X = 15,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700581 /**
582 * Axis constant: Hat Y axis of a motion event.
583 *
584 * - For a joystick, reports the absolute Y position of the directional hat control.
585 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
586 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700587 AMOTION_EVENT_AXIS_HAT_Y = 16,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700588 /**
589 * Axis constant: Left Trigger axis of a motion event.
590 *
591 * - For a joystick, reports the absolute position of the left trigger control.
592 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
593 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700594 AMOTION_EVENT_AXIS_LTRIGGER = 17,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700595 /**
596 * Axis constant: Right Trigger axis of a motion event.
597 *
598 * - For a joystick, reports the absolute position of the right trigger control.
599 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
600 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700601 AMOTION_EVENT_AXIS_RTRIGGER = 18,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700602 /**
603 * Axis constant: Throttle axis of a motion event.
604 *
605 * - For a joystick, reports the absolute position of the throttle control.
606 * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
607 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700608 AMOTION_EVENT_AXIS_THROTTLE = 19,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700609 /**
610 * Axis constant: Rudder axis of a motion event.
611 *
612 * - For a joystick, reports the absolute position of the rudder control.
613 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
614 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700615 AMOTION_EVENT_AXIS_RUDDER = 20,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700616 /**
617 * Axis constant: Wheel axis of a motion event.
618 *
619 * - For a joystick, reports the absolute position of the steering wheel control.
620 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
621 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700622 AMOTION_EVENT_AXIS_WHEEL = 21,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700623 /**
624 * Axis constant: Gas axis of a motion event.
625 *
626 * - For a joystick, reports the absolute position of the gas (accelerator) control.
627 * The value is normalized to a range from 0.0 (no acceleration)
628 * to 1.0 (maximum acceleration).
629 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700630 AMOTION_EVENT_AXIS_GAS = 22,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700631 /**
632 * Axis constant: Brake axis of a motion event.
633 *
634 * - For a joystick, reports the absolute position of the brake control.
635 * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
636 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700637 AMOTION_EVENT_AXIS_BRAKE = 23,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700638 /**
639 * Axis constant: Distance axis of a motion event.
640 *
641 * - For a stylus, reports the distance of the stylus from the screen.
642 * A value of 0.0 indicates direct contact and larger values indicate increasing
643 * distance from the surface.
644 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700645 AMOTION_EVENT_AXIS_DISTANCE = 24,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700646 /**
647 * Axis constant: Tilt axis of a motion event.
648 *
649 * - For a stylus, reports the tilt angle of the stylus in radians where
650 * 0 radians indicates that the stylus is being held perpendicular to the
651 * surface, and PI/2 radians indicates that the stylus is being held flat
652 * against the surface.
653 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700654 AMOTION_EVENT_AXIS_TILT = 25,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700655 /**
Prashant Malani1941ff52015-08-11 18:29:28 -0700656 * Axis constant: Generic scroll axis of a motion event.
657 *
658 * - This is used for scroll axis motion events that can't be classified as strictly
659 * vertical or horizontal. The movement of a rotating scroller is an example of this.
660 */
661 AMOTION_EVENT_AXIS_SCROLL = 26,
662 /**
Jun Mukaifa1706a2015-12-03 01:14:46 -0800663 * Axis constant: The movement of x position of a motion event.
664 *
665 * - For a mouse, reports a difference of x position between the previous position.
666 * This is useful when pointer is captured, in that case the mouse pointer doesn't
667 * change the location but this axis reports the difference which allows the app
668 * to see how the mouse is moved.
669 */
670 AMOTION_EVENT_AXIS_RELATIVE_X = 27,
671 /**
672 * Axis constant: The movement of y position of a motion event.
673 *
674 * Same as {@link RELATIVE_X}, but for y position.
675 */
676 AMOTION_EVENT_AXIS_RELATIVE_Y = 28,
677 /**
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700678 * Axis constant: Generic 1 axis of a motion event.
679 * The interpretation of a generic axis is device-specific.
680 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700681 AMOTION_EVENT_AXIS_GENERIC_1 = 32,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700682 /**
683 * Axis constant: Generic 2 axis of a motion event.
684 * The interpretation of a generic axis is device-specific.
685 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700686 AMOTION_EVENT_AXIS_GENERIC_2 = 33,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700687 /**
688 * Axis constant: Generic 3 axis of a motion event.
689 * The interpretation of a generic axis is device-specific.
690 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700691 AMOTION_EVENT_AXIS_GENERIC_3 = 34,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700692 /**
693 * Axis constant: Generic 4 axis of a motion event.
694 * The interpretation of a generic axis is device-specific.
695 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700696 AMOTION_EVENT_AXIS_GENERIC_4 = 35,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700697 /**
698 * Axis constant: Generic 5 axis of a motion event.
699 * The interpretation of a generic axis is device-specific.
700 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700701 AMOTION_EVENT_AXIS_GENERIC_5 = 36,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700702 /**
703 * Axis constant: Generic 6 axis of a motion event.
704 * The interpretation of a generic axis is device-specific.
705 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700706 AMOTION_EVENT_AXIS_GENERIC_6 = 37,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700707 /**
708 * Axis constant: Generic 7 axis of a motion event.
709 * The interpretation of a generic axis is device-specific.
710 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700711 AMOTION_EVENT_AXIS_GENERIC_7 = 38,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700712 /**
713 * Axis constant: Generic 8 axis of a motion event.
714 * The interpretation of a generic axis is device-specific.
715 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700716 AMOTION_EVENT_AXIS_GENERIC_8 = 39,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700717 /**
718 * Axis constant: Generic 9 axis of a motion event.
719 * The interpretation of a generic axis is device-specific.
720 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700721 AMOTION_EVENT_AXIS_GENERIC_9 = 40,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700722 /**
723 * Axis constant: Generic 10 axis of a motion event.
724 * The interpretation of a generic axis is device-specific.
725 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700726 AMOTION_EVENT_AXIS_GENERIC_10 = 41,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700727 /**
728 * Axis constant: Generic 11 axis of a motion event.
729 * The interpretation of a generic axis is device-specific.
730 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700731 AMOTION_EVENT_AXIS_GENERIC_11 = 42,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700732 /**
733 * Axis constant: Generic 12 axis of a motion event.
734 * The interpretation of a generic axis is device-specific.
735 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700736 AMOTION_EVENT_AXIS_GENERIC_12 = 43,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700737 /**
738 * Axis constant: Generic 13 axis of a motion event.
739 * The interpretation of a generic axis is device-specific.
740 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700741 AMOTION_EVENT_AXIS_GENERIC_13 = 44,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700742 /**
743 * Axis constant: Generic 14 axis of a motion event.
744 * The interpretation of a generic axis is device-specific.
745 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700746 AMOTION_EVENT_AXIS_GENERIC_14 = 45,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700747 /**
748 * Axis constant: Generic 15 axis of a motion event.
749 * The interpretation of a generic axis is device-specific.
750 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700751 AMOTION_EVENT_AXIS_GENERIC_15 = 46,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700752 /**
753 * Axis constant: Generic 16 axis of a motion event.
754 * The interpretation of a generic axis is device-specific.
755 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700756 AMOTION_EVENT_AXIS_GENERIC_16 = 47,
757
758 // NOTE: If you add a new axis here you must also add it to several other files.
759 // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
760};
761
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700762/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700763 * Constants that identify buttons that are associated with motion events.
764 * Refer to the documentation on the MotionEvent class for descriptions of each button.
765 */
766enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700767 /** primary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700768 AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700769 /** secondary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700770 AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700771 /** tertiary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700772 AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700773 /** back */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700774 AMOTION_EVENT_BUTTON_BACK = 1 << 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700775 /** forward */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700776 AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
Michael Wright7b159c92015-05-14 14:48:03 +0100777 AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
778 AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700779};
780
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700781/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700782 * Constants that identify tool types.
783 * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
784 */
785enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700786 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700787 AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700788 /** finger */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700789 AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700790 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700791 AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700792 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700793 AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700794 /** eraser */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700795 AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
796};
797
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700798/**
799 * Input source masks.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700800 *
801 * Refer to the documentation on android.view.InputDevice for more details about input sources
802 * and their correct interpretation.
803 */
804enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700805 /** mask */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700806 AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
807
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700808 /** none */
Michael Wrightaadaca72013-03-11 14:20:14 -0700809 AINPUT_SOURCE_CLASS_NONE = 0x00000000,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700810 /** button */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700811 AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700812 /** pointer */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700813 AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700814 /** navigation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700815 AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700816 /** position */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700817 AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700818 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700819 AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
820};
821
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700822/**
823 * Input sources.
824 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700825enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700826 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700827 AINPUT_SOURCE_UNKNOWN = 0x00000000,
828
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700829 /** keyboard */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700830 AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700831 /** dpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700832 AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700833 /** gamepad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700834 AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700835 /** touchscreen */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700836 AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700837 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700838 AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700839 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700840 AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
Michael Wright7d3ad692015-06-23 19:04:31 +0100841 /** bluetooth stylus */
Michael Wright2f78b682015-06-12 15:25:08 +0100842 AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700843 /** trackball */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700844 AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Vladislav Kaznacheev78f97b32016-12-15 18:14:58 -0800845 /** mouse relative */
846 AINPUT_SOURCE_MOUSE_RELATIVE = 0x00020000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700847 /** touchpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700848 AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700849 /** navigation */
Michael Wrightaadaca72013-03-11 14:20:14 -0700850 AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700851 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700852 AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
Prashant Malani1941ff52015-08-11 18:29:28 -0700853 /** rotary encoder */
854 AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700855
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700856 /** any */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700857 AINPUT_SOURCE_ANY = 0xffffff00,
858};
859
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700860/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700861 * Keyboard types.
862 *
863 * Refer to the documentation on android.view.InputDevice for more details.
864 */
865enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700866 /** none */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700867 AINPUT_KEYBOARD_TYPE_NONE = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700868 /** non alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700869 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700870 /** alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700871 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
872};
873
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700874/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700875 * Constants used to retrieve information about the range of motion for a particular
876 * coordinate of a motion event.
877 *
878 * Refer to the documentation on android.view.InputDevice for more details about input sources
879 * and their correct interpretation.
880 *
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700881 * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700882 */
883enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700884 /** x */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700885 AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700886 /** y */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700887 AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700888 /** pressure */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700889 AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700890 /** size */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700891 AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700892 /** touch major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700893 AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700894 /** touch minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700895 AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700896 /** tool major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700897 AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700898 /** tool minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700899 AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700900 /** orientation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700901 AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700902};
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700903
904
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700905/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700906 * Input event accessors.
907 *
908 * Note that most functions can only be used on input events that are of a given type.
909 * Calling these functions on input events of other types will yield undefined behavior.
910 */
911
912/*** Accessors for all input events. ***/
913
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700914/** Get the input event type. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700915int32_t AInputEvent_getType(const AInputEvent* event);
916
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700917/** Get the id for the device that an input event came from.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700918 *
919 * Input events can be generated by multiple different input devices.
920 * Use the input device id to obtain information about the input
921 * device that was responsible for generating a particular event.
922 *
923 * An input device id of 0 indicates that the event didn't come from a physical device;
924 * other numbers are arbitrary and you shouldn't depend on the values.
925 * Use the provided input device query API to obtain information about input devices.
926 */
927int32_t AInputEvent_getDeviceId(const AInputEvent* event);
928
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700929/** Get the input event source. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700930int32_t AInputEvent_getSource(const AInputEvent* event);
931
932/*** Accessors for key events only. ***/
933
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700934/** Get the key event action. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700935int32_t AKeyEvent_getAction(const AInputEvent* key_event);
936
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700937/** Get the key event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700938int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
939
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700940/**
941 * Get the key code of the key event.
942 * This is the physical key that was pressed, not the Unicode character.
943 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700944int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
945
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700946/**
947 * Get the hardware key id of this key event.
948 * These values are not reliable and vary from device to device.
949 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700950int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
951
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700952/** Get the meta key state. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700953int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
954
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700955/**
956 * Get the repeat count of the event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700957 * For both key up an key down events, this is the number of times the key has
958 * repeated with the first down starting at 0 and counting up from there. For
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700959 * multiple key events, this is the number of down/up pairs that have occurred.
960 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700961int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
962
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700963/**
964 * Get the time of the most recent key down event, in the
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700965 * java.lang.System.nanoTime() time base. If this is a down event,
966 * this will be the same as eventTime.
967 * Note that when chording keys, this value is the down time of the most recently
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700968 * pressed key, which may not be the same physical key of this event.
969 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700970int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
971
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700972/**
973 * Get the time this event occurred, in the
974 * java.lang.System.nanoTime() time base.
975 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700976int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
977
978/*** Accessors for motion events only. ***/
979
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700980/** Get the combined motion event action code and pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700981int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
982
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700983/** Get the motion event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700984int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
985
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700986/**
987 * Get the state of any meta / modifier keys that were in effect when the
988 * event was generated.
989 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700990int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
991
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700992/** Get the button state of all buttons that are pressed. */
Elliott Hughes3d70e532019-10-29 08:59:39 -0700993int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700994
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700995/**
996 * Get a bitfield indicating which edges, if any, were touched by this motion event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700997 * For touch events, clients can use this to determine if the user's finger was
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700998 * touching the edge of the display.
999 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001000int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
1001
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001002/**
1003 * Get the time when the user originally pressed down to start a stream of
1004 * position events, in the java.lang.System.nanoTime() time base.
1005 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001006int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
1007
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001008/**
1009 * Get the time when this specific event was generated,
1010 * in the java.lang.System.nanoTime() time base.
1011 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001012int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
1013
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001014/**
1015 * Get the X coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001016 * For touch events on the screen, this is the delta that was added to the raw
1017 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001018 * and views.
1019 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001020float AMotionEvent_getXOffset(const AInputEvent* motion_event);
1021
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001022/**
1023 * Get the Y coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001024 * For touch events on the screen, this is the delta that was added to the raw
1025 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001026 * and views.
1027 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001028float AMotionEvent_getYOffset(const AInputEvent* motion_event);
1029
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001030/**
1031 * Get the precision of the X coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001032 * You can multiply this number with an X coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001033 * actual hardware value of the X coordinate.
1034 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001035float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
1036
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001037/**
1038 * Get the precision of the Y coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001039 * You can multiply this number with a Y coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001040 * actual hardware value of the Y coordinate.
1041 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001042float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
1043
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001044/**
1045 * Get the number of pointers of data contained in this event.
1046 * Always >= 1.
1047 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001048size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
1049
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001050/**
1051 * Get the pointer identifier associated with a particular pointer
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001052 * data index in this event. The identifier tells you the actual pointer
1053 * number associated with the data, accounting for individual pointers
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001054 * going up and down since the start of the current gesture.
1055 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001056int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
1057
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001058/**
1059 * Get the tool type of a pointer for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001060 * The tool type indicates the type of tool used to make contact such as a
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001061 * finger or stylus, if known.
1062 */
Elliott Hughes3d70e532019-10-29 08:59:39 -07001063int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001064
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001065/**
1066 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001067 * For touch events on the screen, this is the original location of the event
1068 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001069 * and views.
1070 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001071float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
1072
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001073/**
1074 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001075 * For touch events on the screen, this is the original location of the event
1076 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001077 * and views.
1078 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001079float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
1080
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001081/**
1082 * Get the current X coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001083 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001084 * that are sub-pixel precise.
1085 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001086float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
1087
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001088/**
1089 * Get the current Y coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001090 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001091 * that are sub-pixel precise.
1092 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001093float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
1094
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001095/**
1096 * Get the current pressure of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001097 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1098 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001099 * the input device.
1100 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001101float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
1102
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001103/**
1104 * Get the current scaled value of the approximate size for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001105 * This represents some approximation of the area of the screen being
1106 * pressed; the actual value in pixels corresponding to the
1107 * touch is normalized with the device specific range of values
1108 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001109 * determine fat touch events.
1110 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001111float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
1112
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001113/**
1114 * Get the current length of the major axis of an ellipse that describes the touch area
1115 * at the point of contact for the given pointer index.
1116 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001117float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
1118
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001119/**
1120 * Get the current length of the minor axis of an ellipse that describes the touch area
1121 * at the point of contact for the given pointer index.
1122 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001123float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
1124
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001125/**
1126 * Get the current length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001127 * of the approaching tool for the given pointer index.
1128 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001129 * touching the device independent of its actual touch area at the point of contact.
1130 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001131float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
1132
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001133/**
1134 * Get the current length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001135 * of the approaching tool for the given pointer index.
1136 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001137 * touching the device independent of its actual touch area at the point of contact.
1138 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001139float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
1140
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001141/**
1142 * Get the current orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001143 * vertical for the given pointer index.
1144 * An angle of 0 degrees indicates that the major axis of contact is oriented
1145 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1146 * indicates that the major axis of contact is oriented to the right. A negative angle
1147 * indicates that the major axis of contact is oriented to the left.
1148 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001149 * (finger pointing fully right).
1150 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001151float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
1152
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001153/** Get the value of the request axis for the given pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001154float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001155 int32_t axis, size_t pointer_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001156
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001157/**
1158 * Get the number of historical points in this event. These are movements that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001159 * have occurred between this event and the previous event. This only applies
1160 * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001161 * Historical samples are indexed from oldest to newest.
1162 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001163size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
1164
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001165/**
1166 * Get the time that a historical movement occurred between this event and
1167 * the previous event, in the java.lang.System.nanoTime() time base.
1168 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001169int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001170 size_t history_index);
1171
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001172/**
1173 * Get the historical raw X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001174 * occurred between this event and the previous motion event.
1175 * For touch events on the screen, this is the original location of the event
1176 * on the screen, before it had been adjusted for the containing window
1177 * and views.
1178 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001179 * that are sub-pixel precise.
1180 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001181float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
1182 size_t history_index);
1183
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001184/**
1185 * Get the historical raw Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001186 * occurred between this event and the previous motion event.
1187 * For touch events on the screen, this is the original location of the event
1188 * on the screen, before it had been adjusted for the containing window
1189 * and views.
1190 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001191 * that are sub-pixel precise.
1192 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001193float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
1194 size_t history_index);
1195
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001196/**
1197 * Get the historical X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001198 * occurred between this event and the previous motion event.
1199 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001200 * that are sub-pixel precise.
1201 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001202float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001203 size_t history_index);
1204
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001205/**
1206 * Get the historical Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001207 * occurred between this event and the previous motion event.
1208 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001209 * that are sub-pixel precise.
1210 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001211float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001212 size_t history_index);
1213
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001214/**
1215 * Get the historical pressure of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001216 * occurred between this event and the previous motion event.
1217 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1218 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001219 * the input device.
1220 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001221float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001222 size_t history_index);
1223
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001224/**
1225 * Get the current scaled value of the approximate size for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001226 * occurred between this event and the previous motion event.
1227 * This represents some approximation of the area of the screen being
1228 * pressed; the actual value in pixels corresponding to the
1229 * touch is normalized with the device specific range of values
1230 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001231 * determine fat touch events.
1232 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001233float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001234 size_t history_index);
1235
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001236/**
1237 * Get the historical length of the major axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001238 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001239 * occurred between this event and the previous motion event.
1240 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001241float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
1242 size_t history_index);
1243
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001244/**
1245 * Get the historical length of the minor axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001246 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001247 * occurred between this event and the previous motion event.
1248 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001249float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
1250 size_t history_index);
1251
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001252/**
1253 * Get the historical length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001254 * of the approaching tool for the given pointer index that
1255 * occurred between this event and the previous motion event.
1256 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001257 * touching the device independent of its actual touch area at the point of contact.
1258 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001259float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
1260 size_t history_index);
1261
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001262/**
1263 * Get the historical length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001264 * of the approaching tool for the given pointer index that
1265 * occurred between this event and the previous motion event.
1266 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001267 * touching the device independent of its actual touch area at the point of contact.
1268 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001269float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
1270 size_t history_index);
1271
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001272/**
1273 * Get the historical orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001274 * vertical for the given pointer index that
1275 * occurred between this event and the previous motion event.
1276 * An angle of 0 degrees indicates that the major axis of contact is oriented
1277 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1278 * indicates that the major axis of contact is oriented to the right. A negative angle
1279 * indicates that the major axis of contact is oriented to the left.
1280 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001281 * (finger pointing fully right).
1282 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001283float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
1284 size_t history_index);
1285
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001286/**
1287 * Get the historical value of the request axis for the given pointer index
1288 * that occurred between this event and the previous motion event.
1289 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001290float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
Elliott Hughes3d70e532019-10-29 08:59:39 -07001291 int32_t axis, size_t pointer_index, size_t history_index);
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001292
1293
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001294struct AInputQueue;
1295/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001296 * Input queue
1297 *
1298 * An input queue is the facility through which you retrieve input
1299 * events.
1300 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001301typedef struct AInputQueue AInputQueue;
1302
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001303/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001304 * Add this input queue to a looper for processing. See
1305 * ALooper_addFd() for information on the ident, callback, and data params.
1306 */
1307void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
1308 int ident, ALooper_callbackFunc callback, void* data);
1309
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001310/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001311 * Remove the input queue from the looper it is currently attached to.
1312 */
1313void AInputQueue_detachLooper(AInputQueue* queue);
1314
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001315/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001316 * Returns true if there are one or more events available in the
1317 * input queue. Returns 1 if the queue has events; 0 if
1318 * it does not have events; and a negative value if there is an error.
1319 */
1320int32_t AInputQueue_hasEvents(AInputQueue* queue);
1321
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001322/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001323 * Returns the next available event from the queue. Returns a negative
1324 * value if no events are available or an error has occurred.
1325 */
1326int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
1327
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001328/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001329 * Sends the key for standard pre-dispatching -- that is, possibly deliver
1330 * it to the current IME to be consumed before the app. Returns 0 if it
1331 * was not pre-dispatched, meaning you can process it right now. If non-zero
1332 * is returned, you must abandon the current event processing and allow the
1333 * event to appear again in the event queue (if it does not get consumed during
1334 * pre-dispatching).
1335 */
1336int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
1337
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001338/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001339 * Report that dispatching has finished with the given event.
1340 * This must be called after receiving an event with AInputQueue_get_event().
1341 */
1342void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
1343
1344#ifdef __cplusplus
1345}
1346#endif
1347
1348#endif // _ANDROID_INPUT_H
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001349
1350/** @} */