Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2010 The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef _ANDROID_INPUT_H |
michael@0 | 18 | #define _ANDROID_INPUT_H |
michael@0 | 19 | |
michael@0 | 20 | /****************************************************************** |
michael@0 | 21 | * |
michael@0 | 22 | * IMPORTANT NOTICE: |
michael@0 | 23 | * |
michael@0 | 24 | * This file is part of Android's set of stable system headers |
michael@0 | 25 | * exposed by the Android NDK (Native Development Kit). |
michael@0 | 26 | * |
michael@0 | 27 | * Third-party source AND binary code relies on the definitions |
michael@0 | 28 | * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. |
michael@0 | 29 | * |
michael@0 | 30 | * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) |
michael@0 | 31 | * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS |
michael@0 | 32 | * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY |
michael@0 | 33 | * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES |
michael@0 | 34 | */ |
michael@0 | 35 | |
michael@0 | 36 | /* |
michael@0 | 37 | * Structures and functions to receive and process input events in |
michael@0 | 38 | * native code. |
michael@0 | 39 | * |
michael@0 | 40 | * NOTE: These functions MUST be implemented by /system/lib/libui.so |
michael@0 | 41 | */ |
michael@0 | 42 | |
michael@0 | 43 | #include <stdint.h> |
michael@0 | 44 | #include <sys/types.h> |
michael@0 | 45 | #include "android_keycodes.h" |
michael@0 | 46 | #include <android/looper.h> |
michael@0 | 47 | |
michael@0 | 48 | #ifdef __cplusplus |
michael@0 | 49 | extern "C" { |
michael@0 | 50 | #endif |
michael@0 | 51 | |
michael@0 | 52 | /* |
michael@0 | 53 | * Key states (may be returned by queries about the current state of a |
michael@0 | 54 | * particular key code, scan code or switch). |
michael@0 | 55 | */ |
michael@0 | 56 | enum { |
michael@0 | 57 | /* The key state is unknown or the requested key itself is not supported. */ |
michael@0 | 58 | AKEY_STATE_UNKNOWN = -1, |
michael@0 | 59 | |
michael@0 | 60 | /* The key is up. */ |
michael@0 | 61 | AKEY_STATE_UP = 0, |
michael@0 | 62 | |
michael@0 | 63 | /* The key is down. */ |
michael@0 | 64 | AKEY_STATE_DOWN = 1, |
michael@0 | 65 | |
michael@0 | 66 | /* The key is down but is a virtual key press that is being emulated by the system. */ |
michael@0 | 67 | AKEY_STATE_VIRTUAL = 2 |
michael@0 | 68 | }; |
michael@0 | 69 | |
michael@0 | 70 | /* |
michael@0 | 71 | * Meta key / modifer state. |
michael@0 | 72 | */ |
michael@0 | 73 | enum { |
michael@0 | 74 | /* No meta keys are pressed. */ |
michael@0 | 75 | AMETA_NONE = 0, |
michael@0 | 76 | |
michael@0 | 77 | /* This mask is used to check whether one of the ALT meta keys is pressed. */ |
michael@0 | 78 | AMETA_ALT_ON = 0x02, |
michael@0 | 79 | |
michael@0 | 80 | /* This mask is used to check whether the left ALT meta key is pressed. */ |
michael@0 | 81 | AMETA_ALT_LEFT_ON = 0x10, |
michael@0 | 82 | |
michael@0 | 83 | /* This mask is used to check whether the right ALT meta key is pressed. */ |
michael@0 | 84 | AMETA_ALT_RIGHT_ON = 0x20, |
michael@0 | 85 | |
michael@0 | 86 | /* This mask is used to check whether one of the SHIFT meta keys is pressed. */ |
michael@0 | 87 | AMETA_SHIFT_ON = 0x01, |
michael@0 | 88 | |
michael@0 | 89 | /* This mask is used to check whether the left SHIFT meta key is pressed. */ |
michael@0 | 90 | AMETA_SHIFT_LEFT_ON = 0x40, |
michael@0 | 91 | |
michael@0 | 92 | /* This mask is used to check whether the right SHIFT meta key is pressed. */ |
michael@0 | 93 | AMETA_SHIFT_RIGHT_ON = 0x80, |
michael@0 | 94 | |
michael@0 | 95 | /* This mask is used to check whether the SYM meta key is pressed. */ |
michael@0 | 96 | AMETA_SYM_ON = 0x04, |
michael@0 | 97 | |
michael@0 | 98 | /* This mask is used to check whether the FUNCTION meta key is pressed. */ |
michael@0 | 99 | AMETA_FUNCTION_ON = 0x08, |
michael@0 | 100 | |
michael@0 | 101 | /* This mask is used to check whether one of the CTRL meta keys is pressed. */ |
michael@0 | 102 | AMETA_CTRL_ON = 0x1000, |
michael@0 | 103 | |
michael@0 | 104 | /* This mask is used to check whether the left CTRL meta key is pressed. */ |
michael@0 | 105 | AMETA_CTRL_LEFT_ON = 0x2000, |
michael@0 | 106 | |
michael@0 | 107 | /* This mask is used to check whether the right CTRL meta key is pressed. */ |
michael@0 | 108 | AMETA_CTRL_RIGHT_ON = 0x4000, |
michael@0 | 109 | |
michael@0 | 110 | /* This mask is used to check whether one of the META meta keys is pressed. */ |
michael@0 | 111 | AMETA_META_ON = 0x10000, |
michael@0 | 112 | |
michael@0 | 113 | /* This mask is used to check whether the left META meta key is pressed. */ |
michael@0 | 114 | AMETA_META_LEFT_ON = 0x20000, |
michael@0 | 115 | |
michael@0 | 116 | /* This mask is used to check whether the right META meta key is pressed. */ |
michael@0 | 117 | AMETA_META_RIGHT_ON = 0x40000, |
michael@0 | 118 | |
michael@0 | 119 | /* This mask is used to check whether the CAPS LOCK meta key is on. */ |
michael@0 | 120 | AMETA_CAPS_LOCK_ON = 0x100000, |
michael@0 | 121 | |
michael@0 | 122 | /* This mask is used to check whether the NUM LOCK meta key is on. */ |
michael@0 | 123 | AMETA_NUM_LOCK_ON = 0x200000, |
michael@0 | 124 | |
michael@0 | 125 | /* This mask is used to check whether the SCROLL LOCK meta key is on. */ |
michael@0 | 126 | AMETA_SCROLL_LOCK_ON = 0x400000, |
michael@0 | 127 | }; |
michael@0 | 128 | |
michael@0 | 129 | /* |
michael@0 | 130 | * Input events. |
michael@0 | 131 | * |
michael@0 | 132 | * Input events are opaque structures. Use the provided accessors functions to |
michael@0 | 133 | * read their properties. |
michael@0 | 134 | */ |
michael@0 | 135 | struct AInputEvent; |
michael@0 | 136 | typedef struct AInputEvent AInputEvent; |
michael@0 | 137 | |
michael@0 | 138 | /* |
michael@0 | 139 | * Input event types. |
michael@0 | 140 | */ |
michael@0 | 141 | enum { |
michael@0 | 142 | /* Indicates that the input event is a key event. */ |
michael@0 | 143 | AINPUT_EVENT_TYPE_KEY = 1, |
michael@0 | 144 | |
michael@0 | 145 | /* Indicates that the input event is a motion event. */ |
michael@0 | 146 | AINPUT_EVENT_TYPE_MOTION = 2 |
michael@0 | 147 | }; |
michael@0 | 148 | |
michael@0 | 149 | /* |
michael@0 | 150 | * Key event actions. |
michael@0 | 151 | */ |
michael@0 | 152 | enum { |
michael@0 | 153 | /* The key has been pressed down. */ |
michael@0 | 154 | AKEY_EVENT_ACTION_DOWN = 0, |
michael@0 | 155 | |
michael@0 | 156 | /* The key has been released. */ |
michael@0 | 157 | AKEY_EVENT_ACTION_UP = 1, |
michael@0 | 158 | |
michael@0 | 159 | /* Multiple duplicate key events have occurred in a row, or a complex string is |
michael@0 | 160 | * being delivered. The repeat_count property of the key event contains the number |
michael@0 | 161 | * of times the given key code should be executed. |
michael@0 | 162 | */ |
michael@0 | 163 | AKEY_EVENT_ACTION_MULTIPLE = 2 |
michael@0 | 164 | }; |
michael@0 | 165 | |
michael@0 | 166 | /* |
michael@0 | 167 | * Key event flags. |
michael@0 | 168 | */ |
michael@0 | 169 | enum { |
michael@0 | 170 | /* This mask is set if the device woke because of this key event. */ |
michael@0 | 171 | AKEY_EVENT_FLAG_WOKE_HERE = 0x1, |
michael@0 | 172 | |
michael@0 | 173 | /* This mask is set if the key event was generated by a software keyboard. */ |
michael@0 | 174 | AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2, |
michael@0 | 175 | |
michael@0 | 176 | /* This mask is set if we don't want the key event to cause us to leave touch mode. */ |
michael@0 | 177 | AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4, |
michael@0 | 178 | |
michael@0 | 179 | /* This mask is set if an event was known to come from a trusted part |
michael@0 | 180 | * of the system. That is, the event is known to come from the user, |
michael@0 | 181 | * and could not have been spoofed by a third party component. */ |
michael@0 | 182 | AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8, |
michael@0 | 183 | |
michael@0 | 184 | /* This mask is used for compatibility, to identify enter keys that are |
michael@0 | 185 | * coming from an IME whose enter key has been auto-labelled "next" or |
michael@0 | 186 | * "done". This allows TextView to dispatch these as normal enter keys |
michael@0 | 187 | * for old applications, but still do the appropriate action when |
michael@0 | 188 | * receiving them. */ |
michael@0 | 189 | AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10, |
michael@0 | 190 | |
michael@0 | 191 | /* When associated with up key events, this indicates that the key press |
michael@0 | 192 | * has been canceled. Typically this is used with virtual touch screen |
michael@0 | 193 | * keys, where the user can slide from the virtual key area on to the |
michael@0 | 194 | * display: in that case, the application will receive a canceled up |
michael@0 | 195 | * event and should not perform the action normally associated with the |
michael@0 | 196 | * key. Note that for this to work, the application can not perform an |
michael@0 | 197 | * action for a key until it receives an up or the long press timeout has |
michael@0 | 198 | * expired. */ |
michael@0 | 199 | AKEY_EVENT_FLAG_CANCELED = 0x20, |
michael@0 | 200 | |
michael@0 | 201 | /* This key event was generated by a virtual (on-screen) hard key area. |
michael@0 | 202 | * Typically this is an area of the touchscreen, outside of the regular |
michael@0 | 203 | * display, dedicated to "hardware" buttons. */ |
michael@0 | 204 | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40, |
michael@0 | 205 | |
michael@0 | 206 | /* This flag is set for the first key repeat that occurs after the |
michael@0 | 207 | * long press timeout. */ |
michael@0 | 208 | AKEY_EVENT_FLAG_LONG_PRESS = 0x80, |
michael@0 | 209 | |
michael@0 | 210 | /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long |
michael@0 | 211 | * press action was executed while it was down. */ |
michael@0 | 212 | AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100, |
michael@0 | 213 | |
michael@0 | 214 | /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being |
michael@0 | 215 | * tracked from its initial down. That is, somebody requested that tracking |
michael@0 | 216 | * started on the key down and a long press has not caused |
michael@0 | 217 | * the tracking to be canceled. */ |
michael@0 | 218 | AKEY_EVENT_FLAG_TRACKING = 0x200, |
michael@0 | 219 | |
michael@0 | 220 | /* Set when a key event has been synthesized to implement default behavior |
michael@0 | 221 | * for an event that the application did not handle. |
michael@0 | 222 | * Fallback key events are generated by unhandled trackball motions |
michael@0 | 223 | * (to emulate a directional keypad) and by certain unhandled key presses |
michael@0 | 224 | * that are declared in the key map (such as special function numeric keypad |
michael@0 | 225 | * keys when numlock is off). */ |
michael@0 | 226 | AKEY_EVENT_FLAG_FALLBACK = 0x400, |
michael@0 | 227 | }; |
michael@0 | 228 | |
michael@0 | 229 | /* |
michael@0 | 230 | * Motion event actions. |
michael@0 | 231 | */ |
michael@0 | 232 | |
michael@0 | 233 | /* Bit shift for the action bits holding the pointer index as |
michael@0 | 234 | * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK. |
michael@0 | 235 | */ |
michael@0 | 236 | #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 |
michael@0 | 237 | |
michael@0 | 238 | enum { |
michael@0 | 239 | /* Bit mask of the parts of the action code that are the action itself. |
michael@0 | 240 | */ |
michael@0 | 241 | AMOTION_EVENT_ACTION_MASK = 0xff, |
michael@0 | 242 | |
michael@0 | 243 | /* Bits in the action code that represent a pointer index, used with |
michael@0 | 244 | * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting |
michael@0 | 245 | * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer |
michael@0 | 246 | * index where the data for the pointer going up or down can be found. |
michael@0 | 247 | */ |
michael@0 | 248 | AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00, |
michael@0 | 249 | |
michael@0 | 250 | /* A pressed gesture has started, the motion contains the initial starting location. |
michael@0 | 251 | */ |
michael@0 | 252 | AMOTION_EVENT_ACTION_DOWN = 0, |
michael@0 | 253 | |
michael@0 | 254 | /* A pressed gesture has finished, the motion contains the final release location |
michael@0 | 255 | * as well as any intermediate points since the last down or move event. |
michael@0 | 256 | */ |
michael@0 | 257 | AMOTION_EVENT_ACTION_UP = 1, |
michael@0 | 258 | |
michael@0 | 259 | /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and |
michael@0 | 260 | * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as |
michael@0 | 261 | * any intermediate points since the last down or move event. |
michael@0 | 262 | */ |
michael@0 | 263 | AMOTION_EVENT_ACTION_MOVE = 2, |
michael@0 | 264 | |
michael@0 | 265 | /* The current gesture has been aborted. |
michael@0 | 266 | * You will not receive any more points in it. You should treat this as |
michael@0 | 267 | * an up event, but not perform any action that you normally would. |
michael@0 | 268 | */ |
michael@0 | 269 | AMOTION_EVENT_ACTION_CANCEL = 3, |
michael@0 | 270 | |
michael@0 | 271 | /* A movement has happened outside of the normal bounds of the UI element. |
michael@0 | 272 | * This does not provide a full gesture, but only the initial location of the movement/touch. |
michael@0 | 273 | */ |
michael@0 | 274 | AMOTION_EVENT_ACTION_OUTSIDE = 4, |
michael@0 | 275 | |
michael@0 | 276 | /* A non-primary pointer has gone down. |
michael@0 | 277 | * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. |
michael@0 | 278 | */ |
michael@0 | 279 | AMOTION_EVENT_ACTION_POINTER_DOWN = 5, |
michael@0 | 280 | |
michael@0 | 281 | /* A non-primary pointer has gone up. |
michael@0 | 282 | * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. |
michael@0 | 283 | */ |
michael@0 | 284 | AMOTION_EVENT_ACTION_POINTER_UP = 6, |
michael@0 | 285 | |
michael@0 | 286 | /* A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE). |
michael@0 | 287 | * The motion contains the most recent point, as well as any intermediate points since |
michael@0 | 288 | * the last hover move event. |
michael@0 | 289 | */ |
michael@0 | 290 | AMOTION_EVENT_ACTION_HOVER_MOVE = 7, |
michael@0 | 291 | |
michael@0 | 292 | /* The motion event contains relative vertical and/or horizontal scroll offsets. |
michael@0 | 293 | * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL |
michael@0 | 294 | * and AMOTION_EVENT_AXIS_HSCROLL. |
michael@0 | 295 | * The pointer may or may not be down when this event is dispatched. |
michael@0 | 296 | * This action is always delivered to the winder under the pointer, which |
michael@0 | 297 | * may not be the window currently touched. |
michael@0 | 298 | */ |
michael@0 | 299 | AMOTION_EVENT_ACTION_SCROLL = 8, |
michael@0 | 300 | |
michael@0 | 301 | /* The pointer is not down but has entered the boundaries of a window or view. |
michael@0 | 302 | */ |
michael@0 | 303 | AMOTION_EVENT_ACTION_HOVER_ENTER = 9, |
michael@0 | 304 | |
michael@0 | 305 | /* The pointer is not down but has exited the boundaries of a window or view. |
michael@0 | 306 | */ |
michael@0 | 307 | AMOTION_EVENT_ACTION_HOVER_EXIT = 10, |
michael@0 | 308 | }; |
michael@0 | 309 | |
michael@0 | 310 | /* |
michael@0 | 311 | * Motion event flags. |
michael@0 | 312 | */ |
michael@0 | 313 | enum { |
michael@0 | 314 | /* This flag indicates that the window that received this motion event is partly |
michael@0 | 315 | * or wholly obscured by another visible window above it. This flag is set to true |
michael@0 | 316 | * even if the event did not directly pass through the obscured area. |
michael@0 | 317 | * A security sensitive application can check this flag to identify situations in which |
michael@0 | 318 | * a malicious application may have covered up part of its content for the purpose |
michael@0 | 319 | * of misleading the user or hijacking touches. An appropriate response might be |
michael@0 | 320 | * to drop the suspect touches or to take additional precautions to confirm the user's |
michael@0 | 321 | * actual intent. |
michael@0 | 322 | */ |
michael@0 | 323 | AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1, |
michael@0 | 324 | }; |
michael@0 | 325 | |
michael@0 | 326 | /* |
michael@0 | 327 | * Motion event edge touch flags. |
michael@0 | 328 | */ |
michael@0 | 329 | enum { |
michael@0 | 330 | /* No edges intersected */ |
michael@0 | 331 | AMOTION_EVENT_EDGE_FLAG_NONE = 0, |
michael@0 | 332 | |
michael@0 | 333 | /* Flag indicating the motion event intersected the top edge of the screen. */ |
michael@0 | 334 | AMOTION_EVENT_EDGE_FLAG_TOP = 0x01, |
michael@0 | 335 | |
michael@0 | 336 | /* Flag indicating the motion event intersected the bottom edge of the screen. */ |
michael@0 | 337 | AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02, |
michael@0 | 338 | |
michael@0 | 339 | /* Flag indicating the motion event intersected the left edge of the screen. */ |
michael@0 | 340 | AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04, |
michael@0 | 341 | |
michael@0 | 342 | /* Flag indicating the motion event intersected the right edge of the screen. */ |
michael@0 | 343 | AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08 |
michael@0 | 344 | }; |
michael@0 | 345 | |
michael@0 | 346 | /* |
michael@0 | 347 | * Constants that identify each individual axis of a motion event. |
michael@0 | 348 | * Refer to the documentation on the MotionEvent class for descriptions of each axis. |
michael@0 | 349 | */ |
michael@0 | 350 | enum { |
michael@0 | 351 | AMOTION_EVENT_AXIS_X = 0, |
michael@0 | 352 | AMOTION_EVENT_AXIS_Y = 1, |
michael@0 | 353 | AMOTION_EVENT_AXIS_PRESSURE = 2, |
michael@0 | 354 | AMOTION_EVENT_AXIS_SIZE = 3, |
michael@0 | 355 | AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4, |
michael@0 | 356 | AMOTION_EVENT_AXIS_TOUCH_MINOR = 5, |
michael@0 | 357 | AMOTION_EVENT_AXIS_TOOL_MAJOR = 6, |
michael@0 | 358 | AMOTION_EVENT_AXIS_TOOL_MINOR = 7, |
michael@0 | 359 | AMOTION_EVENT_AXIS_ORIENTATION = 8, |
michael@0 | 360 | AMOTION_EVENT_AXIS_VSCROLL = 9, |
michael@0 | 361 | AMOTION_EVENT_AXIS_HSCROLL = 10, |
michael@0 | 362 | AMOTION_EVENT_AXIS_Z = 11, |
michael@0 | 363 | AMOTION_EVENT_AXIS_RX = 12, |
michael@0 | 364 | AMOTION_EVENT_AXIS_RY = 13, |
michael@0 | 365 | AMOTION_EVENT_AXIS_RZ = 14, |
michael@0 | 366 | AMOTION_EVENT_AXIS_HAT_X = 15, |
michael@0 | 367 | AMOTION_EVENT_AXIS_HAT_Y = 16, |
michael@0 | 368 | AMOTION_EVENT_AXIS_LTRIGGER = 17, |
michael@0 | 369 | AMOTION_EVENT_AXIS_RTRIGGER = 18, |
michael@0 | 370 | AMOTION_EVENT_AXIS_THROTTLE = 19, |
michael@0 | 371 | AMOTION_EVENT_AXIS_RUDDER = 20, |
michael@0 | 372 | AMOTION_EVENT_AXIS_WHEEL = 21, |
michael@0 | 373 | AMOTION_EVENT_AXIS_GAS = 22, |
michael@0 | 374 | AMOTION_EVENT_AXIS_BRAKE = 23, |
michael@0 | 375 | AMOTION_EVENT_AXIS_DISTANCE = 24, |
michael@0 | 376 | AMOTION_EVENT_AXIS_TILT = 25, |
michael@0 | 377 | AMOTION_EVENT_AXIS_GENERIC_1 = 32, |
michael@0 | 378 | AMOTION_EVENT_AXIS_GENERIC_2 = 33, |
michael@0 | 379 | AMOTION_EVENT_AXIS_GENERIC_3 = 34, |
michael@0 | 380 | AMOTION_EVENT_AXIS_GENERIC_4 = 35, |
michael@0 | 381 | AMOTION_EVENT_AXIS_GENERIC_5 = 36, |
michael@0 | 382 | AMOTION_EVENT_AXIS_GENERIC_6 = 37, |
michael@0 | 383 | AMOTION_EVENT_AXIS_GENERIC_7 = 38, |
michael@0 | 384 | AMOTION_EVENT_AXIS_GENERIC_8 = 39, |
michael@0 | 385 | AMOTION_EVENT_AXIS_GENERIC_9 = 40, |
michael@0 | 386 | AMOTION_EVENT_AXIS_GENERIC_10 = 41, |
michael@0 | 387 | AMOTION_EVENT_AXIS_GENERIC_11 = 42, |
michael@0 | 388 | AMOTION_EVENT_AXIS_GENERIC_12 = 43, |
michael@0 | 389 | AMOTION_EVENT_AXIS_GENERIC_13 = 44, |
michael@0 | 390 | AMOTION_EVENT_AXIS_GENERIC_14 = 45, |
michael@0 | 391 | AMOTION_EVENT_AXIS_GENERIC_15 = 46, |
michael@0 | 392 | AMOTION_EVENT_AXIS_GENERIC_16 = 47, |
michael@0 | 393 | |
michael@0 | 394 | // NOTE: If you add a new axis here you must also add it to several other files. |
michael@0 | 395 | // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list. |
michael@0 | 396 | }; |
michael@0 | 397 | |
michael@0 | 398 | /* |
michael@0 | 399 | * Constants that identify buttons that are associated with motion events. |
michael@0 | 400 | * Refer to the documentation on the MotionEvent class for descriptions of each button. |
michael@0 | 401 | */ |
michael@0 | 402 | enum { |
michael@0 | 403 | AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0, |
michael@0 | 404 | AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1, |
michael@0 | 405 | AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2, |
michael@0 | 406 | AMOTION_EVENT_BUTTON_BACK = 1 << 3, |
michael@0 | 407 | AMOTION_EVENT_BUTTON_FORWARD = 1 << 4, |
michael@0 | 408 | }; |
michael@0 | 409 | |
michael@0 | 410 | /* |
michael@0 | 411 | * Constants that identify tool types. |
michael@0 | 412 | * Refer to the documentation on the MotionEvent class for descriptions of each tool type. |
michael@0 | 413 | */ |
michael@0 | 414 | enum { |
michael@0 | 415 | AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0, |
michael@0 | 416 | AMOTION_EVENT_TOOL_TYPE_FINGER = 1, |
michael@0 | 417 | AMOTION_EVENT_TOOL_TYPE_STYLUS = 2, |
michael@0 | 418 | AMOTION_EVENT_TOOL_TYPE_MOUSE = 3, |
michael@0 | 419 | AMOTION_EVENT_TOOL_TYPE_ERASER = 4, |
michael@0 | 420 | }; |
michael@0 | 421 | |
michael@0 | 422 | /* |
michael@0 | 423 | * Input sources. |
michael@0 | 424 | * |
michael@0 | 425 | * Refer to the documentation on android.view.InputDevice for more details about input sources |
michael@0 | 426 | * and their correct interpretation. |
michael@0 | 427 | */ |
michael@0 | 428 | enum { |
michael@0 | 429 | AINPUT_SOURCE_CLASS_MASK = 0x000000ff, |
michael@0 | 430 | |
michael@0 | 431 | AINPUT_SOURCE_CLASS_NONE = 0x00000000, |
michael@0 | 432 | AINPUT_SOURCE_CLASS_BUTTON = 0x00000001, |
michael@0 | 433 | AINPUT_SOURCE_CLASS_POINTER = 0x00000002, |
michael@0 | 434 | AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004, |
michael@0 | 435 | AINPUT_SOURCE_CLASS_POSITION = 0x00000008, |
michael@0 | 436 | AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010, |
michael@0 | 437 | }; |
michael@0 | 438 | |
michael@0 | 439 | enum { |
michael@0 | 440 | AINPUT_SOURCE_UNKNOWN = 0x00000000, |
michael@0 | 441 | |
michael@0 | 442 | AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON, |
michael@0 | 443 | AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON, |
michael@0 | 444 | AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON, |
michael@0 | 445 | AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER, |
michael@0 | 446 | AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER, |
michael@0 | 447 | AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER, |
michael@0 | 448 | AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION, |
michael@0 | 449 | AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION, |
michael@0 | 450 | AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE, |
michael@0 | 451 | AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK, |
michael@0 | 452 | |
michael@0 | 453 | AINPUT_SOURCE_ANY = 0xffffff00, |
michael@0 | 454 | }; |
michael@0 | 455 | |
michael@0 | 456 | /* |
michael@0 | 457 | * Keyboard types. |
michael@0 | 458 | * |
michael@0 | 459 | * Refer to the documentation on android.view.InputDevice for more details. |
michael@0 | 460 | */ |
michael@0 | 461 | enum { |
michael@0 | 462 | AINPUT_KEYBOARD_TYPE_NONE = 0, |
michael@0 | 463 | AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1, |
michael@0 | 464 | AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2, |
michael@0 | 465 | }; |
michael@0 | 466 | |
michael@0 | 467 | /* |
michael@0 | 468 | * Constants used to retrieve information about the range of motion for a particular |
michael@0 | 469 | * coordinate of a motion event. |
michael@0 | 470 | * |
michael@0 | 471 | * Refer to the documentation on android.view.InputDevice for more details about input sources |
michael@0 | 472 | * and their correct interpretation. |
michael@0 | 473 | * |
michael@0 | 474 | * DEPRECATION NOTICE: These constants are deprecated. Use AMOTION_EVENT_AXIS_* constants instead. |
michael@0 | 475 | */ |
michael@0 | 476 | enum { |
michael@0 | 477 | AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X, |
michael@0 | 478 | AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y, |
michael@0 | 479 | AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE, |
michael@0 | 480 | AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE, |
michael@0 | 481 | AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR, |
michael@0 | 482 | AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR, |
michael@0 | 483 | AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR, |
michael@0 | 484 | AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR, |
michael@0 | 485 | AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION, |
michael@0 | 486 | } __attribute__ ((deprecated)); |
michael@0 | 487 | |
michael@0 | 488 | |
michael@0 | 489 | /* |
michael@0 | 490 | * Input event accessors. |
michael@0 | 491 | * |
michael@0 | 492 | * Note that most functions can only be used on input events that are of a given type. |
michael@0 | 493 | * Calling these functions on input events of other types will yield undefined behavior. |
michael@0 | 494 | */ |
michael@0 | 495 | |
michael@0 | 496 | /*** Accessors for all input events. ***/ |
michael@0 | 497 | |
michael@0 | 498 | /* Get the input event type. */ |
michael@0 | 499 | int32_t AInputEvent_getType(const AInputEvent* event); |
michael@0 | 500 | |
michael@0 | 501 | /* Get the id for the device that an input event came from. |
michael@0 | 502 | * |
michael@0 | 503 | * Input events can be generated by multiple different input devices. |
michael@0 | 504 | * Use the input device id to obtain information about the input |
michael@0 | 505 | * device that was responsible for generating a particular event. |
michael@0 | 506 | * |
michael@0 | 507 | * An input device id of 0 indicates that the event didn't come from a physical device; |
michael@0 | 508 | * other numbers are arbitrary and you shouldn't depend on the values. |
michael@0 | 509 | * Use the provided input device query API to obtain information about input devices. |
michael@0 | 510 | */ |
michael@0 | 511 | int32_t AInputEvent_getDeviceId(const AInputEvent* event); |
michael@0 | 512 | |
michael@0 | 513 | /* Get the input event source. */ |
michael@0 | 514 | int32_t AInputEvent_getSource(const AInputEvent* event); |
michael@0 | 515 | |
michael@0 | 516 | /*** Accessors for key events only. ***/ |
michael@0 | 517 | |
michael@0 | 518 | /* Get the key event action. */ |
michael@0 | 519 | int32_t AKeyEvent_getAction(const AInputEvent* key_event); |
michael@0 | 520 | |
michael@0 | 521 | /* Get the key event flags. */ |
michael@0 | 522 | int32_t AKeyEvent_getFlags(const AInputEvent* key_event); |
michael@0 | 523 | |
michael@0 | 524 | /* Get the key code of the key event. |
michael@0 | 525 | * This is the physical key that was pressed, not the Unicode character. */ |
michael@0 | 526 | int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event); |
michael@0 | 527 | |
michael@0 | 528 | /* Get the hardware key id of this key event. |
michael@0 | 529 | * These values are not reliable and vary from device to device. */ |
michael@0 | 530 | int32_t AKeyEvent_getScanCode(const AInputEvent* key_event); |
michael@0 | 531 | |
michael@0 | 532 | /* Get the meta key state. */ |
michael@0 | 533 | int32_t AKeyEvent_getMetaState(const AInputEvent* key_event); |
michael@0 | 534 | |
michael@0 | 535 | /* Get the repeat count of the event. |
michael@0 | 536 | * For both key up an key down events, this is the number of times the key has |
michael@0 | 537 | * repeated with the first down starting at 0 and counting up from there. For |
michael@0 | 538 | * multiple key events, this is the number of down/up pairs that have occurred. */ |
michael@0 | 539 | int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event); |
michael@0 | 540 | |
michael@0 | 541 | /* Get the time of the most recent key down event, in the |
michael@0 | 542 | * java.lang.System.nanoTime() time base. If this is a down event, |
michael@0 | 543 | * this will be the same as eventTime. |
michael@0 | 544 | * Note that when chording keys, this value is the down time of the most recently |
michael@0 | 545 | * pressed key, which may not be the same physical key of this event. */ |
michael@0 | 546 | int64_t AKeyEvent_getDownTime(const AInputEvent* key_event); |
michael@0 | 547 | |
michael@0 | 548 | /* Get the time this event occurred, in the |
michael@0 | 549 | * java.lang.System.nanoTime() time base. */ |
michael@0 | 550 | int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); |
michael@0 | 551 | |
michael@0 | 552 | /*** Accessors for motion events only. ***/ |
michael@0 | 553 | |
michael@0 | 554 | /* Get the combined motion event action code and pointer index. */ |
michael@0 | 555 | int32_t AMotionEvent_getAction(const AInputEvent* motion_event); |
michael@0 | 556 | |
michael@0 | 557 | /* Get the motion event flags. */ |
michael@0 | 558 | int32_t AMotionEvent_getFlags(const AInputEvent* motion_event); |
michael@0 | 559 | |
michael@0 | 560 | /* Get the state of any meta / modifier keys that were in effect when the |
michael@0 | 561 | * event was generated. */ |
michael@0 | 562 | int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event); |
michael@0 | 563 | |
michael@0 | 564 | /* Get the button state of all buttons that are pressed. */ |
michael@0 | 565 | int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event); |
michael@0 | 566 | |
michael@0 | 567 | /* Get a bitfield indicating which edges, if any, were touched by this motion event. |
michael@0 | 568 | * For touch events, clients can use this to determine if the user's finger was |
michael@0 | 569 | * touching the edge of the display. */ |
michael@0 | 570 | int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event); |
michael@0 | 571 | |
michael@0 | 572 | /* Get the time when the user originally pressed down to start a stream of |
michael@0 | 573 | * position events, in the java.lang.System.nanoTime() time base. */ |
michael@0 | 574 | int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event); |
michael@0 | 575 | |
michael@0 | 576 | /* Get the time when this specific event was generated, |
michael@0 | 577 | * in the java.lang.System.nanoTime() time base. */ |
michael@0 | 578 | int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event); |
michael@0 | 579 | |
michael@0 | 580 | /* Get the X coordinate offset. |
michael@0 | 581 | * For touch events on the screen, this is the delta that was added to the raw |
michael@0 | 582 | * screen coordinates to adjust for the absolute position of the containing windows |
michael@0 | 583 | * and views. */ |
michael@0 | 584 | float AMotionEvent_getXOffset(const AInputEvent* motion_event); |
michael@0 | 585 | |
michael@0 | 586 | /* Get the precision of the Y coordinates being reported. |
michael@0 | 587 | * For touch events on the screen, this is the delta that was added to the raw |
michael@0 | 588 | * screen coordinates to adjust for the absolute position of the containing windows |
michael@0 | 589 | * and views. */ |
michael@0 | 590 | float AMotionEvent_getYOffset(const AInputEvent* motion_event); |
michael@0 | 591 | |
michael@0 | 592 | /* Get the precision of the X coordinates being reported. |
michael@0 | 593 | * You can multiply this number with an X coordinate sample to find the |
michael@0 | 594 | * actual hardware value of the X coordinate. */ |
michael@0 | 595 | float AMotionEvent_getXPrecision(const AInputEvent* motion_event); |
michael@0 | 596 | |
michael@0 | 597 | /* Get the precision of the Y coordinates being reported. |
michael@0 | 598 | * You can multiply this number with a Y coordinate sample to find the |
michael@0 | 599 | * actual hardware value of the Y coordinate. */ |
michael@0 | 600 | float AMotionEvent_getYPrecision(const AInputEvent* motion_event); |
michael@0 | 601 | |
michael@0 | 602 | /* Get the number of pointers of data contained in this event. |
michael@0 | 603 | * Always >= 1. */ |
michael@0 | 604 | size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event); |
michael@0 | 605 | |
michael@0 | 606 | /* Get the pointer identifier associated with a particular pointer |
michael@0 | 607 | * data index in this event. The identifier tells you the actual pointer |
michael@0 | 608 | * number associated with the data, accounting for individual pointers |
michael@0 | 609 | * going up and down since the start of the current gesture. */ |
michael@0 | 610 | int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 611 | |
michael@0 | 612 | /* Get the tool type of a pointer for the given pointer index. |
michael@0 | 613 | * The tool type indicates the type of tool used to make contact such as a |
michael@0 | 614 | * finger or stylus, if known. */ |
michael@0 | 615 | int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 616 | |
michael@0 | 617 | /* Get the original raw X coordinate of this event. |
michael@0 | 618 | * For touch events on the screen, this is the original location of the event |
michael@0 | 619 | * on the screen, before it had been adjusted for the containing window |
michael@0 | 620 | * and views. */ |
michael@0 | 621 | float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 622 | |
michael@0 | 623 | /* Get the original raw X coordinate of this event. |
michael@0 | 624 | * For touch events on the screen, this is the original location of the event |
michael@0 | 625 | * on the screen, before it had been adjusted for the containing window |
michael@0 | 626 | * and views. */ |
michael@0 | 627 | float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 628 | |
michael@0 | 629 | /* Get the current X coordinate of this event for the given pointer index. |
michael@0 | 630 | * Whole numbers are pixels; the value may have a fraction for input devices |
michael@0 | 631 | * that are sub-pixel precise. */ |
michael@0 | 632 | float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 633 | |
michael@0 | 634 | /* Get the current Y coordinate of this event for the given pointer index. |
michael@0 | 635 | * Whole numbers are pixels; the value may have a fraction for input devices |
michael@0 | 636 | * that are sub-pixel precise. */ |
michael@0 | 637 | float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 638 | |
michael@0 | 639 | /* Get the current pressure of this event for the given pointer index. |
michael@0 | 640 | * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), |
michael@0 | 641 | * although values higher than 1 may be generated depending on the calibration of |
michael@0 | 642 | * the input device. */ |
michael@0 | 643 | float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 644 | |
michael@0 | 645 | /* Get the current scaled value of the approximate size for the given pointer index. |
michael@0 | 646 | * This represents some approximation of the area of the screen being |
michael@0 | 647 | * pressed; the actual value in pixels corresponding to the |
michael@0 | 648 | * touch is normalized with the device specific range of values |
michael@0 | 649 | * and scaled to a value between 0 and 1. The value of size can be used to |
michael@0 | 650 | * determine fat touch events. */ |
michael@0 | 651 | float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 652 | |
michael@0 | 653 | /* Get the current length of the major axis of an ellipse that describes the touch area |
michael@0 | 654 | * at the point of contact for the given pointer index. */ |
michael@0 | 655 | float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 656 | |
michael@0 | 657 | /* Get the current length of the minor axis of an ellipse that describes the touch area |
michael@0 | 658 | * at the point of contact for the given pointer index. */ |
michael@0 | 659 | float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 660 | |
michael@0 | 661 | /* Get the current length of the major axis of an ellipse that describes the size |
michael@0 | 662 | * of the approaching tool for the given pointer index. |
michael@0 | 663 | * The tool area represents the estimated size of the finger or pen that is |
michael@0 | 664 | * touching the device independent of its actual touch area at the point of contact. */ |
michael@0 | 665 | float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 666 | |
michael@0 | 667 | /* Get the current length of the minor axis of an ellipse that describes the size |
michael@0 | 668 | * of the approaching tool for the given pointer index. |
michael@0 | 669 | * The tool area represents the estimated size of the finger or pen that is |
michael@0 | 670 | * touching the device independent of its actual touch area at the point of contact. */ |
michael@0 | 671 | float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 672 | |
michael@0 | 673 | /* Get the current orientation of the touch area and tool area in radians clockwise from |
michael@0 | 674 | * vertical for the given pointer index. |
michael@0 | 675 | * An angle of 0 degrees indicates that the major axis of contact is oriented |
michael@0 | 676 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
michael@0 | 677 | * indicates that the major axis of contact is oriented to the right. A negative angle |
michael@0 | 678 | * indicates that the major axis of contact is oriented to the left. |
michael@0 | 679 | * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians |
michael@0 | 680 | * (finger pointing fully right). */ |
michael@0 | 681 | float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index); |
michael@0 | 682 | |
michael@0 | 683 | /* Get the value of the request axis for the given pointer index. */ |
michael@0 | 684 | float AMotionEvent_getAxisValue(const AInputEvent* motion_event, |
michael@0 | 685 | int32_t axis, size_t pointer_index); |
michael@0 | 686 | |
michael@0 | 687 | /* Get the number of historical points in this event. These are movements that |
michael@0 | 688 | * have occurred between this event and the previous event. This only applies |
michael@0 | 689 | * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0. |
michael@0 | 690 | * Historical samples are indexed from oldest to newest. */ |
michael@0 | 691 | size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event); |
michael@0 | 692 | |
michael@0 | 693 | /* Get the time that a historical movement occurred between this event and |
michael@0 | 694 | * the previous event, in the java.lang.System.nanoTime() time base. */ |
michael@0 | 695 | int64_t AMotionEvent_getHistoricalEventTime(AInputEvent* motion_event, |
michael@0 | 696 | size_t history_index); |
michael@0 | 697 | |
michael@0 | 698 | /* Get the historical raw X coordinate of this event for the given pointer index that |
michael@0 | 699 | * occurred between this event and the previous motion event. |
michael@0 | 700 | * For touch events on the screen, this is the original location of the event |
michael@0 | 701 | * on the screen, before it had been adjusted for the containing window |
michael@0 | 702 | * and views. |
michael@0 | 703 | * Whole numbers are pixels; the value may have a fraction for input devices |
michael@0 | 704 | * that are sub-pixel precise. */ |
michael@0 | 705 | float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 706 | size_t history_index); |
michael@0 | 707 | |
michael@0 | 708 | /* Get the historical raw Y coordinate of this event for the given pointer index that |
michael@0 | 709 | * occurred between this event and the previous motion event. |
michael@0 | 710 | * For touch events on the screen, this is the original location of the event |
michael@0 | 711 | * on the screen, before it had been adjusted for the containing window |
michael@0 | 712 | * and views. |
michael@0 | 713 | * Whole numbers are pixels; the value may have a fraction for input devices |
michael@0 | 714 | * that are sub-pixel precise. */ |
michael@0 | 715 | float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 716 | size_t history_index); |
michael@0 | 717 | |
michael@0 | 718 | /* Get the historical X coordinate of this event for the given pointer index that |
michael@0 | 719 | * occurred between this event and the previous motion event. |
michael@0 | 720 | * Whole numbers are pixels; the value may have a fraction for input devices |
michael@0 | 721 | * that are sub-pixel precise. */ |
michael@0 | 722 | float AMotionEvent_getHistoricalX(AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 723 | size_t history_index); |
michael@0 | 724 | |
michael@0 | 725 | /* Get the historical Y coordinate of this event for the given pointer index that |
michael@0 | 726 | * occurred between this event and the previous motion event. |
michael@0 | 727 | * Whole numbers are pixels; the value may have a fraction for input devices |
michael@0 | 728 | * that are sub-pixel precise. */ |
michael@0 | 729 | float AMotionEvent_getHistoricalY(AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 730 | size_t history_index); |
michael@0 | 731 | |
michael@0 | 732 | /* Get the historical pressure of this event for the given pointer index that |
michael@0 | 733 | * occurred between this event and the previous motion event. |
michael@0 | 734 | * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), |
michael@0 | 735 | * although values higher than 1 may be generated depending on the calibration of |
michael@0 | 736 | * the input device. */ |
michael@0 | 737 | float AMotionEvent_getHistoricalPressure(AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 738 | size_t history_index); |
michael@0 | 739 | |
michael@0 | 740 | /* Get the current scaled value of the approximate size for the given pointer index that |
michael@0 | 741 | * occurred between this event and the previous motion event. |
michael@0 | 742 | * This represents some approximation of the area of the screen being |
michael@0 | 743 | * pressed; the actual value in pixels corresponding to the |
michael@0 | 744 | * touch is normalized with the device specific range of values |
michael@0 | 745 | * and scaled to a value between 0 and 1. The value of size can be used to |
michael@0 | 746 | * determine fat touch events. */ |
michael@0 | 747 | float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 748 | size_t history_index); |
michael@0 | 749 | |
michael@0 | 750 | /* Get the historical length of the major axis of an ellipse that describes the touch area |
michael@0 | 751 | * at the point of contact for the given pointer index that |
michael@0 | 752 | * occurred between this event and the previous motion event. */ |
michael@0 | 753 | float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 754 | size_t history_index); |
michael@0 | 755 | |
michael@0 | 756 | /* Get the historical length of the minor axis of an ellipse that describes the touch area |
michael@0 | 757 | * at the point of contact for the given pointer index that |
michael@0 | 758 | * occurred between this event and the previous motion event. */ |
michael@0 | 759 | float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 760 | size_t history_index); |
michael@0 | 761 | |
michael@0 | 762 | /* Get the historical length of the major axis of an ellipse that describes the size |
michael@0 | 763 | * of the approaching tool for the given pointer index that |
michael@0 | 764 | * occurred between this event and the previous motion event. |
michael@0 | 765 | * The tool area represents the estimated size of the finger or pen that is |
michael@0 | 766 | * touching the device independent of its actual touch area at the point of contact. */ |
michael@0 | 767 | float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 768 | size_t history_index); |
michael@0 | 769 | |
michael@0 | 770 | /* Get the historical length of the minor axis of an ellipse that describes the size |
michael@0 | 771 | * of the approaching tool for the given pointer index that |
michael@0 | 772 | * occurred between this event and the previous motion event. |
michael@0 | 773 | * The tool area represents the estimated size of the finger or pen that is |
michael@0 | 774 | * touching the device independent of its actual touch area at the point of contact. */ |
michael@0 | 775 | float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 776 | size_t history_index); |
michael@0 | 777 | |
michael@0 | 778 | /* Get the historical orientation of the touch area and tool area in radians clockwise from |
michael@0 | 779 | * vertical for the given pointer index that |
michael@0 | 780 | * occurred between this event and the previous motion event. |
michael@0 | 781 | * An angle of 0 degrees indicates that the major axis of contact is oriented |
michael@0 | 782 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
michael@0 | 783 | * indicates that the major axis of contact is oriented to the right. A negative angle |
michael@0 | 784 | * indicates that the major axis of contact is oriented to the left. |
michael@0 | 785 | * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians |
michael@0 | 786 | * (finger pointing fully right). */ |
michael@0 | 787 | float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, |
michael@0 | 788 | size_t history_index); |
michael@0 | 789 | |
michael@0 | 790 | /* Get the historical value of the request axis for the given pointer index |
michael@0 | 791 | * that occurred between this event and the previous motion event. */ |
michael@0 | 792 | float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, |
michael@0 | 793 | int32_t axis, size_t pointer_index, size_t history_index); |
michael@0 | 794 | |
michael@0 | 795 | |
michael@0 | 796 | /* |
michael@0 | 797 | * Input queue |
michael@0 | 798 | * |
michael@0 | 799 | * An input queue is the facility through which you retrieve input |
michael@0 | 800 | * events. |
michael@0 | 801 | */ |
michael@0 | 802 | struct AInputQueue; |
michael@0 | 803 | typedef struct AInputQueue AInputQueue; |
michael@0 | 804 | |
michael@0 | 805 | /* |
michael@0 | 806 | * Add this input queue to a looper for processing. See |
michael@0 | 807 | * ALooper_addFd() for information on the ident, callback, and data params. |
michael@0 | 808 | */ |
michael@0 | 809 | void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, |
michael@0 | 810 | int ident, ALooper_callbackFunc callback, void* data); |
michael@0 | 811 | |
michael@0 | 812 | /* |
michael@0 | 813 | * Remove the input queue from the looper it is currently attached to. |
michael@0 | 814 | */ |
michael@0 | 815 | void AInputQueue_detachLooper(AInputQueue* queue); |
michael@0 | 816 | |
michael@0 | 817 | /* |
michael@0 | 818 | * Returns true if there are one or more events available in the |
michael@0 | 819 | * input queue. Returns 1 if the queue has events; 0 if |
michael@0 | 820 | * it does not have events; and a negative value if there is an error. |
michael@0 | 821 | */ |
michael@0 | 822 | int32_t AInputQueue_hasEvents(AInputQueue* queue); |
michael@0 | 823 | |
michael@0 | 824 | /* |
michael@0 | 825 | * Returns the next available event from the queue. Returns a negative |
michael@0 | 826 | * value if no events are available or an error has occurred. |
michael@0 | 827 | */ |
michael@0 | 828 | int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent); |
michael@0 | 829 | |
michael@0 | 830 | /* |
michael@0 | 831 | * Sends the key for standard pre-dispatching -- that is, possibly deliver |
michael@0 | 832 | * it to the current IME to be consumed before the app. Returns 0 if it |
michael@0 | 833 | * was not pre-dispatched, meaning you can process it right now. If non-zero |
michael@0 | 834 | * is returned, you must abandon the current event processing and allow the |
michael@0 | 835 | * event to appear again in the event queue (if it does not get consumed during |
michael@0 | 836 | * pre-dispatching). |
michael@0 | 837 | */ |
michael@0 | 838 | int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event); |
michael@0 | 839 | |
michael@0 | 840 | /* |
michael@0 | 841 | * Report that dispatching has finished with the given event. |
michael@0 | 842 | * This must be called after receiving an event with AInputQueue_get_event(). |
michael@0 | 843 | */ |
michael@0 | 844 | void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled); |
michael@0 | 845 | |
michael@0 | 846 | #ifdef __cplusplus |
michael@0 | 847 | } |
michael@0 | 848 | #endif |
michael@0 | 849 | |
michael@0 | 850 | #endif // _ANDROID_INPUT_H |