blob: 95d25d3dda2f960921cd409a42abea64f6b74223 [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
29/******************************************************************
30 *
31 * IMPORTANT NOTICE:
32 *
33 * This file is part of Android's set of stable system headers
34 * exposed by the Android NDK (Native Development Kit).
35 *
36 * Third-party source AND binary code relies on the definitions
37 * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
38 *
39 * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
40 * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
41 * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
42 * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
43 */
44
45/*
46 * Structures and functions to receive and process input events in
47 * native code.
48 *
49 * NOTE: These functions MUST be implemented by /system/lib/libui.so
50 */
51
52#include <stdint.h>
53#include <sys/types.h>
54#include <android/keycodes.h>
55#include <android/looper.h>
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070061/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070062 * Key states (may be returned by queries about the current state of a
63 * particular key code, scan code or switch).
64 */
65enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070066 /** The key state is unknown or the requested key itself is not supported. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070067 AKEY_STATE_UNKNOWN = -1,
68
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070069 /** The key is up. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070070 AKEY_STATE_UP = 0,
71
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070072 /** The key is down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070073 AKEY_STATE_DOWN = 1,
74
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070075 /** The key is down but is a virtual key press that is being emulated by the system. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070076 AKEY_STATE_VIRTUAL = 2
77};
78
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070079/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070080 * Meta key / modifer state.
81 */
82enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070083 /** No meta keys are pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070084 AMETA_NONE = 0,
85
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070086 /** This mask is used to check whether one of the ALT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070087 AMETA_ALT_ON = 0x02,
88
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070089 /** This mask is used to check whether the left ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070090 AMETA_ALT_LEFT_ON = 0x10,
91
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070092 /** This mask is used to check whether the right ALT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070093 AMETA_ALT_RIGHT_ON = 0x20,
94
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070095 /** This mask is used to check whether one of the SHIFT meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070096 AMETA_SHIFT_ON = 0x01,
97
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070098 /** This mask is used to check whether the left SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070099 AMETA_SHIFT_LEFT_ON = 0x40,
100
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700101 /** This mask is used to check whether the right SHIFT meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700102 AMETA_SHIFT_RIGHT_ON = 0x80,
103
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700104 /** This mask is used to check whether the SYM meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700105 AMETA_SYM_ON = 0x04,
106
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700107 /** This mask is used to check whether the FUNCTION meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700108 AMETA_FUNCTION_ON = 0x08,
109
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700110 /** This mask is used to check whether one of the CTRL meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700111 AMETA_CTRL_ON = 0x1000,
112
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700113 /** This mask is used to check whether the left CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700114 AMETA_CTRL_LEFT_ON = 0x2000,
115
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700116 /** This mask is used to check whether the right CTRL meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700117 AMETA_CTRL_RIGHT_ON = 0x4000,
118
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700119 /** This mask is used to check whether one of the META meta keys is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700120 AMETA_META_ON = 0x10000,
121
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700122 /** This mask is used to check whether the left META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700123 AMETA_META_LEFT_ON = 0x20000,
124
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700125 /** This mask is used to check whether the right META meta key is pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700126 AMETA_META_RIGHT_ON = 0x40000,
127
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700128 /** This mask is used to check whether the CAPS LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700129 AMETA_CAPS_LOCK_ON = 0x100000,
130
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700131 /** This mask is used to check whether the NUM LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700132 AMETA_NUM_LOCK_ON = 0x200000,
133
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700134 /** This mask is used to check whether the SCROLL LOCK meta key is on. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700135 AMETA_SCROLL_LOCK_ON = 0x400000,
136};
137
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700138struct AInputEvent;
139/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700140 * Input events.
141 *
142 * Input events are opaque structures. Use the provided accessors functions to
143 * read their properties.
144 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700145typedef struct AInputEvent AInputEvent;
146
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700147/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700148 * Input event types.
149 */
150enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700151 /** Indicates that the input event is a key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700152 AINPUT_EVENT_TYPE_KEY = 1,
153
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700154 /** Indicates that the input event is a motion event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700155 AINPUT_EVENT_TYPE_MOTION = 2
156};
157
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700158/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700159 * Key event actions.
160 */
161enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700162 /** The key has been pressed down. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700163 AKEY_EVENT_ACTION_DOWN = 0,
164
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700165 /** The key has been released. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700166 AKEY_EVENT_ACTION_UP = 1,
167
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700168 /**
169 * Multiple duplicate key events have occurred in a row, or a
170 * complex string is being delivered. The repeat_count property
171 * of the key event contains the number of times the given key
172 * code should be executed.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700173 */
174 AKEY_EVENT_ACTION_MULTIPLE = 2
175};
176
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700177/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700178 * Key event flags.
179 */
180enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700181 /** This mask is set if the device woke because of this key event. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700182 AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
183
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700184 /** This mask is set if the key event was generated by a software keyboard. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700185 AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
186
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700187 /** 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 -0700188 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
189
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700190 /**
191 * This mask is set if an event was known to come from a trusted
192 * part of the system. That is, the event is known to come from
193 * the user, and could not have been spoofed by a third party
194 * component.
195 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700196 AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
197
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700198 /**
199 * This mask is used for compatibility, to identify enter keys that are
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700200 * coming from an IME whose enter key has been auto-labelled "next" or
201 * "done". This allows TextView to dispatch these as normal enter keys
202 * for old applications, but still do the appropriate action when
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700203 * receiving them.
204 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700205 AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
206
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700207 /**
208 * When associated with up key events, this indicates that the key press
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700209 * has been canceled. Typically this is used with virtual touch screen
210 * keys, where the user can slide from the virtual key area on to the
211 * display: in that case, the application will receive a canceled up
212 * event and should not perform the action normally associated with the
213 * key. Note that for this to work, the application can not perform an
214 * action for a key until it receives an up or the long press timeout has
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700215 * expired.
216 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700217 AKEY_EVENT_FLAG_CANCELED = 0x20,
218
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700219 /**
220 * This key event was generated by a virtual (on-screen) hard key area.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700221 * Typically this is an area of the touchscreen, outside of the regular
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700222 * display, dedicated to "hardware" buttons.
223 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700224 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
225
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700226 /**
227 * This flag is set for the first key repeat that occurs after the
228 * long press timeout.
229 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700230 AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
231
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700232 /**
233 * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
234 * press action was executed while it was down.
235 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700236 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
237
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700238 /**
239 * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700240 * tracked from its initial down. That is, somebody requested that tracking
241 * started on the key down and a long press has not caused
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700242 * the tracking to be canceled.
243 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700244 AKEY_EVENT_FLAG_TRACKING = 0x200,
245
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700246 /**
247 * Set when a key event has been synthesized to implement default behavior
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700248 * for an event that the application did not handle.
249 * Fallback key events are generated by unhandled trackball motions
250 * (to emulate a directional keypad) and by certain unhandled key presses
251 * that are declared in the key map (such as special function numeric keypad
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700252 * keys when numlock is off).
253 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700254 AKEY_EVENT_FLAG_FALLBACK = 0x400,
255};
256
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700257/**
258 * Bit shift for the action bits holding the pointer index as
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700259 * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
260 */
261#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
262
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700263/** Motion event actions */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700264enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700265 /** Bit mask of the parts of the action code that are the action itself. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700266 AMOTION_EVENT_ACTION_MASK = 0xff,
267
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700268 /**
269 * Bits in the action code that represent a pointer index, used with
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700270 * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
271 * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
272 * index where the data for the pointer going up or down can be found.
273 */
274 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
275
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700276 /** A pressed gesture has started, the motion contains the initial starting location. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700277 AMOTION_EVENT_ACTION_DOWN = 0,
278
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700279 /**
280 * A pressed gesture has finished, the motion contains the final release location
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700281 * as well as any intermediate points since the last down or move event.
282 */
283 AMOTION_EVENT_ACTION_UP = 1,
284
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700285 /**
286 * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700287 * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
288 * any intermediate points since the last down or move event.
289 */
290 AMOTION_EVENT_ACTION_MOVE = 2,
291
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700292 /**
293 * The current gesture has been aborted.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700294 * You will not receive any more points in it. You should treat this as
295 * an up event, but not perform any action that you normally would.
296 */
297 AMOTION_EVENT_ACTION_CANCEL = 3,
298
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700299 /**
300 * A movement has happened outside of the normal bounds of the UI element.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700301 * This does not provide a full gesture, but only the initial location of the movement/touch.
302 */
303 AMOTION_EVENT_ACTION_OUTSIDE = 4,
304
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700305 /**
306 * A non-primary pointer has gone down.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700307 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
308 */
309 AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
310
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700311 /**
312 * A non-primary pointer has gone up.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700313 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
314 */
315 AMOTION_EVENT_ACTION_POINTER_UP = 6,
316
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700317 /**
318 * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700319 * The motion contains the most recent point, as well as any intermediate points since
320 * the last hover move event.
321 */
322 AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
323
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700324 /**
325 * The motion event contains relative vertical and/or horizontal scroll offsets.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700326 * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
327 * and AMOTION_EVENT_AXIS_HSCROLL.
328 * The pointer may or may not be down when this event is dispatched.
329 * This action is always delivered to the winder under the pointer, which
330 * may not be the window currently touched.
331 */
332 AMOTION_EVENT_ACTION_SCROLL = 8,
333
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700334 /** The pointer is not down but has entered the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700335 AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
336
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700337 /** The pointer is not down but has exited the boundaries of a window or view. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700338 AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
Michael Wright7b159c92015-05-14 14:48:03 +0100339
340 /* One or more buttons have been pressed. */
341 AMOTION_EVENT_ACTION_BUTTON_PRESS = 11,
342
343 /* One or more buttons have been released. */
344 AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700345};
346
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700347/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700348 * Motion event flags.
349 */
350enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700351 /**
352 * This flag indicates that the window that received this motion event is partly
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700353 * or wholly obscured by another visible window above it. This flag is set to true
354 * even if the event did not directly pass through the obscured area.
355 * A security sensitive application can check this flag to identify situations in which
356 * a malicious application may have covered up part of its content for the purpose
357 * of misleading the user or hijacking touches. An appropriate response might be
358 * to drop the suspect touches or to take additional precautions to confirm the user's
359 * actual intent.
360 */
361 AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
362};
363
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700364/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700365 * Motion event edge touch flags.
366 */
367enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700368 /** No edges intersected. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700369 AMOTION_EVENT_EDGE_FLAG_NONE = 0,
370
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700371 /** Flag indicating the motion event intersected the top edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700372 AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
373
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700374 /** Flag indicating the motion event intersected the bottom edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700375 AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
376
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700377 /** Flag indicating the motion event intersected the left edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700378 AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
379
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700380 /** Flag indicating the motion event intersected the right edge of the screen. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700381 AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
382};
383
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700384/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700385 * Constants that identify each individual axis of a motion event.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700386 * @anchor AMOTION_EVENT_AXIS
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700387 */
388enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700389 /**
390 * Axis constant: X axis of a motion event.
391 *
392 * - For a touch screen, reports the absolute X screen position of the center of
393 * the touch contact area. The units are display pixels.
394 * - For a touch pad, reports the absolute X surface position of the center of the touch
395 * contact area. The units are device-dependent.
396 * - For a mouse, reports the absolute X screen position of the mouse pointer.
397 * The units are display pixels.
398 * - For a trackball, reports the relative horizontal displacement of the trackball.
399 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
400 * - For a joystick, reports the absolute X position of the joystick.
401 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
402 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700403 AMOTION_EVENT_AXIS_X = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700404 /**
405 * Axis constant: Y axis of a motion event.
406 *
407 * - For a touch screen, reports the absolute Y screen position of the center of
408 * the touch contact area. The units are display pixels.
409 * - For a touch pad, reports the absolute Y surface position of the center of the touch
410 * contact area. The units are device-dependent.
411 * - For a mouse, reports the absolute Y screen position of the mouse pointer.
412 * The units are display pixels.
413 * - For a trackball, reports the relative vertical displacement of the trackball.
414 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
415 * - For a joystick, reports the absolute Y position of the joystick.
416 * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
417 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700418 AMOTION_EVENT_AXIS_Y = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700419 /**
420 * Axis constant: Pressure axis of a motion event.
421 *
422 * - For a touch screen or touch pad, reports the approximate pressure applied to the surface
423 * by a finger or other tool. The value is normalized to a range from
424 * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
425 * may be generated depending on the calibration of the input device.
426 * - For a trackball, the value is set to 1 if the trackball button is pressed
427 * or 0 otherwise.
428 * - For a mouse, the value is set to 1 if the primary mouse button is pressed
429 * or 0 otherwise.
430 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700431 AMOTION_EVENT_AXIS_PRESSURE = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700432 /**
433 * Axis constant: Size axis of a motion event.
434 *
435 * - For a touch screen or touch pad, reports the approximate size of the contact area in
436 * relation to the maximum detectable size for the device. The value is normalized
437 * to a range from 0 (smallest detectable size) to 1 (largest detectable size),
438 * although it is not a linear scale. This value is of limited use.
439 * To obtain calibrated size information, see
440 * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}.
441 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700442 AMOTION_EVENT_AXIS_SIZE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700443 /**
444 * Axis constant: TouchMajor axis of a motion event.
445 *
446 * - For a touch screen, reports the length of the major axis of an ellipse that
447 * represents the touch area at the point of contact.
448 * The units are display pixels.
449 * - For a touch pad, reports the length of the major axis of an ellipse that
450 * represents the touch area at the point of contact.
451 * The units are device-dependent.
452 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700453 AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700454 /**
455 * Axis constant: TouchMinor axis of a motion event.
456 *
457 * - For a touch screen, reports the length of the minor axis of an ellipse that
458 * represents the touch area at the point of contact.
459 * The units are display pixels.
460 * - For a touch pad, reports the length of the minor axis of an ellipse that
461 * represents the touch area at the point of contact.
462 * The units are device-dependent.
463 *
464 * When the touch is circular, the major and minor axis lengths will be equal to one another.
465 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700466 AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700467 /**
468 * Axis constant: ToolMajor axis of a motion event.
469 *
470 * - For a touch screen, reports the length of the major axis of an ellipse that
471 * represents the size of the approaching finger or tool used to make contact.
472 * - For a touch pad, reports the length of the major axis of an ellipse that
473 * represents the size of the approaching finger or tool used to make contact.
474 * The units are device-dependent.
475 *
476 * When the touch is circular, the major and minor axis lengths will be equal to one another.
477 *
478 * The tool size may be larger than the touch size since the tool may not be fully
479 * in contact with the touch sensor.
480 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700481 AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700482 /**
483 * Axis constant: ToolMinor axis of a motion event.
484 *
485 * - For a touch screen, reports the length of the minor axis of an ellipse that
486 * represents the size of the approaching finger or tool used to make contact.
487 * - For a touch pad, reports the length of the minor axis of an ellipse that
488 * represents the size of the approaching finger or tool used to make contact.
489 * The units are device-dependent.
490 *
491 * When the touch is circular, the major and minor axis lengths will be equal to one another.
492 *
493 * The tool size may be larger than the touch size since the tool may not be fully
494 * in contact with the touch sensor.
495 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700496 AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700497 /**
498 * Axis constant: Orientation axis of a motion event.
499 *
500 * - For a touch screen or touch pad, reports the orientation of the finger
501 * or tool in radians relative to the vertical plane of the device.
502 * An angle of 0 radians indicates that the major axis of contact is oriented
503 * upwards, is perfectly circular or is of unknown orientation. A positive angle
504 * indicates that the major axis of contact is oriented to the right. A negative angle
505 * indicates that the major axis of contact is oriented to the left.
506 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
507 * (finger pointing fully right).
508 * - For a stylus, the orientation indicates the direction in which the stylus
509 * is pointing in relation to the vertical axis of the current orientation of the screen.
510 * The range is from -PI radians to PI radians, where 0 is pointing up,
511 * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
512 * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}.
513 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700514 AMOTION_EVENT_AXIS_ORIENTATION = 8,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700515 /**
516 * Axis constant: Vertical Scroll axis of a motion event.
517 *
518 * - For a mouse, reports the relative movement of the vertical scroll wheel.
519 * The value is normalized to a range from -1.0 (down) to 1.0 (up).
520 *
521 * This axis should be used to scroll views vertically.
522 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700523 AMOTION_EVENT_AXIS_VSCROLL = 9,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700524 /**
525 * Axis constant: Horizontal Scroll axis of a motion event.
526 *
527 * - For a mouse, reports the relative movement of the horizontal scroll wheel.
528 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
529 *
530 * This axis should be used to scroll views horizontally.
531 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700532 AMOTION_EVENT_AXIS_HSCROLL = 10,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700533 /**
534 * Axis constant: Z axis of a motion event.
535 *
536 * - For a joystick, reports the absolute Z position of the joystick.
537 * The value is normalized to a range from -1.0 (high) to 1.0 (low).
538 * <em>On game pads with two analog joysticks, this axis is often reinterpreted
539 * to report the absolute X position of the second joystick instead.</em>
540 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700541 AMOTION_EVENT_AXIS_Z = 11,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700542 /**
543 * Axis constant: X Rotation axis of a motion event.
544 *
545 * - For a joystick, reports the absolute rotation angle about the X axis.
546 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
547 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700548 AMOTION_EVENT_AXIS_RX = 12,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700549 /**
550 * Axis constant: Y Rotation axis of a motion event.
551 *
552 * - For a joystick, reports the absolute rotation angle about the Y axis.
553 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
554 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700555 AMOTION_EVENT_AXIS_RY = 13,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700556 /**
557 * Axis constant: Z Rotation axis of a motion event.
558 *
559 * - For a joystick, reports the absolute rotation angle about the Z axis.
560 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
561 * On game pads with two analog joysticks, this axis is often reinterpreted
562 * to report the absolute Y position of the second joystick instead.
563 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700564 AMOTION_EVENT_AXIS_RZ = 14,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700565 /**
566 * Axis constant: Hat X axis of a motion event.
567 *
568 * - For a joystick, reports the absolute X position of the directional hat control.
569 * The value is normalized to a range from -1.0 (left) to 1.0 (right).
570 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700571 AMOTION_EVENT_AXIS_HAT_X = 15,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700572 /**
573 * Axis constant: Hat Y axis of a motion event.
574 *
575 * - For a joystick, reports the absolute Y position of the directional hat control.
576 * The value is normalized to a range from -1.0 (up) to 1.0 (down).
577 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700578 AMOTION_EVENT_AXIS_HAT_Y = 16,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700579 /**
580 * Axis constant: Left Trigger axis of a motion event.
581 *
582 * - For a joystick, reports the absolute position of the left trigger control.
583 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
584 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700585 AMOTION_EVENT_AXIS_LTRIGGER = 17,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700586 /**
587 * Axis constant: Right Trigger axis of a motion event.
588 *
589 * - For a joystick, reports the absolute position of the right trigger control.
590 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
591 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700592 AMOTION_EVENT_AXIS_RTRIGGER = 18,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700593 /**
594 * Axis constant: Throttle axis of a motion event.
595 *
596 * - For a joystick, reports the absolute position of the throttle control.
597 * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
598 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700599 AMOTION_EVENT_AXIS_THROTTLE = 19,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700600 /**
601 * Axis constant: Rudder axis of a motion event.
602 *
603 * - For a joystick, reports the absolute position of the rudder control.
604 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
605 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700606 AMOTION_EVENT_AXIS_RUDDER = 20,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700607 /**
608 * Axis constant: Wheel axis of a motion event.
609 *
610 * - For a joystick, reports the absolute position of the steering wheel control.
611 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
612 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700613 AMOTION_EVENT_AXIS_WHEEL = 21,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700614 /**
615 * Axis constant: Gas axis of a motion event.
616 *
617 * - For a joystick, reports the absolute position of the gas (accelerator) control.
618 * The value is normalized to a range from 0.0 (no acceleration)
619 * to 1.0 (maximum acceleration).
620 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700621 AMOTION_EVENT_AXIS_GAS = 22,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700622 /**
623 * Axis constant: Brake axis of a motion event.
624 *
625 * - For a joystick, reports the absolute position of the brake control.
626 * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
627 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700628 AMOTION_EVENT_AXIS_BRAKE = 23,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700629 /**
630 * Axis constant: Distance axis of a motion event.
631 *
632 * - For a stylus, reports the distance of the stylus from the screen.
633 * A value of 0.0 indicates direct contact and larger values indicate increasing
634 * distance from the surface.
635 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700636 AMOTION_EVENT_AXIS_DISTANCE = 24,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700637 /**
638 * Axis constant: Tilt axis of a motion event.
639 *
640 * - For a stylus, reports the tilt angle of the stylus in radians where
641 * 0 radians indicates that the stylus is being held perpendicular to the
642 * surface, and PI/2 radians indicates that the stylus is being held flat
643 * against the surface.
644 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700645 AMOTION_EVENT_AXIS_TILT = 25,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700646 /**
Jun Mukaifa1706a2015-12-03 01:14:46 -0800647 * Axis constant: The movement of x position of a motion event.
648 *
649 * - For a mouse, reports a difference of x position between the previous position.
650 * This is useful when pointer is captured, in that case the mouse pointer doesn't
651 * change the location but this axis reports the difference which allows the app
652 * to see how the mouse is moved.
653 */
654 AMOTION_EVENT_AXIS_RELATIVE_X = 27,
655 /**
656 * Axis constant: The movement of y position of a motion event.
657 *
658 * Same as {@link RELATIVE_X}, but for y position.
659 */
660 AMOTION_EVENT_AXIS_RELATIVE_Y = 28,
661 /**
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700662 * Axis constant: Generic 1 axis of a motion event.
663 * The interpretation of a generic axis is device-specific.
664 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700665 AMOTION_EVENT_AXIS_GENERIC_1 = 32,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700666 /**
667 * Axis constant: Generic 2 axis of a motion event.
668 * The interpretation of a generic axis is device-specific.
669 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700670 AMOTION_EVENT_AXIS_GENERIC_2 = 33,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700671 /**
672 * Axis constant: Generic 3 axis of a motion event.
673 * The interpretation of a generic axis is device-specific.
674 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700675 AMOTION_EVENT_AXIS_GENERIC_3 = 34,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700676 /**
677 * Axis constant: Generic 4 axis of a motion event.
678 * The interpretation of a generic axis is device-specific.
679 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700680 AMOTION_EVENT_AXIS_GENERIC_4 = 35,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700681 /**
682 * Axis constant: Generic 5 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_5 = 36,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700686 /**
687 * Axis constant: Generic 6 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_6 = 37,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700691 /**
692 * Axis constant: Generic 7 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_7 = 38,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700696 /**
697 * Axis constant: Generic 8 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_8 = 39,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700701 /**
702 * Axis constant: Generic 9 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_9 = 40,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700706 /**
707 * Axis constant: Generic 10 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_10 = 41,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700711 /**
712 * Axis constant: Generic 11 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_11 = 42,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700716 /**
717 * Axis constant: Generic 12 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_12 = 43,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700721 /**
722 * Axis constant: Generic 13 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_13 = 44,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700726 /**
727 * Axis constant: Generic 14 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_14 = 45,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700731 /**
732 * Axis constant: Generic 15 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_15 = 46,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700736 /**
737 * Axis constant: Generic 16 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_16 = 47,
741
742 // NOTE: If you add a new axis here you must also add it to several other files.
743 // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
744};
745
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700746/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700747 * Constants that identify buttons that are associated with motion events.
748 * Refer to the documentation on the MotionEvent class for descriptions of each button.
749 */
750enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700751 /** primary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700752 AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700753 /** secondary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700754 AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700755 /** tertiary */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700756 AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700757 /** back */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700758 AMOTION_EVENT_BUTTON_BACK = 1 << 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700759 /** forward */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700760 AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
Michael Wright7b159c92015-05-14 14:48:03 +0100761 AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
762 AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700763};
764
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700765/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700766 * Constants that identify tool types.
767 * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
768 */
769enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700770 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700771 AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700772 /** finger */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700773 AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700774 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700775 AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700776 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700777 AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700778 /** eraser */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700779 AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
780};
781
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700782/**
783 * Input source masks.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700784 *
785 * Refer to the documentation on android.view.InputDevice for more details about input sources
786 * and their correct interpretation.
787 */
788enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700789 /** mask */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700790 AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
791
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700792 /** none */
Michael Wrightaadaca72013-03-11 14:20:14 -0700793 AINPUT_SOURCE_CLASS_NONE = 0x00000000,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700794 /** button */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700795 AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700796 /** pointer */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700797 AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700798 /** navigation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700799 AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700800 /** position */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700801 AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700802 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700803 AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
804};
805
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700806/**
807 * Input sources.
808 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700809enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700810 /** unknown */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700811 AINPUT_SOURCE_UNKNOWN = 0x00000000,
812
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700813 /** keyboard */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700814 AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700815 /** dpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700816 AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700817 /** gamepad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700818 AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700819 /** touchscreen */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700820 AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700821 /** mouse */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700822 AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700823 /** stylus */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700824 AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
Michael Wright7d3ad692015-06-23 19:04:31 +0100825 /** bluetooth stylus */
Michael Wright2f78b682015-06-12 15:25:08 +0100826 AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700827 /** trackball */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700828 AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700829 /** touchpad */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700830 AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700831 /** navigation */
Michael Wrightaadaca72013-03-11 14:20:14 -0700832 AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700833 /** joystick */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700834 AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
835
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700836 /** any */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700837 AINPUT_SOURCE_ANY = 0xffffff00,
838};
839
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700840/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700841 * Keyboard types.
842 *
843 * Refer to the documentation on android.view.InputDevice for more details.
844 */
845enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700846 /** none */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700847 AINPUT_KEYBOARD_TYPE_NONE = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700848 /** non alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700849 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700850 /** alphabetic */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700851 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
852};
853
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700854/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700855 * Constants used to retrieve information about the range of motion for a particular
856 * coordinate of a motion event.
857 *
858 * Refer to the documentation on android.view.InputDevice for more details about input sources
859 * and their correct interpretation.
860 *
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700861 * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700862 */
863enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700864 /** x */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700865 AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700866 /** y */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700867 AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700868 /** pressure */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700869 AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700870 /** size */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700871 AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700872 /** touch major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700873 AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700874 /** touch minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700875 AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700876 /** tool major */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700877 AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700878 /** tool minor */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700879 AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700880 /** orientation */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700881 AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700882};
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700883
884
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700885/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700886 * Input event accessors.
887 *
888 * Note that most functions can only be used on input events that are of a given type.
889 * Calling these functions on input events of other types will yield undefined behavior.
890 */
891
892/*** Accessors for all input events. ***/
893
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700894/** Get the input event type. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700895int32_t AInputEvent_getType(const AInputEvent* event);
896
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700897/** Get the id for the device that an input event came from.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700898 *
899 * Input events can be generated by multiple different input devices.
900 * Use the input device id to obtain information about the input
901 * device that was responsible for generating a particular event.
902 *
903 * An input device id of 0 indicates that the event didn't come from a physical device;
904 * other numbers are arbitrary and you shouldn't depend on the values.
905 * Use the provided input device query API to obtain information about input devices.
906 */
907int32_t AInputEvent_getDeviceId(const AInputEvent* event);
908
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700909/** Get the input event source. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700910int32_t AInputEvent_getSource(const AInputEvent* event);
911
912/*** Accessors for key events only. ***/
913
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700914/** Get the key event action. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700915int32_t AKeyEvent_getAction(const AInputEvent* key_event);
916
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700917/** Get the key event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700918int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
919
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700920/**
921 * Get the key code of the key event.
922 * This is the physical key that was pressed, not the Unicode character.
923 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700924int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
925
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700926/**
927 * Get the hardware key id of this key event.
928 * These values are not reliable and vary from device to device.
929 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700930int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
931
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700932/** Get the meta key state. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700933int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
934
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700935/**
936 * Get the repeat count of the event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700937 * For both key up an key down events, this is the number of times the key has
938 * repeated with the first down starting at 0 and counting up from there. For
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700939 * multiple key events, this is the number of down/up pairs that have occurred.
940 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700941int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
942
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700943/**
944 * Get the time of the most recent key down event, in the
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700945 * java.lang.System.nanoTime() time base. If this is a down event,
946 * this will be the same as eventTime.
947 * Note that when chording keys, this value is the down time of the most recently
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700948 * pressed key, which may not be the same physical key of this event.
949 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700950int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
951
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700952/**
953 * Get the time this event occurred, in the
954 * java.lang.System.nanoTime() time base.
955 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700956int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
957
958/*** Accessors for motion events only. ***/
959
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700960/** Get the combined motion event action code and pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700961int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
962
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700963/** Get the motion event flags. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700964int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
965
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700966/**
967 * Get the state of any meta / modifier keys that were in effect when the
968 * event was generated.
969 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700970int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
971
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700972/** Get the button state of all buttons that are pressed. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700973int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
974
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700975/**
976 * Get a bitfield indicating which edges, if any, were touched by this motion event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700977 * For touch events, clients can use this to determine if the user's finger was
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700978 * touching the edge of the display.
979 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700980int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
981
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700982/**
983 * Get the time when the user originally pressed down to start a stream of
984 * position events, in the java.lang.System.nanoTime() time base.
985 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700986int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
987
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700988/**
989 * Get the time when this specific event was generated,
990 * in the java.lang.System.nanoTime() time base.
991 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700992int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
993
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700994/**
995 * Get the X coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700996 * For touch events on the screen, this is the delta that was added to the raw
997 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700998 * and views.
999 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001000float AMotionEvent_getXOffset(const AInputEvent* motion_event);
1001
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001002/**
1003 * Get the Y coordinate offset.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001004 * For touch events on the screen, this is the delta that was added to the raw
1005 * screen coordinates to adjust for the absolute position of the containing windows
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001006 * and views.
1007 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001008float AMotionEvent_getYOffset(const AInputEvent* motion_event);
1009
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001010/**
1011 * Get the precision of the X coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001012 * You can multiply this number with an X coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001013 * actual hardware value of the X coordinate.
1014 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001015float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
1016
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001017/**
1018 * Get the precision of the Y coordinates being reported.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001019 * You can multiply this number with a Y coordinate sample to find the
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001020 * actual hardware value of the Y coordinate.
1021 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001022float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
1023
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001024/**
1025 * Get the number of pointers of data contained in this event.
1026 * Always >= 1.
1027 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001028size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
1029
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001030/**
1031 * Get the pointer identifier associated with a particular pointer
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001032 * data index in this event. The identifier tells you the actual pointer
1033 * number associated with the data, accounting for individual pointers
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001034 * going up and down since the start of the current gesture.
1035 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001036int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
1037
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001038/**
1039 * Get the tool type of a pointer for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001040 * The tool type indicates the type of tool used to make contact such as a
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001041 * finger or stylus, if known.
1042 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001043int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
1044
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001045/**
1046 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001047 * For touch events on the screen, this is the original location of the event
1048 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001049 * and views.
1050 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001051float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
1052
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001053/**
1054 * Get the original raw X coordinate of this event.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001055 * For touch events on the screen, this is the original location of the event
1056 * on the screen, before it had been adjusted for the containing window
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001057 * and views.
1058 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001059float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
1060
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001061/**
1062 * Get the current X coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001063 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001064 * that are sub-pixel precise.
1065 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001066float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
1067
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001068/**
1069 * Get the current Y coordinate of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001070 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001071 * that are sub-pixel precise.
1072 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001073float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
1074
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001075/**
1076 * Get the current pressure of this event for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001077 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1078 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001079 * the input device.
1080 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001081float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
1082
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001083/**
1084 * Get the current scaled value of the approximate size for the given pointer index.
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001085 * This represents some approximation of the area of the screen being
1086 * pressed; the actual value in pixels corresponding to the
1087 * touch is normalized with the device specific range of values
1088 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001089 * determine fat touch events.
1090 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001091float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
1092
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001093/**
1094 * Get the current length of the major axis of an ellipse that describes the touch area
1095 * at the point of contact for the given pointer index.
1096 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001097float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
1098
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001099/**
1100 * Get the current length of the minor axis of an ellipse that describes the touch area
1101 * at the point of contact for the given pointer index.
1102 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001103float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
1104
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001105/**
1106 * Get the current length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001107 * of the approaching tool for the given pointer index.
1108 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001109 * touching the device independent of its actual touch area at the point of contact.
1110 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001111float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
1112
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001113/**
1114 * Get the current length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001115 * of the approaching tool for the given pointer index.
1116 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001117 * touching the device independent of its actual touch area at the point of contact.
1118 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001119float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
1120
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001121/**
1122 * Get the current orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001123 * vertical for the given pointer index.
1124 * An angle of 0 degrees indicates that the major axis of contact is oriented
1125 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1126 * indicates that the major axis of contact is oriented to the right. A negative angle
1127 * indicates that the major axis of contact is oriented to the left.
1128 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001129 * (finger pointing fully right).
1130 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001131float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
1132
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001133/** Get the value of the request axis for the given pointer index. */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001134float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
1135 int32_t axis, size_t pointer_index);
1136
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001137/**
1138 * Get the number of historical points in this event. These are movements that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001139 * have occurred between this event and the previous event. This only applies
1140 * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001141 * Historical samples are indexed from oldest to newest.
1142 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001143size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
1144
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001145/**
1146 * Get the time that a historical movement occurred between this event and
1147 * the previous event, in the java.lang.System.nanoTime() time base.
1148 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001149int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001150 size_t history_index);
1151
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001152/**
1153 * Get the historical raw X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001154 * occurred between this event and the previous motion event.
1155 * For touch events on the screen, this is the original location of the event
1156 * on the screen, before it had been adjusted for the containing window
1157 * and views.
1158 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001159 * that are sub-pixel precise.
1160 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001161float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
1162 size_t history_index);
1163
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001164/**
1165 * Get the historical raw Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001166 * occurred between this event and the previous motion event.
1167 * For touch events on the screen, this is the original location of the event
1168 * on the screen, before it had been adjusted for the containing window
1169 * and views.
1170 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001171 * that are sub-pixel precise.
1172 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001173float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
1174 size_t history_index);
1175
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001176/**
1177 * Get the historical X coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001178 * occurred between this event and the previous motion event.
1179 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001180 * that are sub-pixel precise.
1181 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001182float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001183 size_t history_index);
1184
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001185/**
1186 * Get the historical Y coordinate of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001187 * occurred between this event and the previous motion event.
1188 * Whole numbers are pixels; the value may have a fraction for input devices
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001189 * that are sub-pixel precise.
1190 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001191float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001192 size_t history_index);
1193
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001194/**
1195 * Get the historical pressure of this event for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001196 * occurred between this event and the previous motion event.
1197 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
1198 * although values higher than 1 may be generated depending on the calibration of
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001199 * the input device.
1200 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001201float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001202 size_t history_index);
1203
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001204/**
1205 * Get the current scaled value of the approximate size for the given pointer index that
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001206 * occurred between this event and the previous motion event.
1207 * This represents some approximation of the area of the screen being
1208 * pressed; the actual value in pixels corresponding to the
1209 * touch is normalized with the device specific range of values
1210 * and scaled to a value between 0 and 1. The value of size can be used to
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001211 * determine fat touch events.
1212 */
Andrew Hsieh26c24162013-05-27 12:26:04 +08001213float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001214 size_t history_index);
1215
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001216/**
1217 * Get the historical length of the major axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001218 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001219 * occurred between this event and the previous motion event.
1220 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001221float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
1222 size_t history_index);
1223
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001224/**
1225 * Get the historical length of the minor axis of an ellipse that describes the touch area
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001226 * at the point of contact for the given pointer index that
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001227 * occurred between this event and the previous motion event.
1228 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001229float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
1230 size_t history_index);
1231
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001232/**
1233 * Get the historical length of the major axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001234 * of the approaching tool for the given pointer index that
1235 * occurred between this event and the previous motion event.
1236 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001237 * touching the device independent of its actual touch area at the point of contact.
1238 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001239float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
1240 size_t history_index);
1241
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001242/**
1243 * Get the historical length of the minor axis of an ellipse that describes the size
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001244 * of the approaching tool for the given pointer index that
1245 * occurred between this event and the previous motion event.
1246 * The tool area represents the estimated size of the finger or pen that is
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001247 * touching the device independent of its actual touch area at the point of contact.
1248 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001249float AMotionEvent_getHistoricalToolMinor(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 orientation of the touch area and tool area in radians clockwise from
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001254 * vertical for the given pointer index that
1255 * occurred between this event and the previous motion event.
1256 * An angle of 0 degrees indicates that the major axis of contact is oriented
1257 * upwards, is perfectly circular or is of unknown orientation. A positive angle
1258 * indicates that the major axis of contact is oriented to the right. A negative angle
1259 * indicates that the major axis of contact is oriented to the left.
1260 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001261 * (finger pointing fully right).
1262 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001263float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
1264 size_t history_index);
1265
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001266/**
1267 * Get the historical value of the request axis for the given pointer index
1268 * that occurred between this event and the previous motion event.
1269 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001270float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
1271 int32_t axis, size_t pointer_index, size_t history_index);
1272
1273
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001274struct AInputQueue;
1275/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001276 * Input queue
1277 *
1278 * An input queue is the facility through which you retrieve input
1279 * events.
1280 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001281typedef struct AInputQueue AInputQueue;
1282
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001283/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001284 * Add this input queue to a looper for processing. See
1285 * ALooper_addFd() for information on the ident, callback, and data params.
1286 */
1287void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
1288 int ident, ALooper_callbackFunc callback, void* data);
1289
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001290/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001291 * Remove the input queue from the looper it is currently attached to.
1292 */
1293void AInputQueue_detachLooper(AInputQueue* queue);
1294
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001295/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001296 * Returns true if there are one or more events available in the
1297 * input queue. Returns 1 if the queue has events; 0 if
1298 * it does not have events; and a negative value if there is an error.
1299 */
1300int32_t AInputQueue_hasEvents(AInputQueue* queue);
1301
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001302/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001303 * Returns the next available event from the queue. Returns a negative
1304 * value if no events are available or an error has occurred.
1305 */
1306int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
1307
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001308/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001309 * Sends the key for standard pre-dispatching -- that is, possibly deliver
1310 * it to the current IME to be consumed before the app. Returns 0 if it
1311 * was not pre-dispatched, meaning you can process it right now. If non-zero
1312 * is returned, you must abandon the current event processing and allow the
1313 * event to appear again in the event queue (if it does not get consumed during
1314 * pre-dispatching).
1315 */
1316int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
1317
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001318/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001319 * Report that dispatching has finished with the given event.
1320 * This must be called after receiving an event with AInputQueue_get_event().
1321 */
1322void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
1323
1324#ifdef __cplusplus
1325}
1326#endif
1327
1328#endif // _ANDROID_INPUT_H
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -07001329
1330/** @} */