1 /* 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 43 #include <stdint.h> 44 #include <sys/types.h> 45 #include <android/keycodes.h> 46 #include <android/looper.h> 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 /* 53 * Key states (may be returned by queries about the current state of a 54 * particular key code, scan code or switch). 55 */ 56 enum { 57 /* The key state is unknown or the requested key itself is not supported. */ 58 AKEY_STATE_UNKNOWN = -1, 59 60 /* The key is up. */ 61 AKEY_STATE_UP = 0, 62 63 /* The key is down. */ 64 AKEY_STATE_DOWN = 1, 65 66 /* The key is down but is a virtual key press that is being emulated by the system. */ 67 AKEY_STATE_VIRTUAL = 2 68 }; 69 70 /* 71 * Meta key / modifer state. 72 */ 73 enum { 74 /* No meta keys are pressed. */ 75 AMETA_NONE = 0, 76 77 /* This mask is used to check whether one of the ALT meta keys is pressed. */ 78 AMETA_ALT_ON = 0x02, 79 80 /* This mask is used to check whether the left ALT meta key is pressed. */ 81 AMETA_ALT_LEFT_ON = 0x10, 82 83 /* This mask is used to check whether the right ALT meta key is pressed. */ 84 AMETA_ALT_RIGHT_ON = 0x20, 85 86 /* This mask is used to check whether one of the SHIFT meta keys is pressed. */ 87 AMETA_SHIFT_ON = 0x01, 88 89 /* This mask is used to check whether the left SHIFT meta key is pressed. */ 90 AMETA_SHIFT_LEFT_ON = 0x40, 91 92 /* This mask is used to check whether the right SHIFT meta key is pressed. */ 93 AMETA_SHIFT_RIGHT_ON = 0x80, 94 95 /* This mask is used to check whether the SYM meta key is pressed. */ 96 AMETA_SYM_ON = 0x04 97 }; 98 99 /* 100 * Input events. 101 * 102 * Input events are opaque structures. Use the provided accessors functions to 103 * read their properties. 104 */ 105 struct AInputEvent; 106 typedef struct AInputEvent AInputEvent; 107 108 /* 109 * Input event types. 110 */ 111 enum { 112 /* Indicates that the input event is a key event. */ 113 AINPUT_EVENT_TYPE_KEY = 1, 114 115 /* Indicates that the input event is a motion event. */ 116 AINPUT_EVENT_TYPE_MOTION = 2 117 }; 118 119 /* 120 * Key event actions. 121 */ 122 enum { 123 /* The key has been pressed down. */ 124 AKEY_EVENT_ACTION_DOWN = 0, 125 126 /* The key has been released. */ 127 AKEY_EVENT_ACTION_UP = 1, 128 129 /* Multiple duplicate key events have occurred in a row, or a complex string is 130 * being delivered. The repeat_count property of the key event contains the number 131 * of times the given key code should be executed. 132 */ 133 AKEY_EVENT_ACTION_MULTIPLE = 2 134 }; 135 136 /* 137 * Key event flags. 138 */ 139 enum { 140 /* This mask is set if the device woke because of this key event. */ 141 AKEY_EVENT_FLAG_WOKE_HERE = 0x1, 142 143 /* This mask is set if the key event was generated by a software keyboard. */ 144 AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2, 145 146 /* This mask is set if we don't want the key event to cause us to leave touch mode. */ 147 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4, 148 149 /* This mask is set if an event was known to come from a trusted part 150 * of the system. That is, the event is known to come from the user, 151 * and could not have been spoofed by a third party component. */ 152 AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8, 153 154 /* This mask is used for compatibility, to identify enter keys that are 155 * coming from an IME whose enter key has been auto-labelled "next" or 156 * "done". This allows TextView to dispatch these as normal enter keys 157 * for old applications, but still do the appropriate action when 158 * receiving them. */ 159 AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10, 160 161 /* When associated with up key events, this indicates that the key press 162 * has been canceled. Typically this is used with virtual touch screen 163 * keys, where the user can slide from the virtual key area on to the 164 * display: in that case, the application will receive a canceled up 165 * event and should not perform the action normally associated with the 166 * key. Note that for this to work, the application can not perform an 167 * action for a key until it receives an up or the long press timeout has 168 * expired. */ 169 AKEY_EVENT_FLAG_CANCELED = 0x20, 170 171 /* This key event was generated by a virtual (on-screen) hard key area. 172 * Typically this is an area of the touchscreen, outside of the regular 173 * display, dedicated to "hardware" buttons. */ 174 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40, 175 176 /* This flag is set for the first key repeat that occurs after the 177 * long press timeout. */ 178 AKEY_EVENT_FLAG_LONG_PRESS = 0x80, 179 180 /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long 181 * press action was executed while it was down. */ 182 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100, 183 184 /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being 185 * tracked from its initial down. That is, somebody requested that tracking 186 * started on the key down and a long press has not caused 187 * the tracking to be canceled. */ 188 AKEY_EVENT_FLAG_TRACKING = 0x200 189 }; 190 191 /* 192 * Motion event actions. 193 */ 194 195 /* Bit shift for the action bits holding the pointer index as 196 * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK. 197 */ 198 #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 199 200 enum { 201 /* Bit mask of the parts of the action code that are the action itself. 202 */ 203 AMOTION_EVENT_ACTION_MASK = 0xff, 204 205 /* Bits in the action code that represent a pointer index, used with 206 * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting 207 * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer 208 * index where the data for the pointer going up or down can be found. 209 */ 210 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00, 211 212 /* A pressed gesture has started, the motion contains the initial starting location. 213 */ 214 AMOTION_EVENT_ACTION_DOWN = 0, 215 216 /* A pressed gesture has finished, the motion contains the final release location 217 * as well as any intermediate points since the last down or move event. 218 */ 219 AMOTION_EVENT_ACTION_UP = 1, 220 221 /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and 222 * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as 223 * any intermediate points since the last down or move event. 224 */ 225 AMOTION_EVENT_ACTION_MOVE = 2, 226 227 /* The current gesture has been aborted. 228 * You will not receive any more points in it. You should treat this as 229 * an up event, but not perform any action that you normally would. 230 */ 231 AMOTION_EVENT_ACTION_CANCEL = 3, 232 233 /* A movement has happened outside of the normal bounds of the UI element. 234 * This does not provide a full gesture, but only the initial location of the movement/touch. 235 */ 236 AMOTION_EVENT_ACTION_OUTSIDE = 4, 237 238 /* A non-primary pointer has gone down. 239 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. 240 */ 241 AMOTION_EVENT_ACTION_POINTER_DOWN = 5, 242 243 /* A non-primary pointer has gone up. 244 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. 245 */ 246 AMOTION_EVENT_ACTION_POINTER_UP = 6 247 }; 248 249 /* 250 * Motion event flags. 251 */ 252 enum { 253 /* This flag indicates that the window that received this motion event is partly 254 * or wholly obscured by another visible window above it. This flag is set to true 255 * even if the event did not directly pass through the obscured area. 256 * A security sensitive application can check this flag to identify situations in which 257 * a malicious application may have covered up part of its content for the purpose 258 * of misleading the user or hijacking touches. An appropriate response might be 259 * to drop the suspect touches or to take additional precautions to confirm the user's 260 * actual intent. 261 */ 262 AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1, 263 }; 264 265 /* 266 * Motion event edge touch flags. 267 */ 268 enum { 269 /* No edges intersected */ 270 AMOTION_EVENT_EDGE_FLAG_NONE = 0, 271 272 /* Flag indicating the motion event intersected the top edge of the screen. */ 273 AMOTION_EVENT_EDGE_FLAG_TOP = 0x01, 274 275 /* Flag indicating the motion event intersected the bottom edge of the screen. */ 276 AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02, 277 278 /* Flag indicating the motion event intersected the left edge of the screen. */ 279 AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04, 280 281 /* Flag indicating the motion event intersected the right edge of the screen. */ 282 AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08 283 }; 284 285 /* 286 * Input sources. 287 * 288 * Refer to the documentation on android.view.InputDevice for more details about input sources 289 * and their correct interpretation. 290 */ 291 enum { 292 AINPUT_SOURCE_CLASS_MASK = 0x000000ff, 293 294 AINPUT_SOURCE_CLASS_BUTTON = 0x00000001, 295 AINPUT_SOURCE_CLASS_POINTER = 0x00000002, 296 AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004, 297 AINPUT_SOURCE_CLASS_POSITION = 0x00000008, 298 }; 299 300 enum { 301 AINPUT_SOURCE_UNKNOWN = 0x00000000, 302 303 AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON, 304 AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON, 305 AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER, 306 AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER, 307 AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION, 308 AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION, 309 310 AINPUT_SOURCE_ANY = 0xffffff00, 311 }; 312 313 /* 314 * Keyboard types. 315 * 316 * Refer to the documentation on android.view.InputDevice for more details. 317 */ 318 enum { 319 AINPUT_KEYBOARD_TYPE_NONE = 0, 320 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1, 321 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2, 322 }; 323 324 /* 325 * Constants used to retrieve information about the range of motion for a particular 326 * coordinate of a motion event. 327 * 328 * Refer to the documentation on android.view.InputDevice for more details about input sources 329 * and their correct interpretation. 330 */ 331 enum { 332 AINPUT_MOTION_RANGE_X = 0, 333 AINPUT_MOTION_RANGE_Y = 1, 334 AINPUT_MOTION_RANGE_PRESSURE = 2, 335 AINPUT_MOTION_RANGE_SIZE = 3, 336 AINPUT_MOTION_RANGE_TOUCH_MAJOR = 4, 337 AINPUT_MOTION_RANGE_TOUCH_MINOR = 5, 338 AINPUT_MOTION_RANGE_TOOL_MAJOR = 6, 339 AINPUT_MOTION_RANGE_TOOL_MINOR = 7, 340 AINPUT_MOTION_RANGE_ORIENTATION = 8, 341 }; 342 343 344 /* 345 * Input event accessors. 346 * 347 * Note that most functions can only be used on input events that are of a given type. 348 * Calling these functions on input events of other types will yield undefined behavior. 349 */ 350 351 /*** Accessors for all input events. ***/ 352 353 /* Get the input event type. */ 354 int32_t AInputEvent_getType(const AInputEvent* event); 355 356 /* Get the id for the device that an input event came from. 357 * 358 * Input events can be generated by multiple different input devices. 359 * Use the input device id to obtain information about the input 360 * device that was responsible for generating a particular event. 361 * 362 * An input device id of 0 indicates that the event didn't come from a physical device; 363 * other numbers are arbitrary and you shouldn't depend on the values. 364 * Use the provided input device query API to obtain information about input devices. 365 */ 366 int32_t AInputEvent_getDeviceId(const AInputEvent* event); 367 368 /* Get the input event source. */ 369 int32_t AInputEvent_getSource(const AInputEvent* event); 370 371 /*** Accessors for key events only. ***/ 372 373 /* Get the key event action. */ 374 int32_t AKeyEvent_getAction(const AInputEvent* key_event); 375 376 /* Get the key event flags. */ 377 int32_t AKeyEvent_getFlags(const AInputEvent* key_event); 378 379 /* Get the key code of the key event. 380 * This is the physical key that was pressed, not the Unicode character. */ 381 int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event); 382 383 /* Get the hardware key id of this key event. 384 * These values are not reliable and vary from device to device. */ 385 int32_t AKeyEvent_getScanCode(const AInputEvent* key_event); 386 387 /* Get the meta key state. */ 388 int32_t AKeyEvent_getMetaState(const AInputEvent* key_event); 389 390 /* Get the repeat count of the event. 391 * For both key up an key down events, this is the number of times the key has 392 * repeated with the first down starting at 0 and counting up from there. For 393 * multiple key events, this is the number of down/up pairs that have occurred. */ 394 int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event); 395 396 /* Get the time of the most recent key down event, in the 397 * java.lang.System.nanoTime() time base. If this is a down event, 398 * this will be the same as eventTime. 399 * Note that when chording keys, this value is the down time of the most recently 400 * pressed key, which may not be the same physical key of this event. */ 401 int64_t AKeyEvent_getDownTime(const AInputEvent* key_event); 402 403 /* Get the time this event occurred, in the 404 * java.lang.System.nanoTime() time base. */ 405 int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); 406 407 /*** Accessors for motion events only. ***/ 408 409 /* Get the combined motion event action code and pointer index. */ 410 int32_t AMotionEvent_getAction(const AInputEvent* motion_event); 411 412 /* Get the motion event flags. */ 413 int32_t AMotionEvent_getFlags(const AInputEvent* motion_event); 414 415 /* Get the state of any meta / modifier keys that were in effect when the 416 * event was generated. */ 417 int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event); 418 419 /* Get a bitfield indicating which edges, if any, were touched by this motion event. 420 * For touch events, clients can use this to determine if the user's finger was 421 * touching the edge of the display. */ 422 int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event); 423 424 /* Get the time when the user originally pressed down to start a stream of 425 * position events, in the java.lang.System.nanoTime() time base. */ 426 int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event); 427 428 /* Get the time when this specific event was generated, 429 * in the java.lang.System.nanoTime() time base. */ 430 int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event); 431 432 /* Get the X coordinate offset. 433 * For touch events on the screen, this is the delta that was added to the raw 434 * screen coordinates to adjust for the absolute position of the containing windows 435 * and views. */ 436 float AMotionEvent_getXOffset(const AInputEvent* motion_event); 437 438 /* Get the precision of the Y coordinates being reported. 439 * For touch events on the screen, this is the delta that was added to the raw 440 * screen coordinates to adjust for the absolute position of the containing windows 441 * and views. */ 442 float AMotionEvent_getYOffset(const AInputEvent* motion_event); 443 444 /* Get the precision of the X coordinates being reported. 445 * You can multiply this number with an X coordinate sample to find the 446 * actual hardware value of the X coordinate. */ 447 float AMotionEvent_getXPrecision(const AInputEvent* motion_event); 448 449 /* Get the precision of the Y coordinates being reported. 450 * You can multiply this number with a Y coordinate sample to find the 451 * actual hardware value of the Y coordinate. */ 452 float AMotionEvent_getYPrecision(const AInputEvent* motion_event); 453 454 /* Get the number of pointers of data contained in this event. 455 * Always >= 1. */ 456 size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event); 457 458 /* Get the pointer identifier associated with a particular pointer 459 * data index is this event. The identifier tells you the actual pointer 460 * number associated with the data, accounting for individual pointers 461 * going up and down since the start of the current gesture. */ 462 int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index); 463 464 /* Get the original raw X coordinate of this event. 465 * For touch events on the screen, this is the original location of the event 466 * on the screen, before it had been adjusted for the containing window 467 * and views. */ 468 float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index); 469 470 /* Get the original raw X coordinate of this event. 471 * For touch events on the screen, this is the original location of the event 472 * on the screen, before it had been adjusted for the containing window 473 * and views. */ 474 float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index); 475 476 /* Get the current X coordinate of this event for the given pointer index. 477 * Whole numbers are pixels; the value may have a fraction for input devices 478 * that are sub-pixel precise. */ 479 float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index); 480 481 /* Get the current Y coordinate of this event for the given pointer index. 482 * Whole numbers are pixels; the value may have a fraction for input devices 483 * that are sub-pixel precise. */ 484 float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index); 485 486 /* Get the current pressure of this event for the given pointer index. 487 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), 488 * although values higher than 1 may be generated depending on the calibration of 489 * the input device. */ 490 float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index); 491 492 /* Get the current scaled value of the approximate size for the given pointer index. 493 * This represents some approximation of the area of the screen being 494 * pressed; the actual value in pixels corresponding to the 495 * touch is normalized with the device specific range of values 496 * and scaled to a value between 0 and 1. The value of size can be used to 497 * determine fat touch events. */ 498 float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index); 499 500 /* Get the current length of the major axis of an ellipse that describes the touch area 501 * at the point of contact for the given pointer index. */ 502 float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index); 503 504 /* Get the current length of the minor axis of an ellipse that describes the touch area 505 * at the point of contact for the given pointer index. */ 506 float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index); 507 508 /* Get the current length of the major axis of an ellipse that describes the size 509 * of the approaching tool for the given pointer index. 510 * The tool area represents the estimated size of the finger or pen that is 511 * touching the device independent of its actual touch area at the point of contact. */ 512 float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index); 513 514 /* Get the current length of the minor axis of an ellipse that describes the size 515 * of the approaching tool for the given pointer index. 516 * The tool area represents the estimated size of the finger or pen that is 517 * touching the device independent of its actual touch area at the point of contact. */ 518 float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index); 519 520 /* Get the current orientation of the touch area and tool area in radians clockwise from 521 * vertical for the given pointer index. 522 * An angle of 0 degrees indicates that the major axis of contact is oriented 523 * upwards, is perfectly circular or is of unknown orientation. A positive angle 524 * indicates that the major axis of contact is oriented to the right. A negative angle 525 * indicates that the major axis of contact is oriented to the left. 526 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians 527 * (finger pointing fully right). */ 528 float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index); 529 530 /* Get the number of historical points in this event. These are movements that 531 * have occurred between this event and the previous event. This only applies 532 * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0. 533 * Historical samples are indexed from oldest to newest. */ 534 size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event); 535 536 /* Get the time that a historical movement occurred between this event and 537 * the previous event, in the java.lang.System.nanoTime() time base. */ 538 int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event, 539 size_t history_index); 540 541 /* Get the historical raw X coordinate of this event for the given pointer index that 542 * occurred between this event and the previous motion event. 543 * For touch events on the screen, this is the original location of the event 544 * on the screen, before it had been adjusted for the containing window 545 * and views. 546 * Whole numbers are pixels; the value may have a fraction for input devices 547 * that are sub-pixel precise. */ 548 float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index, 549 size_t history_index); 550 551 /* Get the historical raw Y coordinate of this event for the given pointer index that 552 * occurred between this event and the previous motion event. 553 * For touch events on the screen, this is the original location of the event 554 * on the screen, before it had been adjusted for the containing window 555 * and views. 556 * Whole numbers are pixels; the value may have a fraction for input devices 557 * that are sub-pixel precise. */ 558 float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index, 559 size_t history_index); 560 561 /* Get the historical X coordinate of this event for the given pointer index that 562 * occurred between this event and the previous motion event. 563 * Whole numbers are pixels; the value may have a fraction for input devices 564 * that are sub-pixel precise. */ 565 float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index, 566 size_t history_index); 567 568 /* Get the historical Y coordinate of this event for the given pointer index that 569 * occurred between this event and the previous motion event. 570 * Whole numbers are pixels; the value may have a fraction for input devices 571 * that are sub-pixel precise. */ 572 float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index, 573 size_t history_index); 574 575 /* Get the historical pressure of this event for the given pointer index that 576 * occurred between this event and the previous motion event. 577 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), 578 * although values higher than 1 may be generated depending on the calibration of 579 * the input device. */ 580 float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index, 581 size_t history_index); 582 583 /* Get the current scaled value of the approximate size for the given pointer index that 584 * occurred between this event and the previous motion event. 585 * This represents some approximation of the area of the screen being 586 * pressed; the actual value in pixels corresponding to the 587 * touch is normalized with the device specific range of values 588 * and scaled to a value between 0 and 1. The value of size can be used to 589 * determine fat touch events. */ 590 float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index, 591 size_t history_index); 592 593 /* Get the historical length of the major axis of an ellipse that describes the touch area 594 * at the point of contact for the given pointer index that 595 * occurred between this event and the previous motion event. */ 596 float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index, 597 size_t history_index); 598 599 /* Get the historical length of the minor axis of an ellipse that describes the touch area 600 * at the point of contact for the given pointer index that 601 * occurred between this event and the previous motion event. */ 602 float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index, 603 size_t history_index); 604 605 /* Get the historical length of the major axis of an ellipse that describes the size 606 * of the approaching tool for the given pointer index that 607 * occurred between this event and the previous motion event. 608 * The tool area represents the estimated size of the finger or pen that is 609 * touching the device independent of its actual touch area at the point of contact. */ 610 float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index, 611 size_t history_index); 612 613 /* Get the historical length of the minor axis of an ellipse that describes the size 614 * of the approaching tool for the given pointer index that 615 * occurred between this event and the previous motion event. 616 * The tool area represents the estimated size of the finger or pen that is 617 * touching the device independent of its actual touch area at the point of contact. */ 618 float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index, 619 size_t history_index); 620 621 /* Get the historical orientation of the touch area and tool area in radians clockwise from 622 * vertical for the given pointer index that 623 * occurred between this event and the previous motion event. 624 * An angle of 0 degrees indicates that the major axis of contact is oriented 625 * upwards, is perfectly circular or is of unknown orientation. A positive angle 626 * indicates that the major axis of contact is oriented to the right. A negative angle 627 * indicates that the major axis of contact is oriented to the left. 628 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians 629 * (finger pointing fully right). */ 630 float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, 631 size_t history_index); 632 633 634 /* 635 * Input queue 636 * 637 * An input queue is the facility through which you retrieve input 638 * events. 639 */ 640 struct AInputQueue; 641 typedef struct AInputQueue AInputQueue; 642 643 /* 644 * Add this input queue to a looper for processing. See 645 * ALooper_addFd() for information on the ident, callback, and data params. 646 */ 647 void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, 648 int ident, ALooper_callbackFunc callback, void* data); 649 650 /* 651 * Remove the input queue from the looper it is currently attached to. 652 */ 653 void AInputQueue_detachLooper(AInputQueue* queue); 654 655 /* 656 * Returns true if there are one or more events available in the 657 * input queue. Returns 1 if the queue has events; 0 if 658 * it does not have events; and a negative value if there is an error. 659 */ 660 int32_t AInputQueue_hasEvents(AInputQueue* queue); 661 662 /* 663 * Returns the next available event from the queue. Returns a negative 664 * value if no events are available or an error has occurred. 665 */ 666 int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent); 667 668 /* 669 * Sends the key for standard pre-dispatching -- that is, possibly deliver 670 * it to the current IME to be consumed before the app. Returns 0 if it 671 * was not pre-dispatched, meaning you can process it right now. If non-zero 672 * is returned, you must abandon the current event processing and allow the 673 * event to appear again in the event queue (if it does not get consumed during 674 * pre-dispatching). 675 */ 676 int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event); 677 678 /* 679 * Report that dispatching has finished with the given event. 680 * This must be called after receiving an event with AInputQueue_get_event(). 681 */ 682 void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled); 683 684 #ifdef __cplusplus 685 } 686 #endif 687 688 #endif // _ANDROID_INPUT_H 689