2
* Copyright (C) 2010 The Android Open Source Project
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
17
#ifndef _ANDROID_INPUT_H
18
#define _ANDROID_INPUT_H
20
/******************************************************************
24
* This file is part of Android's set of stable system headers
25
* exposed by the Android NDK (Native Development Kit).
27
* Third-party source AND binary code relies on the definitions
28
* here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
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
37
* Structures and functions to receive and process input events in
40
* NOTE: These functions MUST be implemented by /system/lib/libui.so
44
#include <sys/types.h>
51
* Key states (may be returned by queries about the current state of a
52
* particular key code, scan code or switch).
55
/* The key state is unknown or the requested key itself is not supported. */
56
AKEY_STATE_UNKNOWN = -1,
61
/* The key is down. */
64
/* The key is down but is a virtual key press that is being emulated by the system. */
65
AKEY_STATE_VIRTUAL = 2
69
* Meta key / modifer state.
72
/* No meta keys are pressed. */
75
/* This mask is used to check whether one of the ALT meta keys is pressed. */
78
/* This mask is used to check whether the left ALT meta key is pressed. */
79
AMETA_ALT_LEFT_ON = 0x10,
81
/* This mask is used to check whether the right ALT meta key is pressed. */
82
AMETA_ALT_RIGHT_ON = 0x20,
84
/* This mask is used to check whether one of the SHIFT meta keys is pressed. */
85
AMETA_SHIFT_ON = 0x01,
87
/* This mask is used to check whether the left SHIFT meta key is pressed. */
88
AMETA_SHIFT_LEFT_ON = 0x40,
90
/* This mask is used to check whether the right SHIFT meta key is pressed. */
91
AMETA_SHIFT_RIGHT_ON = 0x80,
93
/* This mask is used to check whether the SYM meta key is pressed. */
96
/* This mask is used to check whether the FUNCTION meta key is pressed. */
97
AMETA_FUNCTION_ON = 0x08,
99
/* This mask is used to check whether one of the CTRL meta keys is pressed. */
100
AMETA_CTRL_ON = 0x1000,
102
/* This mask is used to check whether the left CTRL meta key is pressed. */
103
AMETA_CTRL_LEFT_ON = 0x2000,
105
/* This mask is used to check whether the right CTRL meta key is pressed. */
106
AMETA_CTRL_RIGHT_ON = 0x4000,
108
/* This mask is used to check whether one of the META meta keys is pressed. */
109
AMETA_META_ON = 0x10000,
111
/* This mask is used to check whether the left META meta key is pressed. */
112
AMETA_META_LEFT_ON = 0x20000,
114
/* This mask is used to check whether the right META meta key is pressed. */
115
AMETA_META_RIGHT_ON = 0x40000,
117
/* This mask is used to check whether the CAPS LOCK meta key is on. */
118
AMETA_CAPS_LOCK_ON = 0x100000,
120
/* This mask is used to check whether the NUM LOCK meta key is on. */
121
AMETA_NUM_LOCK_ON = 0x200000,
123
/* This mask is used to check whether the SCROLL LOCK meta key is on. */
124
AMETA_SCROLL_LOCK_ON = 0x400000
130
* Input events are opaque structures. Use the provided accessors functions to
131
* read their properties.
134
typedef struct AInputEvent AInputEvent;
140
/* Indicates that the input event is a key event. */
141
AINPUT_EVENT_TYPE_KEY = 1,
143
/* Indicates that the input event is a motion event. */
144
AINPUT_EVENT_TYPE_MOTION = 2,
146
/* Indicates that the event contains a raw buffer. */
147
AINPUT_EVENT_TYPE_BUFFER = 3
154
/* The key has been pressed down. */
155
AKEY_EVENT_ACTION_DOWN = 0,
157
/* The key has been released. */
158
AKEY_EVENT_ACTION_UP = 1,
160
/* Multiple duplicate key events have occurred in a row, or a complex string is
161
* being delivered. The repeat_count property of the key event contains the number
162
* of times the given key code should be executed.
164
AKEY_EVENT_ACTION_MULTIPLE = 2
171
/* This mask is set if the device woke because of this key event. */
172
AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
174
/* This mask is set if the key event was generated by a software keyboard. */
175
AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
177
/* This mask is set if we don't want the key event to cause us to leave touch mode. */
178
AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
180
/* This mask is set if an event was known to come from a trusted part
181
* of the system. That is, the event is known to come from the user,
182
* and could not have been spoofed by a third party component. */
183
AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
185
/* This mask is used for compatibility, to identify enter keys that are
186
* coming from an IME whose enter key has been auto-labelled "next" or
187
* "done". This allows TextView to dispatch these as normal enter keys
188
* for old applications, but still do the appropriate action when
190
AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
192
/* When associated with up key events, this indicates that the key press
193
* has been canceled. Typically this is used with virtual touch screen
194
* keys, where the user can slide from the virtual key area on to the
195
* display: in that case, the application will receive a canceled up
196
* event and should not perform the action normally associated with the
197
* key. Note that for this to work, the application can not perform an
198
* action for a key until it receives an up or the long press timeout has
200
AKEY_EVENT_FLAG_CANCELED = 0x20,
202
/* This key event was generated by a virtual (on-screen) hard key area.
203
* Typically this is an area of the touchscreen, outside of the regular
204
* display, dedicated to "hardware" buttons. */
205
AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
207
/* This flag is set for the first key repeat that occurs after the
208
* long press timeout. */
209
AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
211
/* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
212
* press action was executed while it was down. */
213
AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
215
/* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
216
* tracked from its initial down. That is, somebody requested that tracking
217
* started on the key down and a long press has not caused
218
* the tracking to be canceled. */
219
AKEY_EVENT_FLAG_TRACKING = 0x200,
221
/* Set when a key event has been synthesized to implement default behavior
222
* for an event that the application did not handle.
223
* Fallback key events are generated by unhandled trackball motions
224
* (to emulate a directional keypad) and by certain unhandled key presses
225
* that are declared in the key map (such as special function numeric keypad
226
* keys when numlock is off). */
227
AKEY_EVENT_FLAG_FALLBACK = 0x400
231
* Motion event actions.
234
/* Bit shift for the action bits holding the pointer index as
235
* defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
237
#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
240
/* Bit mask of the parts of the action code that are the action itself.
242
AMOTION_EVENT_ACTION_MASK = 0xff,
244
/* Bits in the action code that represent a pointer index, used with
245
* AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
246
* down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
247
* index where the data for the pointer going up or down can be found.
249
AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
251
/* A pressed gesture has started, the motion contains the initial starting location.
253
AMOTION_EVENT_ACTION_DOWN = 0,
255
/* A pressed gesture has finished, the motion contains the final release location
256
* as well as any intermediate points since the last down or move event.
258
AMOTION_EVENT_ACTION_UP = 1,
260
/* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
261
* AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
262
* any intermediate points since the last down or move event.
264
AMOTION_EVENT_ACTION_MOVE = 2,
266
/* The current gesture has been aborted.
267
* You will not receive any more points in it. You should treat this as
268
* an up event, but not perform any action that you normally would.
270
AMOTION_EVENT_ACTION_CANCEL = 3,
272
/* A movement has happened outside of the normal bounds of the UI element.
273
* This does not provide a full gesture, but only the initial location of the movement/touch.
275
AMOTION_EVENT_ACTION_OUTSIDE = 4,
277
/* A non-primary pointer has gone down.
278
* The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
280
AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
282
/* A non-primary pointer has gone up.
283
* The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
285
AMOTION_EVENT_ACTION_POINTER_UP = 6,
287
/* A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
288
* The motion contains the most recent point, as well as any intermediate points since
289
* the last hover move event.
291
AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
293
/* The motion event contains relative vertical and/or horizontal scroll offsets.
294
* Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
295
* and AMOTION_EVENT_AXIS_HSCROLL.
296
* The pointer may or may not be down when this event is dispatched.
297
* This action is always delivered to the winder under the pointer, which
298
* may not be the window currently touched.
300
AMOTION_EVENT_ACTION_SCROLL = 8,
302
/* The pointer is not down but has entered the boundaries of a window or view.
304
AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
306
/* The pointer is not down but has exited the boundaries of a window or view.
308
AMOTION_EVENT_ACTION_HOVER_EXIT = 10
312
* Motion event flags.
315
/* This flag indicates that the window that received this motion event is partly
316
* or wholly obscured by another visible window above it. This flag is set to true
317
* even if the event did not directly pass through the obscured area.
318
* A security sensitive application can check this flag to identify situations in which
319
* a malicious application may have covered up part of its content for the purpose
320
* of misleading the user or hijacking touches. An appropriate response might be
321
* to drop the suspect touches or to take additional precautions to confirm the user's
324
AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1
328
* Motion event edge touch flags.
331
/* No edges intersected */
332
AMOTION_EVENT_EDGE_FLAG_NONE = 0,
334
/* Flag indicating the motion event intersected the top edge of the screen. */
335
AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
337
/* Flag indicating the motion event intersected the bottom edge of the screen. */
338
AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
340
/* Flag indicating the motion event intersected the left edge of the screen. */
341
AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
343
/* Flag indicating the motion event intersected the right edge of the screen. */
344
AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
348
* Constants that identify each individual axis of a motion event.
349
* Refer to the documentation on the MotionEvent class for descriptions of each axis.
352
AMOTION_EVENT_AXIS_X = 0,
353
AMOTION_EVENT_AXIS_Y = 1,
354
AMOTION_EVENT_AXIS_PRESSURE = 2,
355
AMOTION_EVENT_AXIS_SIZE = 3,
356
AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
357
AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
358
AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
359
AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
360
AMOTION_EVENT_AXIS_ORIENTATION = 8,
361
AMOTION_EVENT_AXIS_VSCROLL = 9,
362
AMOTION_EVENT_AXIS_HSCROLL = 10,
363
AMOTION_EVENT_AXIS_Z = 11,
364
AMOTION_EVENT_AXIS_RX = 12,
365
AMOTION_EVENT_AXIS_RY = 13,
366
AMOTION_EVENT_AXIS_RZ = 14,
367
AMOTION_EVENT_AXIS_HAT_X = 15,
368
AMOTION_EVENT_AXIS_HAT_Y = 16,
369
AMOTION_EVENT_AXIS_LTRIGGER = 17,
370
AMOTION_EVENT_AXIS_RTRIGGER = 18,
371
AMOTION_EVENT_AXIS_THROTTLE = 19,
372
AMOTION_EVENT_AXIS_RUDDER = 20,
373
AMOTION_EVENT_AXIS_WHEEL = 21,
374
AMOTION_EVENT_AXIS_GAS = 22,
375
AMOTION_EVENT_AXIS_BRAKE = 23,
376
AMOTION_EVENT_AXIS_DISTANCE = 24,
377
AMOTION_EVENT_AXIS_TILT = 25,
378
AMOTION_EVENT_AXIS_GENERIC_1 = 32,
379
AMOTION_EVENT_AXIS_GENERIC_2 = 33,
380
AMOTION_EVENT_AXIS_GENERIC_3 = 34,
381
AMOTION_EVENT_AXIS_GENERIC_4 = 35,
382
AMOTION_EVENT_AXIS_GENERIC_5 = 36,
383
AMOTION_EVENT_AXIS_GENERIC_6 = 37,
384
AMOTION_EVENT_AXIS_GENERIC_7 = 38,
385
AMOTION_EVENT_AXIS_GENERIC_8 = 39,
386
AMOTION_EVENT_AXIS_GENERIC_9 = 40,
387
AMOTION_EVENT_AXIS_GENERIC_10 = 41,
388
AMOTION_EVENT_AXIS_GENERIC_11 = 42,
389
AMOTION_EVENT_AXIS_GENERIC_12 = 43,
390
AMOTION_EVENT_AXIS_GENERIC_13 = 44,
391
AMOTION_EVENT_AXIS_GENERIC_14 = 45,
392
AMOTION_EVENT_AXIS_GENERIC_15 = 46,
393
AMOTION_EVENT_AXIS_GENERIC_16 = 47
395
// NOTE: If you add a new axis here you must also add it to several other files.
396
// Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
400
* Constants that identify buttons that are associated with motion events.
401
* Refer to the documentation on the MotionEvent class for descriptions of each button.
404
AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
405
AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
406
AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
407
AMOTION_EVENT_BUTTON_BACK = 1 << 3,
408
AMOTION_EVENT_BUTTON_FORWARD = 1 << 4
412
* Constants that identify tool types.
413
* Refer to the documentation on the MotionEvent class for descriptions of each tool type.
416
AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
417
AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
418
AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
419
AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
420
AMOTION_EVENT_TOOL_TYPE_ERASER = 4
426
* Refer to the documentation on android.view.InputDevice for more details about input sources
427
* and their correct interpretation.
430
AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
432
AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
433
AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
434
AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
435
AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
436
AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010
440
AINPUT_SOURCE_UNKNOWN = 0x00000000,
442
AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
443
AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
444
AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
445
AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
446
AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
447
AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
448
AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
449
AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
450
AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
452
AINPUT_SOURCE_ANY = 0xffffff00
458
* Refer to the documentation on android.view.InputDevice for more details.
461
AINPUT_KEYBOARD_TYPE_NONE = 0,
462
AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
463
AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2
470
#endif // _ANDROID_INPUT_H