blob: d53148972597d58a972eb609e250517347cac413 [file] [log] [blame]
Jeff Brown46b9ac02010-04-22 18:58:52 -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
17#ifndef _ANDROID_INPUT_H
18#define _ANDROID_INPUT_H
19
20/******************************************************************
21 *
22 * IMPORTANT NOTICE:
23 *
24 * This file is part of Android's set of stable system headers
25 * exposed by the Android NDK (Native Development Kit).
26 *
27 * Third-party source AND binary code relies on the definitions
28 * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
29 *
30 * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
31 * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
32 * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
33 * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
34 */
35
36/*
37 * Structures and functions to receive and process input events in
38 * native code.
39 *
40 * NOTE: These functions MUST be implemented by /system/lib/libui.so
41 */
42
Kenny Roote30de4e2010-07-28 16:41:02 -070043#include <stdint.h>
Jeff Brown46b9ac02010-04-22 18:58:52 -070044#include <sys/types.h>
45#include <android/keycodes.h>
Dianne Hackborn68267412010-07-02 18:52:01 -070046#include <android/looper.h>
Jeff Brown46b9ac02010-04-22 18:58:52 -070047
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52/*
Jeff Brown46b9ac02010-04-22 18:58:52 -070053 * Key states (may be returned by queries about the current state of a
54 * particular key code, scan code or switch).
Jeff Brown46b9ac02010-04-22 18:58:52 -070055 */
56enum {
57 /* The key state is unknown or the requested key itself is not supported. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070058 AKEY_STATE_UNKNOWN = -1,
Jeff Brown46b9ac02010-04-22 18:58:52 -070059
60 /* The key is up. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070061 AKEY_STATE_UP = 0,
Jeff Brown46b9ac02010-04-22 18:58:52 -070062
63 /* The key is down. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070064 AKEY_STATE_DOWN = 1,
Jeff Brown46b9ac02010-04-22 18:58:52 -070065
66 /* The key is down but is a virtual key press that is being emulated by the system. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070067 AKEY_STATE_VIRTUAL = 2
Jeff Brown46b9ac02010-04-22 18:58:52 -070068};
69
70/*
71 * Meta key / modifer state.
72 */
73enum {
74 /* No meta keys are pressed. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070075 AMETA_NONE = 0,
Jeff Brown46b9ac02010-04-22 18:58:52 -070076
77 /* This mask is used to check whether one of the ALT meta keys is pressed. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070078 AMETA_ALT_ON = 0x02,
Jeff Brown46b9ac02010-04-22 18:58:52 -070079
80 /* This mask is used to check whether the left ALT meta key is pressed. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070081 AMETA_ALT_LEFT_ON = 0x10,
Jeff Brown46b9ac02010-04-22 18:58:52 -070082
83 /* This mask is used to check whether the right ALT meta key is pressed. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070084 AMETA_ALT_RIGHT_ON = 0x20,
Jeff Brown46b9ac02010-04-22 18:58:52 -070085
86 /* This mask is used to check whether one of the SHIFT meta keys is pressed. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070087 AMETA_SHIFT_ON = 0x01,
Jeff Brown46b9ac02010-04-22 18:58:52 -070088
89 /* This mask is used to check whether the left SHIFT meta key is pressed. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070090 AMETA_SHIFT_LEFT_ON = 0x40,
Jeff Brown46b9ac02010-04-22 18:58:52 -070091
92 /* This mask is used to check whether the right SHIFT meta key is pressed. */
Jeff Brownc5ed5912010-07-14 18:48:53 -070093 AMETA_SHIFT_RIGHT_ON = 0x80,
Jeff Brown46b9ac02010-04-22 18:58:52 -070094
95 /* This mask is used to check whether the SYM meta key is pressed. */
Jeff Brown497a92c2010-09-12 17:55:08 -070096 AMETA_SYM_ON = 0x04,
97
98 /* This mask is used to check whether the FUNCTION meta key is pressed. */
99 AMETA_FUNCTION_ON = 0x08,
100
101 /* This mask is used to check whether one of the CTRL meta keys is pressed. */
102 AMETA_CTRL_ON = 0x1000,
103
104 /* This mask is used to check whether the left CTRL meta key is pressed. */
105 AMETA_CTRL_LEFT_ON = 0x2000,
106
107 /* This mask is used to check whether the right CTRL meta key is pressed. */
108 AMETA_CTRL_RIGHT_ON = 0x4000,
109
110 /* This mask is used to check whether one of the META meta keys is pressed. */
111 AMETA_META_ON = 0x10000,
112
113 /* This mask is used to check whether the left META meta key is pressed. */
114 AMETA_META_LEFT_ON = 0x20000,
115
116 /* This mask is used to check whether the right META meta key is pressed. */
117 AMETA_META_RIGHT_ON = 0x40000,
118
Jeff Brown51e7fe72010-10-29 22:19:53 -0700119 /* This mask is used to check whether the CAPS LOCK meta key is on. */
120 AMETA_CAPS_LOCK_ON = 0x100000,
Jeff Brown497a92c2010-09-12 17:55:08 -0700121
Jeff Brown51e7fe72010-10-29 22:19:53 -0700122 /* This mask is used to check whether the NUM LOCK meta key is on. */
123 AMETA_NUM_LOCK_ON = 0x200000,
Jeff Brown497a92c2010-09-12 17:55:08 -0700124
Jeff Brown51e7fe72010-10-29 22:19:53 -0700125 /* This mask is used to check whether the SCROLL LOCK meta key is on. */
126 AMETA_SCROLL_LOCK_ON = 0x400000,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700127};
128
129/*
130 * Input events.
131 *
132 * Input events are opaque structures. Use the provided accessors functions to
133 * read their properties.
134 */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700135struct AInputEvent;
136typedef struct AInputEvent AInputEvent;
Jeff Brown46b9ac02010-04-22 18:58:52 -0700137
138/*
139 * Input event types.
140 */
141enum {
142 /* Indicates that the input event is a key event. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700143 AINPUT_EVENT_TYPE_KEY = 1,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700144
145 /* Indicates that the input event is a motion event. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700146 AINPUT_EVENT_TYPE_MOTION = 2
Jeff Brown46b9ac02010-04-22 18:58:52 -0700147};
148
149/*
150 * Key event actions.
151 */
152enum {
153 /* The key has been pressed down. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700154 AKEY_EVENT_ACTION_DOWN = 0,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700155
156 /* The key has been released. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700157 AKEY_EVENT_ACTION_UP = 1,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700158
159 /* Multiple duplicate key events have occurred in a row, or a complex string is
160 * being delivered. The repeat_count property of the key event contains the number
161 * of times the given key code should be executed.
162 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700163 AKEY_EVENT_ACTION_MULTIPLE = 2
Jeff Brown46b9ac02010-04-22 18:58:52 -0700164};
165
166/*
167 * Key event flags.
168 */
169enum {
170 /* This mask is set if the device woke because of this key event. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700171 AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700172
173 /* This mask is set if the key event was generated by a software keyboard. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700174 AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700175
176 /* This mask is set if we don't want the key event to cause us to leave touch mode. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700177 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700178
179 /* This mask is set if an event was known to come from a trusted part
180 * of the system. That is, the event is known to come from the user,
181 * and could not have been spoofed by a third party component. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700182 AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700183
184 /* This mask is used for compatibility, to identify enter keys that are
185 * coming from an IME whose enter key has been auto-labelled "next" or
186 * "done". This allows TextView to dispatch these as normal enter keys
187 * for old applications, but still do the appropriate action when
188 * receiving them. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700189 AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700190
191 /* When associated with up key events, this indicates that the key press
192 * has been canceled. Typically this is used with virtual touch screen
193 * keys, where the user can slide from the virtual key area on to the
194 * display: in that case, the application will receive a canceled up
195 * event and should not perform the action normally associated with the
196 * key. Note that for this to work, the application can not perform an
197 * action for a key until it receives an up or the long press timeout has
198 * expired. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700199 AKEY_EVENT_FLAG_CANCELED = 0x20,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700200
201 /* This key event was generated by a virtual (on-screen) hard key area.
202 * Typically this is an area of the touchscreen, outside of the regular
203 * display, dedicated to "hardware" buttons. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700204 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700205
206 /* This flag is set for the first key repeat that occurs after the
207 * long press timeout. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700208 AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700209
Jeff Brownc5ed5912010-07-14 18:48:53 -0700210 /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
Jeff Brown46b9ac02010-04-22 18:58:52 -0700211 * press action was executed while it was down. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700212 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700213
Jeff Brownc5ed5912010-07-14 18:48:53 -0700214 /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
Jeff Brown46b9ac02010-04-22 18:58:52 -0700215 * tracked from its initial down. That is, somebody requested that tracking
216 * started on the key down and a long press has not caused
217 * the tracking to be canceled. */
Jeff Brown49ed71d2010-12-06 17:13:33 -0800218 AKEY_EVENT_FLAG_TRACKING = 0x200,
219
220 /* Set when a key event has been synthesized to implement default behavior
221 * for an event that the application did not handle.
222 * Fallback key events are generated by unhandled trackball motions
223 * (to emulate a directional keypad) and by certain unhandled key presses
224 * that are declared in the key map (such as special function numeric keypad
225 * keys when numlock is off). */
226 AKEY_EVENT_FLAG_FALLBACK = 0x400,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700227};
228
229/*
230 * Motion event actions.
231 */
232
233/* Bit shift for the action bits holding the pointer index as
Jeff Brownc5ed5912010-07-14 18:48:53 -0700234 * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
Jeff Brown46b9ac02010-04-22 18:58:52 -0700235 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700236#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
Jeff Brown46b9ac02010-04-22 18:58:52 -0700237
238enum {
239 /* Bit mask of the parts of the action code that are the action itself.
240 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700241 AMOTION_EVENT_ACTION_MASK = 0xff,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700242
243 /* Bits in the action code that represent a pointer index, used with
Jeff Brownc5ed5912010-07-14 18:48:53 -0700244 * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
245 * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
Jeff Brown46b9ac02010-04-22 18:58:52 -0700246 * index where the data for the pointer going up or down can be found.
247 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700248 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700249
250 /* A pressed gesture has started, the motion contains the initial starting location.
251 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700252 AMOTION_EVENT_ACTION_DOWN = 0,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700253
254 /* A pressed gesture has finished, the motion contains the final release location
255 * as well as any intermediate points since the last down or move event.
256 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700257 AMOTION_EVENT_ACTION_UP = 1,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700258
Jeff Brownc5ed5912010-07-14 18:48:53 -0700259 /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
260 * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
Jeff Brown46b9ac02010-04-22 18:58:52 -0700261 * any intermediate points since the last down or move event.
262 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700263 AMOTION_EVENT_ACTION_MOVE = 2,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700264
265 /* The current gesture has been aborted.
266 * You will not receive any more points in it. You should treat this as
267 * an up event, but not perform any action that you normally would.
268 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700269 AMOTION_EVENT_ACTION_CANCEL = 3,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700270
271 /* A movement has happened outside of the normal bounds of the UI element.
272 * This does not provide a full gesture, but only the initial location of the movement/touch.
273 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700274 AMOTION_EVENT_ACTION_OUTSIDE = 4,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700275
276 /* A non-primary pointer has gone down.
Jeff Brownc5ed5912010-07-14 18:48:53 -0700277 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
Jeff Brown46b9ac02010-04-22 18:58:52 -0700278 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700279 AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700280
281 /* A non-primary pointer has gone up.
Jeff Brownc5ed5912010-07-14 18:48:53 -0700282 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
Jeff Brown46b9ac02010-04-22 18:58:52 -0700283 */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700284 AMOTION_EVENT_ACTION_POINTER_UP = 6
Jeff Brown46b9ac02010-04-22 18:58:52 -0700285};
286
287/*
Jeff Brown85a31762010-09-01 17:01:00 -0700288 * Motion event flags.
289 */
290enum {
291 /* This flag indicates that the window that received this motion event is partly
292 * or wholly obscured by another visible window above it. This flag is set to true
293 * even if the event did not directly pass through the obscured area.
294 * A security sensitive application can check this flag to identify situations in which
295 * a malicious application may have covered up part of its content for the purpose
296 * of misleading the user or hijacking touches. An appropriate response might be
297 * to drop the suspect touches or to take additional precautions to confirm the user's
298 * actual intent.
299 */
300 AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
301};
302
303/*
Jeff Brown46b9ac02010-04-22 18:58:52 -0700304 * Motion event edge touch flags.
305 */
306enum {
307 /* No edges intersected */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700308 AMOTION_EVENT_EDGE_FLAG_NONE = 0,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700309
310 /* Flag indicating the motion event intersected the top edge of the screen. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700311 AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700312
313 /* Flag indicating the motion event intersected the bottom edge of the screen. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700314 AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700315
316 /* Flag indicating the motion event intersected the left edge of the screen. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700317 AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700318
319 /* Flag indicating the motion event intersected the right edge of the screen. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700320 AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
Jeff Brown46b9ac02010-04-22 18:58:52 -0700321};
322
323/*
Jeff Brownebbd5d12011-02-17 13:01:34 -0800324 * Constants that identify each individual axis of a motion event.
Jeff Brown6f2fba42011-02-19 01:08:02 -0800325 * Refer to the documentation on the MotionEvent class for descriptions of each axis.
Jeff Brownebbd5d12011-02-17 13:01:34 -0800326 */
327enum {
328 AMOTION_EVENT_AXIS_X = 0,
329 AMOTION_EVENT_AXIS_Y = 1,
330 AMOTION_EVENT_AXIS_PRESSURE = 2,
331 AMOTION_EVENT_AXIS_SIZE = 3,
332 AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
333 AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
334 AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
335 AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
336 AMOTION_EVENT_AXIS_ORIENTATION = 8,
Jeff Brown6f2fba42011-02-19 01:08:02 -0800337 AMOTION_EVENT_AXIS_VSCROLL = 9,
338 AMOTION_EVENT_AXIS_HSCROLL = 10,
339 AMOTION_EVENT_AXIS_Z = 11,
340 AMOTION_EVENT_AXIS_RX = 12,
341 AMOTION_EVENT_AXIS_RY = 13,
342 AMOTION_EVENT_AXIS_RZ = 14,
343 AMOTION_EVENT_AXIS_HAT_X = 15,
344 AMOTION_EVENT_AXIS_HAT_Y = 16,
345 AMOTION_EVENT_AXIS_LTRIGGER = 17,
346 AMOTION_EVENT_AXIS_RTRIGGER = 18,
347 AMOTION_EVENT_AXIS_GENERIC_1 = 32,
348 AMOTION_EVENT_AXIS_GENERIC_2 = 33,
349 AMOTION_EVENT_AXIS_GENERIC_3 = 34,
350 AMOTION_EVENT_AXIS_GENERIC_4 = 35,
351 AMOTION_EVENT_AXIS_GENERIC_5 = 36,
352 AMOTION_EVENT_AXIS_GENERIC_6 = 37,
353 AMOTION_EVENT_AXIS_GENERIC_7 = 38,
354 AMOTION_EVENT_AXIS_GENERIC_8 = 39,
355 AMOTION_EVENT_AXIS_GENERIC_9 = 40,
356 AMOTION_EVENT_AXIS_GENERIC_10 = 41,
357 AMOTION_EVENT_AXIS_GENERIC_11 = 42,
358 AMOTION_EVENT_AXIS_GENERIC_12 = 43,
359 AMOTION_EVENT_AXIS_GENERIC_13 = 44,
360 AMOTION_EVENT_AXIS_GENERIC_14 = 45,
361 AMOTION_EVENT_AXIS_GENERIC_15 = 46,
362 AMOTION_EVENT_AXIS_GENERIC_16 = 47,
363
364 // NOTE: If you add a new axis here you must also add it to several other files.
365 // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
Jeff Brownebbd5d12011-02-17 13:01:34 -0800366};
367
368/*
Jeff Brownc5ed5912010-07-14 18:48:53 -0700369 * Input sources.
Jeff Brown46b9ac02010-04-22 18:58:52 -0700370 *
Jeff Brownc5ed5912010-07-14 18:48:53 -0700371 * Refer to the documentation on android.view.InputDevice for more details about input sources
372 * and their correct interpretation.
Jeff Brown46b9ac02010-04-22 18:58:52 -0700373 */
374enum {
Jeff Brownc5ed5912010-07-14 18:48:53 -0700375 AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
376
377 AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
378 AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
379 AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
380 AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
Jeff Browncb1404e2011-01-15 18:14:15 -0800381 AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
Jeff Brownc5ed5912010-07-14 18:48:53 -0700382};
383
384enum {
385 AINPUT_SOURCE_UNKNOWN = 0x00000000,
386
387 AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
388 AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
Jeff Browncb1404e2011-01-15 18:14:15 -0800389 AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
Jeff Brownc5ed5912010-07-14 18:48:53 -0700390 AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
391 AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
392 AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
393 AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
Jeff Browncb1404e2011-01-15 18:14:15 -0800394 AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
Jeff Brownc3db8582010-10-20 15:33:38 -0700395
396 AINPUT_SOURCE_ANY = 0xffffff00,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700397};
398
399/*
Jeff Brown6d0fec22010-07-23 21:28:06 -0700400 * Keyboard types.
401 *
402 * Refer to the documentation on android.view.InputDevice for more details.
403 */
404enum {
405 AINPUT_KEYBOARD_TYPE_NONE = 0,
406 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
407 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
408};
409
410/*
411 * Constants used to retrieve information about the range of motion for a particular
412 * coordinate of a motion event.
413 *
414 * Refer to the documentation on android.view.InputDevice for more details about input sources
415 * and their correct interpretation.
Jeff Brown91c69ab2011-02-14 17:03:18 -0800416 *
Jeff Brownebbd5d12011-02-17 13:01:34 -0800417 * DEPRECATION NOTICE: These constants are deprecated. Use AMOTION_EVENT_AXIS_* constants instead.
Jeff Brown6d0fec22010-07-23 21:28:06 -0700418 */
419enum {
Jeff Brownebbd5d12011-02-17 13:01:34 -0800420 AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
421 AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
422 AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
423 AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
424 AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
425 AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
426 AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
427 AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
428 AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
Jeff Brown91c69ab2011-02-14 17:03:18 -0800429} __attribute__ ((deprecated));
Jeff Brown6d0fec22010-07-23 21:28:06 -0700430
431
432/*
Jeff Brown46b9ac02010-04-22 18:58:52 -0700433 * Input event accessors.
434 *
435 * Note that most functions can only be used on input events that are of a given type.
436 * Calling these functions on input events of other types will yield undefined behavior.
437 */
438
439/*** Accessors for all input events. ***/
440
441/* Get the input event type. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700442int32_t AInputEvent_getType(const AInputEvent* event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700443
444/* Get the id for the device that an input event came from.
445 *
446 * Input events can be generated by multiple different input devices.
447 * Use the input device id to obtain information about the input
448 * device that was responsible for generating a particular event.
449 *
450 * An input device id of 0 indicates that the event didn't come from a physical device;
451 * other numbers are arbitrary and you shouldn't depend on the values.
452 * Use the provided input device query API to obtain information about input devices.
453 */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700454int32_t AInputEvent_getDeviceId(const AInputEvent* event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700455
Jeff Brownc5ed5912010-07-14 18:48:53 -0700456/* Get the input event source. */
457int32_t AInputEvent_getSource(const AInputEvent* event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700458
459/*** Accessors for key events only. ***/
460
461/* Get the key event action. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700462int32_t AKeyEvent_getAction(const AInputEvent* key_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700463
464/* Get the key event flags. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700465int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700466
467/* Get the key code of the key event.
468 * This is the physical key that was pressed, not the Unicode character. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700469int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700470
471/* Get the hardware key id of this key event.
472 * These values are not reliable and vary from device to device. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700473int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700474
475/* Get the meta key state. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700476int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700477
478/* Get the repeat count of the event.
479 * For both key up an key down events, this is the number of times the key has
480 * repeated with the first down starting at 0 and counting up from there. For
481 * multiple key events, this is the number of down/up pairs that have occurred. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700482int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700483
484/* Get the time of the most recent key down event, in the
485 * java.lang.System.nanoTime() time base. If this is a down event,
486 * this will be the same as eventTime.
487 * Note that when chording keys, this value is the down time of the most recently
488 * pressed key, which may not be the same physical key of this event. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700489int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700490
491/* Get the time this event occurred, in the
492 * java.lang.System.nanoTime() time base. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700493int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700494
495/*** Accessors for motion events only. ***/
496
497/* Get the combined motion event action code and pointer index. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700498int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700499
Jeff Brown85a31762010-09-01 17:01:00 -0700500/* Get the motion event flags. */
501int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
502
Jeff Brown46b9ac02010-04-22 18:58:52 -0700503/* Get the state of any meta / modifier keys that were in effect when the
504 * event was generated. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700505int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700506
507/* Get a bitfield indicating which edges, if any, were touched by this motion event.
508 * For touch events, clients can use this to determine if the user's finger was
509 * touching the edge of the display. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700510int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700511
512/* Get the time when the user originally pressed down to start a stream of
513 * position events, in the java.lang.System.nanoTime() time base. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700514int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700515
516/* Get the time when this specific event was generated,
517 * in the java.lang.System.nanoTime() time base. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700518int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700519
Jeff Brown5c225b12010-06-16 01:53:36 -0700520/* Get the X coordinate offset.
521 * For touch events on the screen, this is the delta that was added to the raw
522 * screen coordinates to adjust for the absolute position of the containing windows
523 * and views. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700524float AMotionEvent_getXOffset(const AInputEvent* motion_event);
Jeff Brown5c225b12010-06-16 01:53:36 -0700525
526/* Get the precision of the Y coordinates being reported.
527 * For touch events on the screen, this is the delta that was added to the raw
528 * screen coordinates to adjust for the absolute position of the containing windows
529 * and views. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700530float AMotionEvent_getYOffset(const AInputEvent* motion_event);
Jeff Brown5c225b12010-06-16 01:53:36 -0700531
Jeff Brown46b9ac02010-04-22 18:58:52 -0700532/* Get the precision of the X coordinates being reported.
533 * You can multiply this number with an X coordinate sample to find the
534 * actual hardware value of the X coordinate. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700535float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700536
537/* Get the precision of the Y coordinates being reported.
538 * You can multiply this number with a Y coordinate sample to find the
539 * actual hardware value of the Y coordinate. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700540float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700541
542/* Get the number of pointers of data contained in this event.
543 * Always >= 1. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700544size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700545
546/* Get the pointer identifier associated with a particular pointer
547 * data index is this event. The identifier tells you the actual pointer
548 * number associated with the data, accounting for individual pointers
549 * going up and down since the start of the current gesture. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700550int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700551
Jeff Brown5c225b12010-06-16 01:53:36 -0700552/* Get the original raw X coordinate of this event.
553 * For touch events on the screen, this is the original location of the event
Jeff Brown46b9ac02010-04-22 18:58:52 -0700554 * on the screen, before it had been adjusted for the containing window
555 * and views. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700556float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700557
Jeff Brown5c225b12010-06-16 01:53:36 -0700558/* Get the original raw X coordinate of this event.
559 * For touch events on the screen, this is the original location of the event
Jeff Brown46b9ac02010-04-22 18:58:52 -0700560 * on the screen, before it had been adjusted for the containing window
561 * and views. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700562float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700563
564/* Get the current X coordinate of this event for the given pointer index.
565 * Whole numbers are pixels; the value may have a fraction for input devices
566 * that are sub-pixel precise. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700567float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700568
569/* Get the current Y coordinate of this event for the given pointer index.
570 * Whole numbers are pixels; the value may have a fraction for input devices
571 * that are sub-pixel precise. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700572float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700573
574/* Get the current pressure of this event for the given pointer index.
575 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
Jeff Brown91c69ab2011-02-14 17:03:18 -0800576 * although values higher than 1 may be generated depending on the calibration of
Jeff Brown46b9ac02010-04-22 18:58:52 -0700577 * the input device. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700578float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700579
580/* Get the current scaled value of the approximate size for the given pointer index.
581 * This represents some approximation of the area of the screen being
582 * pressed; the actual value in pixels corresponding to the
583 * touch is normalized with the device specific range of values
584 * and scaled to a value between 0 and 1. The value of size can be used to
585 * determine fat touch events. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700586float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700587
Jeff Brownc5ed5912010-07-14 18:48:53 -0700588/* Get the current length of the major axis of an ellipse that describes the touch area
589 * at the point of contact for the given pointer index. */
590float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
591
592/* Get the current length of the minor axis of an ellipse that describes the touch area
593 * at the point of contact for the given pointer index. */
594float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
595
596/* Get the current length of the major axis of an ellipse that describes the size
597 * of the approaching tool for the given pointer index.
598 * The tool area represents the estimated size of the finger or pen that is
599 * touching the device independent of its actual touch area at the point of contact. */
600float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
601
602/* Get the current length of the minor axis of an ellipse that describes the size
603 * of the approaching tool for the given pointer index.
604 * The tool area represents the estimated size of the finger or pen that is
605 * touching the device independent of its actual touch area at the point of contact. */
606float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
607
608/* Get the current orientation of the touch area and tool area in radians clockwise from
609 * vertical for the given pointer index.
610 * An angle of 0 degrees indicates that the major axis of contact is oriented
611 * upwards, is perfectly circular or is of unknown orientation. A positive angle
612 * indicates that the major axis of contact is oriented to the right. A negative angle
613 * indicates that the major axis of contact is oriented to the left.
Jeff Brown6d0fec22010-07-23 21:28:06 -0700614 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Jeff Brownc5ed5912010-07-14 18:48:53 -0700615 * (finger pointing fully right). */
616float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
617
Jeff Brown91c69ab2011-02-14 17:03:18 -0800618/* Get the value of the request axis for the given pointer index. */
619float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
620 int32_t axis, size_t pointer_index);
621
Jeff Brown46b9ac02010-04-22 18:58:52 -0700622/* Get the number of historical points in this event. These are movements that
623 * have occurred between this event and the previous event. This only applies
Jeff Brownc5ed5912010-07-14 18:48:53 -0700624 * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
Jeff Brown46b9ac02010-04-22 18:58:52 -0700625 * Historical samples are indexed from oldest to newest. */
Jeff Brownc5ed5912010-07-14 18:48:53 -0700626size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
Jeff Brown46b9ac02010-04-22 18:58:52 -0700627
628/* Get the time that a historical movement occurred between this event and
629 * the previous event, in the java.lang.System.nanoTime() time base. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700630int64_t AMotionEvent_getHistoricalEventTime(AInputEvent* motion_event,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700631 size_t history_index);
632
Jeff Brown5c225b12010-06-16 01:53:36 -0700633/* Get the historical raw X coordinate of this event for the given pointer index that
634 * occurred between this event and the previous motion event.
635 * For touch events on the screen, this is the original location of the event
636 * on the screen, before it had been adjusted for the containing window
637 * and views.
638 * Whole numbers are pixels; the value may have a fraction for input devices
639 * that are sub-pixel precise. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700640float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index);
Jeff Brown5c225b12010-06-16 01:53:36 -0700641
642/* Get the historical raw Y coordinate of this event for the given pointer index that
643 * occurred between this event and the previous motion event.
644 * For touch events on the screen, this is the original location of the event
645 * on the screen, before it had been adjusted for the containing window
646 * and views.
647 * Whole numbers are pixels; the value may have a fraction for input devices
648 * that are sub-pixel precise. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700649float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index);
Jeff Brown5c225b12010-06-16 01:53:36 -0700650
Jeff Brown46b9ac02010-04-22 18:58:52 -0700651/* Get the historical X coordinate of this event for the given pointer index that
652 * occurred between this event and the previous motion event.
653 * Whole numbers are pixels; the value may have a fraction for input devices
654 * that are sub-pixel precise. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700655float AMotionEvent_getHistoricalX(AInputEvent* motion_event, size_t pointer_index,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700656 size_t history_index);
657
658/* Get the historical Y coordinate of this event for the given pointer index that
659 * occurred between this event and the previous motion event.
660 * Whole numbers are pixels; the value may have a fraction for input devices
661 * that are sub-pixel precise. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700662float AMotionEvent_getHistoricalY(AInputEvent* motion_event, size_t pointer_index,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700663 size_t history_index);
664
665/* Get the historical pressure of this event for the given pointer index that
666 * occurred between this event and the previous motion event.
667 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
Jeff Brown91c69ab2011-02-14 17:03:18 -0800668 * although values higher than 1 may be generated depending on the calibration of
Jeff Brown46b9ac02010-04-22 18:58:52 -0700669 * the input device. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700670float AMotionEvent_getHistoricalPressure(AInputEvent* motion_event, size_t pointer_index,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700671 size_t history_index);
672
673/* Get the current scaled value of the approximate size for the given pointer index that
674 * occurred between this event and the previous motion event.
675 * This represents some approximation of the area of the screen being
676 * pressed; the actual value in pixels corresponding to the
677 * touch is normalized with the device specific range of values
678 * and scaled to a value between 0 and 1. The value of size can be used to
679 * determine fat touch events. */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700680float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index,
Jeff Brown46b9ac02010-04-22 18:58:52 -0700681 size_t history_index);
682
Jeff Brownc5ed5912010-07-14 18:48:53 -0700683/* Get the historical length of the major axis of an ellipse that describes the touch area
684 * at the point of contact for the given pointer index that
685 * occurred between this event and the previous motion event. */
686float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
687 size_t history_index);
688
689/* Get the historical length of the minor axis of an ellipse that describes the touch area
690 * at the point of contact for the given pointer index that
691 * occurred between this event and the previous motion event. */
692float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
693 size_t history_index);
694
695/* Get the historical length of the major axis of an ellipse that describes the size
696 * of the approaching tool for the given pointer index that
697 * occurred between this event and the previous motion event.
698 * The tool area represents the estimated size of the finger or pen that is
699 * touching the device independent of its actual touch area at the point of contact. */
700float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
701 size_t history_index);
702
703/* Get the historical length of the minor axis of an ellipse that describes the size
704 * of the approaching tool for the given pointer index that
705 * occurred between this event and the previous motion event.
706 * The tool area represents the estimated size of the finger or pen that is
707 * touching the device independent of its actual touch area at the point of contact. */
708float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
709 size_t history_index);
710
711/* Get the historical orientation of the touch area and tool area in radians clockwise from
712 * vertical for the given pointer index that
713 * occurred between this event and the previous motion event.
714 * An angle of 0 degrees indicates that the major axis of contact is oriented
715 * upwards, is perfectly circular or is of unknown orientation. A positive angle
716 * indicates that the major axis of contact is oriented to the right. A negative angle
717 * indicates that the major axis of contact is oriented to the left.
Jeff Brown6d0fec22010-07-23 21:28:06 -0700718 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
Jeff Brownc5ed5912010-07-14 18:48:53 -0700719 * (finger pointing fully right). */
720float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
721 size_t history_index);
722
Jeff Brown91c69ab2011-02-14 17:03:18 -0800723/* Get the historical value of the request axis for the given pointer index
724 * that occurred between this event and the previous motion event. */
725float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
726 int32_t axis, size_t pointer_index, size_t history_index);
727
Jeff Brownc5ed5912010-07-14 18:48:53 -0700728
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700729/*
730 * Input queue
731 *
732 * An input queue is the facility through which you retrieve input
733 * events.
734 */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700735struct AInputQueue;
736typedef struct AInputQueue AInputQueue;
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700737
738/*
Dianne Hackborn85448bb2010-07-07 14:27:31 -0700739 * Add this input queue to a looper for processing. See
Dianne Hackborn42c03e52010-09-07 15:28:30 -0700740 * ALooper_addFd() for information on the ident, callback, and data params.
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700741 */
Dianne Hackborn68267412010-07-02 18:52:01 -0700742void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
Jeff Brown4fe6c3e2010-09-13 23:17:30 -0700743 int ident, ALooper_callbackFunc callback, void* data);
Dianne Hackborn68267412010-07-02 18:52:01 -0700744
745/*
746 * Remove the input queue from the looper it is currently attached to.
747 */
748void AInputQueue_detachLooper(AInputQueue* queue);
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700749
750/*
751 * Returns true if there are one or more events available in the
752 * input queue. Returns 1 if the queue has events; 0 if
753 * it does not have events; and a negative value if there is an error.
754 */
Dianne Hackborn2c6081c2010-07-15 17:44:53 -0700755int32_t AInputQueue_hasEvents(AInputQueue* queue);
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700756
757/*
758 * Returns the next available event from the queue. Returns a negative
759 * value if no events are available or an error has occurred.
760 */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700761int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700762
763/*
Dianne Hackborn2c6081c2010-07-15 17:44:53 -0700764 * Sends the key for standard pre-dispatching -- that is, possibly deliver
765 * it to the current IME to be consumed before the app. Returns 0 if it
766 * was not pre-dispatched, meaning you can process it right now. If non-zero
767 * is returned, you must abandon the current event processing and allow the
768 * event to appear again in the event queue (if it does not get consumed during
769 * pre-dispatching).
770 */
771int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
772
773/*
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700774 * Report that dispatching has finished with the given event.
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700775 * This must be called after receiving an event with AInputQueue_get_event().
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700776 */
Dianne Hackborn2e9f93e2010-06-28 15:27:30 -0700777void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700778
Jeff Brown46b9ac02010-04-22 18:58:52 -0700779#ifdef __cplusplus
780}
781#endif
782
783#endif // _ANDROID_INPUT_H