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