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 /** 18 * @addtogroup Input 19 * @{ 20 */ 21 22 /** 23 * @file input.h 24 */ 25 26 #ifndef _ANDROID_INPUT_H 27 #define _ANDROID_INPUT_H 28 29 #include <sys/cdefs.h> 30 31 /****************************************************************** 32 * 33 * IMPORTANT NOTICE: 34 * 35 * This file is part of Android's set of stable system headers 36 * exposed by the Android NDK (Native Development Kit). 37 * 38 * Third-party source AND binary code relies on the definitions 39 * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. 40 * 41 * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) 42 * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS 43 * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY 44 * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES 45 */ 46 47 /* 48 * Structures and functions to receive and process input events in 49 * native code. 50 * 51 * NOTE: These functions MUST be implemented by /system/lib/libui.so 52 */ 53 54 #include <stdint.h> 55 #include <sys/types.h> 56 #include <android/keycodes.h> 57 #include <android/looper.h> 58 59 #if !defined(__INTRODUCED_IN) 60 #define __INTRODUCED_IN(__api_level) /* nothing */ 61 #endif 62 63 #ifdef __cplusplus 64 extern "C" { 65 #endif 66 67 /** 68 * Key states (may be returned by queries about the current state of a 69 * particular key code, scan code or switch). 70 */ 71 enum { 72 /** The key state is unknown or the requested key itself is not supported. */ 73 AKEY_STATE_UNKNOWN = -1, 74 75 /** The key is up. */ 76 AKEY_STATE_UP = 0, 77 78 /** The key is down. */ 79 AKEY_STATE_DOWN = 1, 80 81 /** The key is down but is a virtual key press that is being emulated by the system. */ 82 AKEY_STATE_VIRTUAL = 2 83 }; 84 85 /** 86 * Meta key / modifier state. 87 */ 88 enum { 89 /** No meta keys are pressed. */ 90 AMETA_NONE = 0, 91 92 /** This mask is used to check whether one of the ALT meta keys is pressed. */ 93 AMETA_ALT_ON = 0x02, 94 95 /** This mask is used to check whether the left ALT meta key is pressed. */ 96 AMETA_ALT_LEFT_ON = 0x10, 97 98 /** This mask is used to check whether the right ALT meta key is pressed. */ 99 AMETA_ALT_RIGHT_ON = 0x20, 100 101 /** This mask is used to check whether one of the SHIFT meta keys is pressed. */ 102 AMETA_SHIFT_ON = 0x01, 103 104 /** This mask is used to check whether the left SHIFT meta key is pressed. */ 105 AMETA_SHIFT_LEFT_ON = 0x40, 106 107 /** This mask is used to check whether the right SHIFT meta key is pressed. */ 108 AMETA_SHIFT_RIGHT_ON = 0x80, 109 110 /** This mask is used to check whether the SYM meta key is pressed. */ 111 AMETA_SYM_ON = 0x04, 112 113 /** This mask is used to check whether the FUNCTION meta key is pressed. */ 114 AMETA_FUNCTION_ON = 0x08, 115 116 /** This mask is used to check whether one of the CTRL meta keys is pressed. */ 117 AMETA_CTRL_ON = 0x1000, 118 119 /** This mask is used to check whether the left CTRL meta key is pressed. */ 120 AMETA_CTRL_LEFT_ON = 0x2000, 121 122 /** This mask is used to check whether the right CTRL meta key is pressed. */ 123 AMETA_CTRL_RIGHT_ON = 0x4000, 124 125 /** This mask is used to check whether one of the META meta keys is pressed. */ 126 AMETA_META_ON = 0x10000, 127 128 /** This mask is used to check whether the left META meta key is pressed. */ 129 AMETA_META_LEFT_ON = 0x20000, 130 131 /** This mask is used to check whether the right META meta key is pressed. */ 132 AMETA_META_RIGHT_ON = 0x40000, 133 134 /** This mask is used to check whether the CAPS LOCK meta key is on. */ 135 AMETA_CAPS_LOCK_ON = 0x100000, 136 137 /** This mask is used to check whether the NUM LOCK meta key is on. */ 138 AMETA_NUM_LOCK_ON = 0x200000, 139 140 /** This mask is used to check whether the SCROLL LOCK meta key is on. */ 141 AMETA_SCROLL_LOCK_ON = 0x400000, 142 }; 143 144 struct AInputEvent; 145 /** 146 * Input events. 147 * 148 * Input events are opaque structures. Use the provided accessors functions to 149 * read their properties. 150 */ 151 typedef struct AInputEvent AInputEvent; 152 153 /** 154 * Input event types. 155 */ 156 enum { 157 /** Indicates that the input event is a key event. */ 158 AINPUT_EVENT_TYPE_KEY = 1, 159 160 /** Indicates that the input event is a motion event. */ 161 AINPUT_EVENT_TYPE_MOTION = 2, 162 163 /** Focus event */ 164 AINPUT_EVENT_TYPE_FOCUS = 3, 165 }; 166 167 /** 168 * Key event actions. 169 */ 170 enum { 171 /** The key has been pressed down. */ 172 AKEY_EVENT_ACTION_DOWN = 0, 173 174 /** The key has been released. */ 175 AKEY_EVENT_ACTION_UP = 1, 176 177 /** 178 * Multiple duplicate key events have occurred in a row, or a 179 * complex string is being delivered. The repeat_count property 180 * of the key event contains the number of times the given key 181 * code should be executed. 182 */ 183 AKEY_EVENT_ACTION_MULTIPLE = 2 184 }; 185 186 /** 187 * Key event flags. 188 */ 189 enum { 190 /** This mask is set if the device woke because of this key event. */ 191 AKEY_EVENT_FLAG_WOKE_HERE = 0x1, 192 193 /** This mask is set if the key event was generated by a software keyboard. */ 194 AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2, 195 196 /** This mask is set if we don't want the key event to cause us to leave touch mode. */ 197 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4, 198 199 /** 200 * This mask is set if an event was known to come from a trusted 201 * part of the system. That is, the event is known to come from 202 * the user, and could not have been spoofed by a third party 203 * component. 204 */ 205 AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8, 206 207 /** 208 * This mask is used for compatibility, to identify enter keys that are 209 * coming from an IME whose enter key has been auto-labelled "next" or 210 * "done". This allows TextView to dispatch these as normal enter keys 211 * for old applications, but still do the appropriate action when 212 * receiving them. 213 */ 214 AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10, 215 216 /** 217 * When associated with up key events, this indicates that the key press 218 * has been canceled. Typically this is used with virtual touch screen 219 * keys, where the user can slide from the virtual key area on to the 220 * display: in that case, the application will receive a canceled up 221 * event and should not perform the action normally associated with the 222 * key. Note that for this to work, the application can not perform an 223 * action for a key until it receives an up or the long press timeout has 224 * expired. 225 */ 226 AKEY_EVENT_FLAG_CANCELED = 0x20, 227 228 /** 229 * This key event was generated by a virtual (on-screen) hard key area. 230 * Typically this is an area of the touchscreen, outside of the regular 231 * display, dedicated to "hardware" buttons. 232 */ 233 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40, 234 235 /** 236 * This flag is set for the first key repeat that occurs after the 237 * long press timeout. 238 */ 239 AKEY_EVENT_FLAG_LONG_PRESS = 0x80, 240 241 /** 242 * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long 243 * press action was executed while it was down. 244 */ 245 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100, 246 247 /** 248 * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being 249 * tracked from its initial down. That is, somebody requested that tracking 250 * started on the key down and a long press has not caused 251 * the tracking to be canceled. 252 */ 253 AKEY_EVENT_FLAG_TRACKING = 0x200, 254 255 /** 256 * Set when a key event has been synthesized to implement default behavior 257 * for an event that the application did not handle. 258 * Fallback key events are generated by unhandled trackball motions 259 * (to emulate a directional keypad) and by certain unhandled key presses 260 * that are declared in the key map (such as special function numeric keypad 261 * keys when numlock is off). 262 */ 263 AKEY_EVENT_FLAG_FALLBACK = 0x400, 264 }; 265 266 /** 267 * Bit shift for the action bits holding the pointer index as 268 * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK. 269 */ 270 #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 271 272 /** Motion event actions */ 273 enum { 274 /** Bit mask of the parts of the action code that are the action itself. */ 275 AMOTION_EVENT_ACTION_MASK = 0xff, 276 277 /** 278 * Bits in the action code that represent a pointer index, used with 279 * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting 280 * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer 281 * index where the data for the pointer going up or down can be found. 282 */ 283 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00, 284 285 /** A pressed gesture has started, the motion contains the initial starting location. */ 286 AMOTION_EVENT_ACTION_DOWN = 0, 287 288 /** 289 * A pressed gesture has finished, the motion contains the final release location 290 * as well as any intermediate points since the last down or move event. 291 */ 292 AMOTION_EVENT_ACTION_UP = 1, 293 294 /** 295 * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and 296 * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as 297 * any intermediate points since the last down or move event. 298 */ 299 AMOTION_EVENT_ACTION_MOVE = 2, 300 301 /** 302 * The current gesture has been aborted. 303 * You will not receive any more points in it. You should treat this as 304 * an up event, but not perform any action that you normally would. 305 */ 306 AMOTION_EVENT_ACTION_CANCEL = 3, 307 308 /** 309 * A movement has happened outside of the normal bounds of the UI element. 310 * This does not provide a full gesture, but only the initial location of the movement/touch. 311 */ 312 AMOTION_EVENT_ACTION_OUTSIDE = 4, 313 314 /** 315 * A non-primary pointer has gone down. 316 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. 317 */ 318 AMOTION_EVENT_ACTION_POINTER_DOWN = 5, 319 320 /** 321 * A non-primary pointer has gone up. 322 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. 323 */ 324 AMOTION_EVENT_ACTION_POINTER_UP = 6, 325 326 /** 327 * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE). 328 * The motion contains the most recent point, as well as any intermediate points since 329 * the last hover move event. 330 */ 331 AMOTION_EVENT_ACTION_HOVER_MOVE = 7, 332 333 /** 334 * The motion event contains relative vertical and/or horizontal scroll offsets. 335 * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL 336 * and AMOTION_EVENT_AXIS_HSCROLL. 337 * The pointer may or may not be down when this event is dispatched. 338 * This action is always delivered to the winder under the pointer, which 339 * may not be the window currently touched. 340 */ 341 AMOTION_EVENT_ACTION_SCROLL = 8, 342 343 /** The pointer is not down but has entered the boundaries of a window or view. */ 344 AMOTION_EVENT_ACTION_HOVER_ENTER = 9, 345 346 /** The pointer is not down but has exited the boundaries of a window or view. */ 347 AMOTION_EVENT_ACTION_HOVER_EXIT = 10, 348 349 /* One or more buttons have been pressed. */ 350 AMOTION_EVENT_ACTION_BUTTON_PRESS = 11, 351 352 /* One or more buttons have been released. */ 353 AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12, 354 }; 355 356 /** 357 * Motion event flags. 358 */ 359 enum { 360 /** 361 * This flag indicates that the window that received this motion event is partly 362 * or wholly obscured by another visible window above it. This flag is set to true 363 * even if the event did not directly pass through the obscured area. 364 * A security sensitive application can check this flag to identify situations in which 365 * a malicious application may have covered up part of its content for the purpose 366 * of misleading the user or hijacking touches. An appropriate response might be 367 * to drop the suspect touches or to take additional precautions to confirm the user's 368 * actual intent. 369 */ 370 AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1, 371 }; 372 373 /** 374 * Motion event edge touch flags. 375 */ 376 enum { 377 /** No edges intersected. */ 378 AMOTION_EVENT_EDGE_FLAG_NONE = 0, 379 380 /** Flag indicating the motion event intersected the top edge of the screen. */ 381 AMOTION_EVENT_EDGE_FLAG_TOP = 0x01, 382 383 /** Flag indicating the motion event intersected the bottom edge of the screen. */ 384 AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02, 385 386 /** Flag indicating the motion event intersected the left edge of the screen. */ 387 AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04, 388 389 /** Flag indicating the motion event intersected the right edge of the screen. */ 390 AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08 391 }; 392 393 /** 394 * Constants that identify each individual axis of a motion event. 395 * @anchor AMOTION_EVENT_AXIS 396 */ 397 enum { 398 /** 399 * Axis constant: X axis of a motion event. 400 * 401 * - For a touch screen, reports the absolute X screen position of the center of 402 * the touch contact area. The units are display pixels. 403 * - For a touch pad, reports the absolute X surface position of the center of the touch 404 * contact area. The units are device-dependent. 405 * - For a mouse, reports the absolute X screen position of the mouse pointer. 406 * The units are display pixels. 407 * - For a trackball, reports the relative horizontal displacement of the trackball. 408 * The value is normalized to a range from -1.0 (left) to 1.0 (right). 409 * - For a joystick, reports the absolute X position of the joystick. 410 * The value is normalized to a range from -1.0 (left) to 1.0 (right). 411 */ 412 AMOTION_EVENT_AXIS_X = 0, 413 /** 414 * Axis constant: Y axis of a motion event. 415 * 416 * - For a touch screen, reports the absolute Y screen position of the center of 417 * the touch contact area. The units are display pixels. 418 * - For a touch pad, reports the absolute Y surface position of the center of the touch 419 * contact area. The units are device-dependent. 420 * - For a mouse, reports the absolute Y screen position of the mouse pointer. 421 * The units are display pixels. 422 * - For a trackball, reports the relative vertical displacement of the trackball. 423 * The value is normalized to a range from -1.0 (up) to 1.0 (down). 424 * - For a joystick, reports the absolute Y position of the joystick. 425 * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near). 426 */ 427 AMOTION_EVENT_AXIS_Y = 1, 428 /** 429 * Axis constant: Pressure axis of a motion event. 430 * 431 * - For a touch screen or touch pad, reports the approximate pressure applied to the surface 432 * by a finger or other tool. The value is normalized to a range from 433 * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1 434 * may be generated depending on the calibration of the input device. 435 * - For a trackball, the value is set to 1 if the trackball button is pressed 436 * or 0 otherwise. 437 * - For a mouse, the value is set to 1 if the primary mouse button is pressed 438 * or 0 otherwise. 439 */ 440 AMOTION_EVENT_AXIS_PRESSURE = 2, 441 /** 442 * Axis constant: Size axis of a motion event. 443 * 444 * - For a touch screen or touch pad, reports the approximate size of the contact area in 445 * relation to the maximum detectable size for the device. The value is normalized 446 * to a range from 0 (smallest detectable size) to 1 (largest detectable size), 447 * although it is not a linear scale. This value is of limited use. 448 * To obtain calibrated size information, see 449 * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}. 450 */ 451 AMOTION_EVENT_AXIS_SIZE = 3, 452 /** 453 * Axis constant: TouchMajor axis of a motion event. 454 * 455 * - For a touch screen, reports the length of the major axis of an ellipse that 456 * represents the touch area at the point of contact. 457 * The units are display pixels. 458 * - For a touch pad, reports the length of the major axis of an ellipse that 459 * represents the touch area at the point of contact. 460 * The units are device-dependent. 461 */ 462 AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4, 463 /** 464 * Axis constant: TouchMinor axis of a motion event. 465 * 466 * - For a touch screen, reports the length of the minor axis of an ellipse that 467 * represents the touch area at the point of contact. 468 * The units are display pixels. 469 * - For a touch pad, reports the length of the minor axis of an ellipse that 470 * represents the touch area at the point of contact. 471 * The units are device-dependent. 472 * 473 * When the touch is circular, the major and minor axis lengths will be equal to one another. 474 */ 475 AMOTION_EVENT_AXIS_TOUCH_MINOR = 5, 476 /** 477 * Axis constant: ToolMajor axis of a motion event. 478 * 479 * - For a touch screen, reports the length of the major axis of an ellipse that 480 * represents the size of the approaching finger or tool used to make contact. 481 * - For a touch pad, reports the length of the major axis of an ellipse that 482 * represents the size of the approaching finger or tool used to make contact. 483 * The units are device-dependent. 484 * 485 * When the touch is circular, the major and minor axis lengths will be equal to one another. 486 * 487 * The tool size may be larger than the touch size since the tool may not be fully 488 * in contact with the touch sensor. 489 */ 490 AMOTION_EVENT_AXIS_TOOL_MAJOR = 6, 491 /** 492 * Axis constant: ToolMinor axis of a motion event. 493 * 494 * - For a touch screen, reports the length of the minor axis of an ellipse that 495 * represents the size of the approaching finger or tool used to make contact. 496 * - For a touch pad, reports the length of the minor axis of an ellipse that 497 * represents the size of the approaching finger or tool used to make contact. 498 * The units are device-dependent. 499 * 500 * When the touch is circular, the major and minor axis lengths will be equal to one another. 501 * 502 * The tool size may be larger than the touch size since the tool may not be fully 503 * in contact with the touch sensor. 504 */ 505 AMOTION_EVENT_AXIS_TOOL_MINOR = 7, 506 /** 507 * Axis constant: Orientation axis of a motion event. 508 * 509 * - For a touch screen or touch pad, reports the orientation of the finger 510 * or tool in radians relative to the vertical plane of the device. 511 * An angle of 0 radians indicates that the major axis of contact is oriented 512 * upwards, is perfectly circular or is of unknown orientation. A positive angle 513 * indicates that the major axis of contact is oriented to the right. A negative angle 514 * indicates that the major axis of contact is oriented to the left. 515 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians 516 * (finger pointing fully right). 517 * - For a stylus, the orientation indicates the direction in which the stylus 518 * is pointing in relation to the vertical axis of the current orientation of the screen. 519 * The range is from -PI radians to PI radians, where 0 is pointing up, 520 * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians 521 * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}. 522 */ 523 AMOTION_EVENT_AXIS_ORIENTATION = 8, 524 /** 525 * Axis constant: Vertical Scroll axis of a motion event. 526 * 527 * - For a mouse, reports the relative movement of the vertical scroll wheel. 528 * The value is normalized to a range from -1.0 (down) to 1.0 (up). 529 * 530 * This axis should be used to scroll views vertically. 531 */ 532 AMOTION_EVENT_AXIS_VSCROLL = 9, 533 /** 534 * Axis constant: Horizontal Scroll axis of a motion event. 535 * 536 * - For a mouse, reports the relative movement of the horizontal scroll wheel. 537 * The value is normalized to a range from -1.0 (left) to 1.0 (right). 538 * 539 * This axis should be used to scroll views horizontally. 540 */ 541 AMOTION_EVENT_AXIS_HSCROLL = 10, 542 /** 543 * Axis constant: Z axis of a motion event. 544 * 545 * - For a joystick, reports the absolute Z position of the joystick. 546 * The value is normalized to a range from -1.0 (high) to 1.0 (low). 547 * <em>On game pads with two analog joysticks, this axis is often reinterpreted 548 * to report the absolute X position of the second joystick instead.</em> 549 */ 550 AMOTION_EVENT_AXIS_Z = 11, 551 /** 552 * Axis constant: X Rotation axis of a motion event. 553 * 554 * - For a joystick, reports the absolute rotation angle about the X axis. 555 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). 556 */ 557 AMOTION_EVENT_AXIS_RX = 12, 558 /** 559 * Axis constant: Y Rotation axis of a motion event. 560 * 561 * - For a joystick, reports the absolute rotation angle about the Y axis. 562 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). 563 */ 564 AMOTION_EVENT_AXIS_RY = 13, 565 /** 566 * Axis constant: Z Rotation axis of a motion event. 567 * 568 * - For a joystick, reports the absolute rotation angle about the Z axis. 569 * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). 570 * On game pads with two analog joysticks, this axis is often reinterpreted 571 * to report the absolute Y position of the second joystick instead. 572 */ 573 AMOTION_EVENT_AXIS_RZ = 14, 574 /** 575 * Axis constant: Hat X axis of a motion event. 576 * 577 * - For a joystick, reports the absolute X position of the directional hat control. 578 * The value is normalized to a range from -1.0 (left) to 1.0 (right). 579 */ 580 AMOTION_EVENT_AXIS_HAT_X = 15, 581 /** 582 * Axis constant: Hat Y axis of a motion event. 583 * 584 * - For a joystick, reports the absolute Y position of the directional hat control. 585 * The value is normalized to a range from -1.0 (up) to 1.0 (down). 586 */ 587 AMOTION_EVENT_AXIS_HAT_Y = 16, 588 /** 589 * Axis constant: Left Trigger axis of a motion event. 590 * 591 * - For a joystick, reports the absolute position of the left trigger control. 592 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). 593 */ 594 AMOTION_EVENT_AXIS_LTRIGGER = 17, 595 /** 596 * Axis constant: Right Trigger axis of a motion event. 597 * 598 * - For a joystick, reports the absolute position of the right trigger control. 599 * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). 600 */ 601 AMOTION_EVENT_AXIS_RTRIGGER = 18, 602 /** 603 * Axis constant: Throttle axis of a motion event. 604 * 605 * - For a joystick, reports the absolute position of the throttle control. 606 * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed). 607 */ 608 AMOTION_EVENT_AXIS_THROTTLE = 19, 609 /** 610 * Axis constant: Rudder axis of a motion event. 611 * 612 * - For a joystick, reports the absolute position of the rudder control. 613 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). 614 */ 615 AMOTION_EVENT_AXIS_RUDDER = 20, 616 /** 617 * Axis constant: Wheel axis of a motion event. 618 * 619 * - For a joystick, reports the absolute position of the steering wheel control. 620 * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). 621 */ 622 AMOTION_EVENT_AXIS_WHEEL = 21, 623 /** 624 * Axis constant: Gas axis of a motion event. 625 * 626 * - For a joystick, reports the absolute position of the gas (accelerator) control. 627 * The value is normalized to a range from 0.0 (no acceleration) 628 * to 1.0 (maximum acceleration). 629 */ 630 AMOTION_EVENT_AXIS_GAS = 22, 631 /** 632 * Axis constant: Brake axis of a motion event. 633 * 634 * - For a joystick, reports the absolute position of the brake control. 635 * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking). 636 */ 637 AMOTION_EVENT_AXIS_BRAKE = 23, 638 /** 639 * Axis constant: Distance axis of a motion event. 640 * 641 * - For a stylus, reports the distance of the stylus from the screen. 642 * A value of 0.0 indicates direct contact and larger values indicate increasing 643 * distance from the surface. 644 */ 645 AMOTION_EVENT_AXIS_DISTANCE = 24, 646 /** 647 * Axis constant: Tilt axis of a motion event. 648 * 649 * - For a stylus, reports the tilt angle of the stylus in radians where 650 * 0 radians indicates that the stylus is being held perpendicular to the 651 * surface, and PI/2 radians indicates that the stylus is being held flat 652 * against the surface. 653 */ 654 AMOTION_EVENT_AXIS_TILT = 25, 655 /** 656 * Axis constant: Generic scroll axis of a motion event. 657 * 658 * - This is used for scroll axis motion events that can't be classified as strictly 659 * vertical or horizontal. The movement of a rotating scroller is an example of this. 660 */ 661 AMOTION_EVENT_AXIS_SCROLL = 26, 662 /** 663 * Axis constant: The movement of x position of a motion event. 664 * 665 * - For a mouse, reports a difference of x position between the previous position. 666 * This is useful when pointer is captured, in that case the mouse pointer doesn't 667 * change the location but this axis reports the difference which allows the app 668 * to see how the mouse is moved. 669 */ 670 AMOTION_EVENT_AXIS_RELATIVE_X = 27, 671 /** 672 * Axis constant: The movement of y position of a motion event. 673 * 674 * Same as {@link RELATIVE_X}, but for y position. 675 */ 676 AMOTION_EVENT_AXIS_RELATIVE_Y = 28, 677 /** 678 * Axis constant: Generic 1 axis of a motion event. 679 * The interpretation of a generic axis is device-specific. 680 */ 681 AMOTION_EVENT_AXIS_GENERIC_1 = 32, 682 /** 683 * Axis constant: Generic 2 axis of a motion event. 684 * The interpretation of a generic axis is device-specific. 685 */ 686 AMOTION_EVENT_AXIS_GENERIC_2 = 33, 687 /** 688 * Axis constant: Generic 3 axis of a motion event. 689 * The interpretation of a generic axis is device-specific. 690 */ 691 AMOTION_EVENT_AXIS_GENERIC_3 = 34, 692 /** 693 * Axis constant: Generic 4 axis of a motion event. 694 * The interpretation of a generic axis is device-specific. 695 */ 696 AMOTION_EVENT_AXIS_GENERIC_4 = 35, 697 /** 698 * Axis constant: Generic 5 axis of a motion event. 699 * The interpretation of a generic axis is device-specific. 700 */ 701 AMOTION_EVENT_AXIS_GENERIC_5 = 36, 702 /** 703 * Axis constant: Generic 6 axis of a motion event. 704 * The interpretation of a generic axis is device-specific. 705 */ 706 AMOTION_EVENT_AXIS_GENERIC_6 = 37, 707 /** 708 * Axis constant: Generic 7 axis of a motion event. 709 * The interpretation of a generic axis is device-specific. 710 */ 711 AMOTION_EVENT_AXIS_GENERIC_7 = 38, 712 /** 713 * Axis constant: Generic 8 axis of a motion event. 714 * The interpretation of a generic axis is device-specific. 715 */ 716 AMOTION_EVENT_AXIS_GENERIC_8 = 39, 717 /** 718 * Axis constant: Generic 9 axis of a motion event. 719 * The interpretation of a generic axis is device-specific. 720 */ 721 AMOTION_EVENT_AXIS_GENERIC_9 = 40, 722 /** 723 * Axis constant: Generic 10 axis of a motion event. 724 * The interpretation of a generic axis is device-specific. 725 */ 726 AMOTION_EVENT_AXIS_GENERIC_10 = 41, 727 /** 728 * Axis constant: Generic 11 axis of a motion event. 729 * The interpretation of a generic axis is device-specific. 730 */ 731 AMOTION_EVENT_AXIS_GENERIC_11 = 42, 732 /** 733 * Axis constant: Generic 12 axis of a motion event. 734 * The interpretation of a generic axis is device-specific. 735 */ 736 AMOTION_EVENT_AXIS_GENERIC_12 = 43, 737 /** 738 * Axis constant: Generic 13 axis of a motion event. 739 * The interpretation of a generic axis is device-specific. 740 */ 741 AMOTION_EVENT_AXIS_GENERIC_13 = 44, 742 /** 743 * Axis constant: Generic 14 axis of a motion event. 744 * The interpretation of a generic axis is device-specific. 745 */ 746 AMOTION_EVENT_AXIS_GENERIC_14 = 45, 747 /** 748 * Axis constant: Generic 15 axis of a motion event. 749 * The interpretation of a generic axis is device-specific. 750 */ 751 AMOTION_EVENT_AXIS_GENERIC_15 = 46, 752 /** 753 * Axis constant: Generic 16 axis of a motion event. 754 * The interpretation of a generic axis is device-specific. 755 */ 756 AMOTION_EVENT_AXIS_GENERIC_16 = 47, 757 758 // NOTE: If you add a new axis here you must also add it to several other files. 759 // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list. 760 }; 761 762 /** 763 * Constants that identify buttons that are associated with motion events. 764 * Refer to the documentation on the MotionEvent class for descriptions of each button. 765 */ 766 enum { 767 /** primary */ 768 AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0, 769 /** secondary */ 770 AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1, 771 /** tertiary */ 772 AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2, 773 /** back */ 774 AMOTION_EVENT_BUTTON_BACK = 1 << 3, 775 /** forward */ 776 AMOTION_EVENT_BUTTON_FORWARD = 1 << 4, 777 AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5, 778 AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6, 779 }; 780 781 /** 782 * Constants that identify tool types. 783 * Refer to the documentation on the MotionEvent class for descriptions of each tool type. 784 */ 785 enum { 786 /** unknown */ 787 AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0, 788 /** finger */ 789 AMOTION_EVENT_TOOL_TYPE_FINGER = 1, 790 /** stylus */ 791 AMOTION_EVENT_TOOL_TYPE_STYLUS = 2, 792 /** mouse */ 793 AMOTION_EVENT_TOOL_TYPE_MOUSE = 3, 794 /** eraser */ 795 AMOTION_EVENT_TOOL_TYPE_ERASER = 4, 796 /** palm */ 797 AMOTION_EVENT_TOOL_TYPE_PALM = 5, 798 }; 799 800 /** 801 * Input source masks. 802 * 803 * Refer to the documentation on android.view.InputDevice for more details about input sources 804 * and their correct interpretation. 805 */ 806 enum { 807 /** mask */ 808 AINPUT_SOURCE_CLASS_MASK = 0x000000ff, 809 810 /** none */ 811 AINPUT_SOURCE_CLASS_NONE = 0x00000000, 812 /** button */ 813 AINPUT_SOURCE_CLASS_BUTTON = 0x00000001, 814 /** pointer */ 815 AINPUT_SOURCE_CLASS_POINTER = 0x00000002, 816 /** navigation */ 817 AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004, 818 /** position */ 819 AINPUT_SOURCE_CLASS_POSITION = 0x00000008, 820 /** joystick */ 821 AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010, 822 }; 823 824 /** 825 * Input sources. 826 */ 827 enum { 828 /** unknown */ 829 AINPUT_SOURCE_UNKNOWN = 0x00000000, 830 831 /** keyboard */ 832 AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON, 833 /** dpad */ 834 AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON, 835 /** gamepad */ 836 AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON, 837 /** touchscreen */ 838 AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER, 839 /** mouse */ 840 AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER, 841 /** stylus */ 842 AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER, 843 /** bluetooth stylus */ 844 AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS, 845 /** trackball */ 846 AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION, 847 /** mouse relative */ 848 AINPUT_SOURCE_MOUSE_RELATIVE = 0x00020000 | AINPUT_SOURCE_CLASS_NAVIGATION, 849 /** touchpad */ 850 AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION, 851 /** navigation */ 852 AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE, 853 /** joystick */ 854 AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK, 855 /** rotary encoder */ 856 AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE, 857 858 /** any */ 859 AINPUT_SOURCE_ANY = 0xffffff00, 860 }; 861 862 /** 863 * Keyboard types. 864 * 865 * Refer to the documentation on android.view.InputDevice for more details. 866 */ 867 enum { 868 /** none */ 869 AINPUT_KEYBOARD_TYPE_NONE = 0, 870 /** non alphabetic */ 871 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1, 872 /** alphabetic */ 873 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2, 874 }; 875 876 /** 877 * Constants used to retrieve information about the range of motion for a particular 878 * coordinate of a motion event. 879 * 880 * Refer to the documentation on android.view.InputDevice for more details about input sources 881 * and their correct interpretation. 882 * 883 * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead. 884 */ 885 enum { 886 /** x */ 887 AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X, 888 /** y */ 889 AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y, 890 /** pressure */ 891 AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE, 892 /** size */ 893 AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE, 894 /** touch major */ 895 AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR, 896 /** touch minor */ 897 AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR, 898 /** tool major */ 899 AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR, 900 /** tool minor */ 901 AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR, 902 /** orientation */ 903 AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION, 904 }; 905 906 907 /** 908 * Input event accessors. 909 * 910 * Note that most functions can only be used on input events that are of a given type. 911 * Calling these functions on input events of other types will yield undefined behavior. 912 */ 913 914 /*** Accessors for all input events. ***/ 915 916 /** Get the input event type. */ 917 int32_t AInputEvent_getType(const AInputEvent* event); 918 919 /** Get the id for the device that an input event came from. 920 * 921 * Input events can be generated by multiple different input devices. 922 * Use the input device id to obtain information about the input 923 * device that was responsible for generating a particular event. 924 * 925 * An input device id of 0 indicates that the event didn't come from a physical device; 926 * other numbers are arbitrary and you shouldn't depend on the values. 927 * Use the provided input device query API to obtain information about input devices. 928 */ 929 int32_t AInputEvent_getDeviceId(const AInputEvent* event); 930 931 /** Get the input event source. */ 932 int32_t AInputEvent_getSource(const AInputEvent* event); 933 934 /*** Accessors for key events only. ***/ 935 936 /** Get the key event action. */ 937 int32_t AKeyEvent_getAction(const AInputEvent* key_event); 938 939 /** Get the key event flags. */ 940 int32_t AKeyEvent_getFlags(const AInputEvent* key_event); 941 942 /** 943 * Get the key code of the key event. 944 * This is the physical key that was pressed, not the Unicode character. 945 */ 946 int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event); 947 948 /** 949 * Get the hardware key id of this key event. 950 * These values are not reliable and vary from device to device. 951 */ 952 int32_t AKeyEvent_getScanCode(const AInputEvent* key_event); 953 954 /** Get the meta key state. */ 955 int32_t AKeyEvent_getMetaState(const AInputEvent* key_event); 956 957 /** 958 * Get the repeat count of the event. 959 * For both key up an key down events, this is the number of times the key has 960 * repeated with the first down starting at 0 and counting up from there. For 961 * multiple key events, this is the number of down/up pairs that have occurred. 962 */ 963 int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event); 964 965 /** 966 * Get the time of the most recent key down event, in the 967 * java.lang.System.nanoTime() time base. If this is a down event, 968 * this will be the same as eventTime. 969 * Note that when chording keys, this value is the down time of the most recently 970 * pressed key, which may not be the same physical key of this event. 971 */ 972 int64_t AKeyEvent_getDownTime(const AInputEvent* key_event); 973 974 /** 975 * Get the time this event occurred, in the 976 * java.lang.System.nanoTime() time base. 977 */ 978 int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); 979 980 /*** Accessors for motion events only. ***/ 981 982 /** Get the combined motion event action code and pointer index. */ 983 int32_t AMotionEvent_getAction(const AInputEvent* motion_event); 984 985 /** Get the motion event flags. */ 986 int32_t AMotionEvent_getFlags(const AInputEvent* motion_event); 987 988 /** 989 * Get the state of any meta / modifier keys that were in effect when the 990 * event was generated. 991 */ 992 int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event); 993 994 /** Get the button state of all buttons that are pressed. */ 995 int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event); 996 997 /** 998 * Get a bitfield indicating which edges, if any, were touched by this motion event. 999 * For touch events, clients can use this to determine if the user's finger was 1000 * touching the edge of the display. 1001 */ 1002 int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event); 1003 1004 /** 1005 * Get the time when the user originally pressed down to start a stream of 1006 * position events, in the java.lang.System.nanoTime() time base. 1007 */ 1008 int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event); 1009 1010 /** 1011 * Get the time when this specific event was generated, 1012 * in the java.lang.System.nanoTime() time base. 1013 */ 1014 int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event); 1015 1016 /** 1017 * Get the X coordinate offset. 1018 * For touch events on the screen, this is the delta that was added to the raw 1019 * screen coordinates to adjust for the absolute position of the containing windows 1020 * and views. 1021 */ 1022 float AMotionEvent_getXOffset(const AInputEvent* motion_event); 1023 1024 /** 1025 * Get the Y coordinate offset. 1026 * For touch events on the screen, this is the delta that was added to the raw 1027 * screen coordinates to adjust for the absolute position of the containing windows 1028 * and views. 1029 */ 1030 float AMotionEvent_getYOffset(const AInputEvent* motion_event); 1031 1032 /** 1033 * Get the precision of the X coordinates being reported. 1034 * You can multiply this number with an X coordinate sample to find the 1035 * actual hardware value of the X coordinate. 1036 */ 1037 float AMotionEvent_getXPrecision(const AInputEvent* motion_event); 1038 1039 /** 1040 * Get the precision of the Y coordinates being reported. 1041 * You can multiply this number with a Y coordinate sample to find the 1042 * actual hardware value of the Y coordinate. 1043 */ 1044 float AMotionEvent_getYPrecision(const AInputEvent* motion_event); 1045 1046 /** 1047 * Get the number of pointers of data contained in this event. 1048 * Always >= 1. 1049 */ 1050 size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event); 1051 1052 /** 1053 * Get the pointer identifier associated with a particular pointer 1054 * data index in this event. The identifier tells you the actual pointer 1055 * number associated with the data, accounting for individual pointers 1056 * going up and down since the start of the current gesture. 1057 */ 1058 int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index); 1059 1060 /** 1061 * Get the tool type of a pointer for the given pointer index. 1062 * The tool type indicates the type of tool used to make contact such as a 1063 * finger or stylus, if known. 1064 */ 1065 int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index); 1066 1067 /** 1068 * Get the original raw X coordinate of this event. 1069 * For touch events on the screen, this is the original location of the event 1070 * on the screen, before it had been adjusted for the containing window 1071 * and views. 1072 */ 1073 float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index); 1074 1075 /** 1076 * Get the original raw X coordinate of this event. 1077 * For touch events on the screen, this is the original location of the event 1078 * on the screen, before it had been adjusted for the containing window 1079 * and views. 1080 */ 1081 float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index); 1082 1083 /** 1084 * Get the current X coordinate of this event for the given pointer index. 1085 * Whole numbers are pixels; the value may have a fraction for input devices 1086 * that are sub-pixel precise. 1087 */ 1088 float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index); 1089 1090 /** 1091 * Get the current Y coordinate of this event for the given pointer index. 1092 * Whole numbers are pixels; the value may have a fraction for input devices 1093 * that are sub-pixel precise. 1094 */ 1095 float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index); 1096 1097 /** 1098 * Get the current pressure of this event for the given pointer index. 1099 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), 1100 * although values higher than 1 may be generated depending on the calibration of 1101 * the input device. 1102 */ 1103 float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index); 1104 1105 /** 1106 * Get the current scaled value of the approximate size for the given pointer index. 1107 * This represents some approximation of the area of the screen being 1108 * pressed; the actual value in pixels corresponding to the 1109 * touch is normalized with the device specific range of values 1110 * and scaled to a value between 0 and 1. The value of size can be used to 1111 * determine fat touch events. 1112 */ 1113 float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index); 1114 1115 /** 1116 * Get the current length of the major axis of an ellipse that describes the touch area 1117 * at the point of contact for the given pointer index. 1118 */ 1119 float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index); 1120 1121 /** 1122 * Get the current length of the minor axis of an ellipse that describes the touch area 1123 * at the point of contact for the given pointer index. 1124 */ 1125 float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index); 1126 1127 /** 1128 * Get the current length of the major axis of an ellipse that describes the size 1129 * of the approaching tool for the given pointer index. 1130 * The tool area represents the estimated size of the finger or pen that is 1131 * touching the device independent of its actual touch area at the point of contact. 1132 */ 1133 float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index); 1134 1135 /** 1136 * Get the current length of the minor axis of an ellipse that describes the size 1137 * of the approaching tool for the given pointer index. 1138 * The tool area represents the estimated size of the finger or pen that is 1139 * touching the device independent of its actual touch area at the point of contact. 1140 */ 1141 float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index); 1142 1143 /** 1144 * Get the current orientation of the touch area and tool area in radians clockwise from 1145 * vertical for the given pointer index. 1146 * An angle of 0 degrees indicates that the major axis of contact is oriented 1147 * upwards, is perfectly circular or is of unknown orientation. A positive angle 1148 * indicates that the major axis of contact is oriented to the right. A negative angle 1149 * indicates that the major axis of contact is oriented to the left. 1150 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians 1151 * (finger pointing fully right). 1152 */ 1153 float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index); 1154 1155 /** Get the value of the request axis for the given pointer index. */ 1156 float AMotionEvent_getAxisValue(const AInputEvent* motion_event, 1157 int32_t axis, size_t pointer_index); 1158 1159 /** 1160 * Get the number of historical points in this event. These are movements that 1161 * have occurred between this event and the previous event. This only applies 1162 * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0. 1163 * Historical samples are indexed from oldest to newest. 1164 */ 1165 size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event); 1166 1167 /** 1168 * Get the time that a historical movement occurred between this event and 1169 * the previous event, in the java.lang.System.nanoTime() time base. 1170 */ 1171 int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event, 1172 size_t history_index); 1173 1174 /** 1175 * Get the historical raw X coordinate of this event for the given pointer index that 1176 * occurred between this event and the previous motion event. 1177 * For touch events on the screen, this is the original location of the event 1178 * on the screen, before it had been adjusted for the containing window 1179 * and views. 1180 * Whole numbers are pixels; the value may have a fraction for input devices 1181 * that are sub-pixel precise. 1182 */ 1183 float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index, 1184 size_t history_index); 1185 1186 /** 1187 * Get the historical raw Y coordinate of this event for the given pointer index that 1188 * occurred between this event and the previous motion event. 1189 * For touch events on the screen, this is the original location of the event 1190 * on the screen, before it had been adjusted for the containing window 1191 * and views. 1192 * Whole numbers are pixels; the value may have a fraction for input devices 1193 * that are sub-pixel precise. 1194 */ 1195 float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index, 1196 size_t history_index); 1197 1198 /** 1199 * Get the historical X coordinate of this event for the given pointer index that 1200 * occurred between this event and the previous motion event. 1201 * Whole numbers are pixels; the value may have a fraction for input devices 1202 * that are sub-pixel precise. 1203 */ 1204 float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index, 1205 size_t history_index); 1206 1207 /** 1208 * Get the historical Y coordinate of this event for the given pointer index that 1209 * occurred between this event and the previous motion event. 1210 * Whole numbers are pixels; the value may have a fraction for input devices 1211 * that are sub-pixel precise. 1212 */ 1213 float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index, 1214 size_t history_index); 1215 1216 /** 1217 * Get the historical pressure of this event for the given pointer index that 1218 * occurred between this event and the previous motion event. 1219 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), 1220 * although values higher than 1 may be generated depending on the calibration of 1221 * the input device. 1222 */ 1223 float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index, 1224 size_t history_index); 1225 1226 /** 1227 * Get the current scaled value of the approximate size for the given pointer index that 1228 * occurred between this event and the previous motion event. 1229 * This represents some approximation of the area of the screen being 1230 * pressed; the actual value in pixels corresponding to the 1231 * touch is normalized with the device specific range of values 1232 * and scaled to a value between 0 and 1. The value of size can be used to 1233 * determine fat touch events. 1234 */ 1235 float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index, 1236 size_t history_index); 1237 1238 /** 1239 * Get the historical length of the major axis of an ellipse that describes the touch area 1240 * at the point of contact for the given pointer index that 1241 * occurred between this event and the previous motion event. 1242 */ 1243 float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index, 1244 size_t history_index); 1245 1246 /** 1247 * Get the historical length of the minor axis of an ellipse that describes the touch area 1248 * at the point of contact for the given pointer index that 1249 * occurred between this event and the previous motion event. 1250 */ 1251 float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index, 1252 size_t history_index); 1253 1254 /** 1255 * Get the historical length of the major axis of an ellipse that describes the size 1256 * of the approaching tool for the given pointer index that 1257 * occurred between this event and the previous motion event. 1258 * The tool area represents the estimated size of the finger or pen that is 1259 * touching the device independent of its actual touch area at the point of contact. 1260 */ 1261 float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index, 1262 size_t history_index); 1263 1264 /** 1265 * Get the historical length of the minor axis of an ellipse that describes the size 1266 * of the approaching tool for the given pointer index that 1267 * occurred between this event and the previous motion event. 1268 * The tool area represents the estimated size of the finger or pen that is 1269 * touching the device independent of its actual touch area at the point of contact. 1270 */ 1271 float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index, 1272 size_t history_index); 1273 1274 /** 1275 * Get the historical orientation of the touch area and tool area in radians clockwise from 1276 * vertical for the given pointer index that 1277 * occurred between this event and the previous motion event. 1278 * An angle of 0 degrees indicates that the major axis of contact is oriented 1279 * upwards, is perfectly circular or is of unknown orientation. A positive angle 1280 * indicates that the major axis of contact is oriented to the right. A negative angle 1281 * indicates that the major axis of contact is oriented to the left. 1282 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians 1283 * (finger pointing fully right). 1284 */ 1285 float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, 1286 size_t history_index); 1287 1288 /** 1289 * Get the historical value of the request axis for the given pointer index 1290 * that occurred between this event and the previous motion event. 1291 */ 1292 float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, 1293 int32_t axis, size_t pointer_index, size_t history_index); 1294 1295 1296 struct AInputQueue; 1297 /** 1298 * Input queue 1299 * 1300 * An input queue is the facility through which you retrieve input 1301 * events. 1302 */ 1303 typedef struct AInputQueue AInputQueue; 1304 1305 /** 1306 * Add this input queue to a looper for processing. See 1307 * ALooper_addFd() for information on the ident, callback, and data params. 1308 */ 1309 void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, 1310 int ident, ALooper_callbackFunc callback, void* data); 1311 1312 /** 1313 * Remove the input queue from the looper it is currently attached to. 1314 */ 1315 void AInputQueue_detachLooper(AInputQueue* queue); 1316 1317 /** 1318 * Returns true if there are one or more events available in the 1319 * input queue. Returns 1 if the queue has events; 0 if 1320 * it does not have events; and a negative value if there is an error. 1321 */ 1322 int32_t AInputQueue_hasEvents(AInputQueue* queue); 1323 1324 /** 1325 * Returns the next available event from the queue. Returns a negative 1326 * value if no events are available or an error has occurred. 1327 */ 1328 int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent); 1329 1330 /** 1331 * Sends the key for standard pre-dispatching -- that is, possibly deliver 1332 * it to the current IME to be consumed before the app. Returns 0 if it 1333 * was not pre-dispatched, meaning you can process it right now. If non-zero 1334 * is returned, you must abandon the current event processing and allow the 1335 * event to appear again in the event queue (if it does not get consumed during 1336 * pre-dispatching). 1337 */ 1338 int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event); 1339 1340 /** 1341 * Report that dispatching has finished with the given event. 1342 * This must be called after receiving an event with AInputQueue_get_event(). 1343 */ 1344 void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled); 1345 1346 #ifdef __cplusplus 1347 } 1348 #endif 1349 1350 #endif // _ANDROID_INPUT_H 1351 1352 /** @} */ 1353