michael@0: /* michael@0: * Copyright (C) 2010 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef _ANDROID_INPUT_H michael@0: #define _ANDROID_INPUT_H michael@0: michael@0: /****************************************************************** michael@0: * michael@0: * IMPORTANT NOTICE: michael@0: * michael@0: * This file is part of Android's set of stable system headers michael@0: * exposed by the Android NDK (Native Development Kit). michael@0: * michael@0: * Third-party source AND binary code relies on the definitions michael@0: * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. michael@0: * michael@0: * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) michael@0: * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS michael@0: * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY michael@0: * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES michael@0: */ michael@0: michael@0: /* michael@0: * Structures and functions to receive and process input events in michael@0: * native code. michael@0: * michael@0: * NOTE: These functions MUST be implemented by /system/lib/libui.so michael@0: */ michael@0: michael@0: #include michael@0: #include michael@0: #include "android_keycodes.h" michael@0: #include michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: /* michael@0: * Key states (may be returned by queries about the current state of a michael@0: * particular key code, scan code or switch). michael@0: */ michael@0: enum { michael@0: /* The key state is unknown or the requested key itself is not supported. */ michael@0: AKEY_STATE_UNKNOWN = -1, michael@0: michael@0: /* The key is up. */ michael@0: AKEY_STATE_UP = 0, michael@0: michael@0: /* The key is down. */ michael@0: AKEY_STATE_DOWN = 1, michael@0: michael@0: /* The key is down but is a virtual key press that is being emulated by the system. */ michael@0: AKEY_STATE_VIRTUAL = 2 michael@0: }; michael@0: michael@0: /* michael@0: * Meta key / modifer state. michael@0: */ michael@0: enum { michael@0: /* No meta keys are pressed. */ michael@0: AMETA_NONE = 0, michael@0: michael@0: /* This mask is used to check whether one of the ALT meta keys is pressed. */ michael@0: AMETA_ALT_ON = 0x02, michael@0: michael@0: /* This mask is used to check whether the left ALT meta key is pressed. */ michael@0: AMETA_ALT_LEFT_ON = 0x10, michael@0: michael@0: /* This mask is used to check whether the right ALT meta key is pressed. */ michael@0: AMETA_ALT_RIGHT_ON = 0x20, michael@0: michael@0: /* This mask is used to check whether one of the SHIFT meta keys is pressed. */ michael@0: AMETA_SHIFT_ON = 0x01, michael@0: michael@0: /* This mask is used to check whether the left SHIFT meta key is pressed. */ michael@0: AMETA_SHIFT_LEFT_ON = 0x40, michael@0: michael@0: /* This mask is used to check whether the right SHIFT meta key is pressed. */ michael@0: AMETA_SHIFT_RIGHT_ON = 0x80, michael@0: michael@0: /* This mask is used to check whether the SYM meta key is pressed. */ michael@0: AMETA_SYM_ON = 0x04, michael@0: michael@0: /* This mask is used to check whether the FUNCTION meta key is pressed. */ michael@0: AMETA_FUNCTION_ON = 0x08, michael@0: michael@0: /* This mask is used to check whether one of the CTRL meta keys is pressed. */ michael@0: AMETA_CTRL_ON = 0x1000, michael@0: michael@0: /* This mask is used to check whether the left CTRL meta key is pressed. */ michael@0: AMETA_CTRL_LEFT_ON = 0x2000, michael@0: michael@0: /* This mask is used to check whether the right CTRL meta key is pressed. */ michael@0: AMETA_CTRL_RIGHT_ON = 0x4000, michael@0: michael@0: /* This mask is used to check whether one of the META meta keys is pressed. */ michael@0: AMETA_META_ON = 0x10000, michael@0: michael@0: /* This mask is used to check whether the left META meta key is pressed. */ michael@0: AMETA_META_LEFT_ON = 0x20000, michael@0: michael@0: /* This mask is used to check whether the right META meta key is pressed. */ michael@0: AMETA_META_RIGHT_ON = 0x40000, michael@0: michael@0: /* This mask is used to check whether the CAPS LOCK meta key is on. */ michael@0: AMETA_CAPS_LOCK_ON = 0x100000, michael@0: michael@0: /* This mask is used to check whether the NUM LOCK meta key is on. */ michael@0: AMETA_NUM_LOCK_ON = 0x200000, michael@0: michael@0: /* This mask is used to check whether the SCROLL LOCK meta key is on. */ michael@0: AMETA_SCROLL_LOCK_ON = 0x400000, michael@0: }; michael@0: michael@0: /* michael@0: * Input events. michael@0: * michael@0: * Input events are opaque structures. Use the provided accessors functions to michael@0: * read their properties. michael@0: */ michael@0: struct AInputEvent; michael@0: typedef struct AInputEvent AInputEvent; michael@0: michael@0: /* michael@0: * Input event types. michael@0: */ michael@0: enum { michael@0: /* Indicates that the input event is a key event. */ michael@0: AINPUT_EVENT_TYPE_KEY = 1, michael@0: michael@0: /* Indicates that the input event is a motion event. */ michael@0: AINPUT_EVENT_TYPE_MOTION = 2 michael@0: }; michael@0: michael@0: /* michael@0: * Key event actions. michael@0: */ michael@0: enum { michael@0: /* The key has been pressed down. */ michael@0: AKEY_EVENT_ACTION_DOWN = 0, michael@0: michael@0: /* The key has been released. */ michael@0: AKEY_EVENT_ACTION_UP = 1, michael@0: michael@0: /* Multiple duplicate key events have occurred in a row, or a complex string is michael@0: * being delivered. The repeat_count property of the key event contains the number michael@0: * of times the given key code should be executed. michael@0: */ michael@0: AKEY_EVENT_ACTION_MULTIPLE = 2 michael@0: }; michael@0: michael@0: /* michael@0: * Key event flags. michael@0: */ michael@0: enum { michael@0: /* This mask is set if the device woke because of this key event. */ michael@0: AKEY_EVENT_FLAG_WOKE_HERE = 0x1, michael@0: michael@0: /* This mask is set if the key event was generated by a software keyboard. */ michael@0: AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2, michael@0: michael@0: /* This mask is set if we don't want the key event to cause us to leave touch mode. */ michael@0: AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4, michael@0: michael@0: /* This mask is set if an event was known to come from a trusted part michael@0: * of the system. That is, the event is known to come from the user, michael@0: * and could not have been spoofed by a third party component. */ michael@0: AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8, michael@0: michael@0: /* This mask is used for compatibility, to identify enter keys that are michael@0: * coming from an IME whose enter key has been auto-labelled "next" or michael@0: * "done". This allows TextView to dispatch these as normal enter keys michael@0: * for old applications, but still do the appropriate action when michael@0: * receiving them. */ michael@0: AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10, michael@0: michael@0: /* When associated with up key events, this indicates that the key press michael@0: * has been canceled. Typically this is used with virtual touch screen michael@0: * keys, where the user can slide from the virtual key area on to the michael@0: * display: in that case, the application will receive a canceled up michael@0: * event and should not perform the action normally associated with the michael@0: * key. Note that for this to work, the application can not perform an michael@0: * action for a key until it receives an up or the long press timeout has michael@0: * expired. */ michael@0: AKEY_EVENT_FLAG_CANCELED = 0x20, michael@0: michael@0: /* This key event was generated by a virtual (on-screen) hard key area. michael@0: * Typically this is an area of the touchscreen, outside of the regular michael@0: * display, dedicated to "hardware" buttons. */ michael@0: AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40, michael@0: michael@0: /* This flag is set for the first key repeat that occurs after the michael@0: * long press timeout. */ michael@0: AKEY_EVENT_FLAG_LONG_PRESS = 0x80, michael@0: michael@0: /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long michael@0: * press action was executed while it was down. */ michael@0: AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100, michael@0: michael@0: /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being michael@0: * tracked from its initial down. That is, somebody requested that tracking michael@0: * started on the key down and a long press has not caused michael@0: * the tracking to be canceled. */ michael@0: AKEY_EVENT_FLAG_TRACKING = 0x200, michael@0: michael@0: /* Set when a key event has been synthesized to implement default behavior michael@0: * for an event that the application did not handle. michael@0: * Fallback key events are generated by unhandled trackball motions michael@0: * (to emulate a directional keypad) and by certain unhandled key presses michael@0: * that are declared in the key map (such as special function numeric keypad michael@0: * keys when numlock is off). */ michael@0: AKEY_EVENT_FLAG_FALLBACK = 0x400, michael@0: }; michael@0: michael@0: /* michael@0: * Motion event actions. michael@0: */ michael@0: michael@0: /* Bit shift for the action bits holding the pointer index as michael@0: * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK. michael@0: */ michael@0: #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 michael@0: michael@0: enum { michael@0: /* Bit mask of the parts of the action code that are the action itself. michael@0: */ michael@0: AMOTION_EVENT_ACTION_MASK = 0xff, michael@0: michael@0: /* Bits in the action code that represent a pointer index, used with michael@0: * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting michael@0: * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer michael@0: * index where the data for the pointer going up or down can be found. michael@0: */ michael@0: AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00, michael@0: michael@0: /* A pressed gesture has started, the motion contains the initial starting location. michael@0: */ michael@0: AMOTION_EVENT_ACTION_DOWN = 0, michael@0: michael@0: /* A pressed gesture has finished, the motion contains the final release location michael@0: * as well as any intermediate points since the last down or move event. michael@0: */ michael@0: AMOTION_EVENT_ACTION_UP = 1, michael@0: michael@0: /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and michael@0: * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as michael@0: * any intermediate points since the last down or move event. michael@0: */ michael@0: AMOTION_EVENT_ACTION_MOVE = 2, michael@0: michael@0: /* The current gesture has been aborted. michael@0: * You will not receive any more points in it. You should treat this as michael@0: * an up event, but not perform any action that you normally would. michael@0: */ michael@0: AMOTION_EVENT_ACTION_CANCEL = 3, michael@0: michael@0: /* A movement has happened outside of the normal bounds of the UI element. michael@0: * This does not provide a full gesture, but only the initial location of the movement/touch. michael@0: */ michael@0: AMOTION_EVENT_ACTION_OUTSIDE = 4, michael@0: michael@0: /* A non-primary pointer has gone down. michael@0: * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. michael@0: */ michael@0: AMOTION_EVENT_ACTION_POINTER_DOWN = 5, michael@0: michael@0: /* A non-primary pointer has gone up. michael@0: * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. michael@0: */ michael@0: AMOTION_EVENT_ACTION_POINTER_UP = 6, michael@0: michael@0: /* A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE). michael@0: * The motion contains the most recent point, as well as any intermediate points since michael@0: * the last hover move event. michael@0: */ michael@0: AMOTION_EVENT_ACTION_HOVER_MOVE = 7, michael@0: michael@0: /* The motion event contains relative vertical and/or horizontal scroll offsets. michael@0: * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL michael@0: * and AMOTION_EVENT_AXIS_HSCROLL. michael@0: * The pointer may or may not be down when this event is dispatched. michael@0: * This action is always delivered to the winder under the pointer, which michael@0: * may not be the window currently touched. michael@0: */ michael@0: AMOTION_EVENT_ACTION_SCROLL = 8, michael@0: michael@0: /* The pointer is not down but has entered the boundaries of a window or view. michael@0: */ michael@0: AMOTION_EVENT_ACTION_HOVER_ENTER = 9, michael@0: michael@0: /* The pointer is not down but has exited the boundaries of a window or view. michael@0: */ michael@0: AMOTION_EVENT_ACTION_HOVER_EXIT = 10, michael@0: }; michael@0: michael@0: /* michael@0: * Motion event flags. michael@0: */ michael@0: enum { michael@0: /* This flag indicates that the window that received this motion event is partly michael@0: * or wholly obscured by another visible window above it. This flag is set to true michael@0: * even if the event did not directly pass through the obscured area. michael@0: * A security sensitive application can check this flag to identify situations in which michael@0: * a malicious application may have covered up part of its content for the purpose michael@0: * of misleading the user or hijacking touches. An appropriate response might be michael@0: * to drop the suspect touches or to take additional precautions to confirm the user's michael@0: * actual intent. michael@0: */ michael@0: AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1, michael@0: }; michael@0: michael@0: /* michael@0: * Motion event edge touch flags. michael@0: */ michael@0: enum { michael@0: /* No edges intersected */ michael@0: AMOTION_EVENT_EDGE_FLAG_NONE = 0, michael@0: michael@0: /* Flag indicating the motion event intersected the top edge of the screen. */ michael@0: AMOTION_EVENT_EDGE_FLAG_TOP = 0x01, michael@0: michael@0: /* Flag indicating the motion event intersected the bottom edge of the screen. */ michael@0: AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02, michael@0: michael@0: /* Flag indicating the motion event intersected the left edge of the screen. */ michael@0: AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04, michael@0: michael@0: /* Flag indicating the motion event intersected the right edge of the screen. */ michael@0: AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08 michael@0: }; michael@0: michael@0: /* michael@0: * Constants that identify each individual axis of a motion event. michael@0: * Refer to the documentation on the MotionEvent class for descriptions of each axis. michael@0: */ michael@0: enum { michael@0: AMOTION_EVENT_AXIS_X = 0, michael@0: AMOTION_EVENT_AXIS_Y = 1, michael@0: AMOTION_EVENT_AXIS_PRESSURE = 2, michael@0: AMOTION_EVENT_AXIS_SIZE = 3, michael@0: AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4, michael@0: AMOTION_EVENT_AXIS_TOUCH_MINOR = 5, michael@0: AMOTION_EVENT_AXIS_TOOL_MAJOR = 6, michael@0: AMOTION_EVENT_AXIS_TOOL_MINOR = 7, michael@0: AMOTION_EVENT_AXIS_ORIENTATION = 8, michael@0: AMOTION_EVENT_AXIS_VSCROLL = 9, michael@0: AMOTION_EVENT_AXIS_HSCROLL = 10, michael@0: AMOTION_EVENT_AXIS_Z = 11, michael@0: AMOTION_EVENT_AXIS_RX = 12, michael@0: AMOTION_EVENT_AXIS_RY = 13, michael@0: AMOTION_EVENT_AXIS_RZ = 14, michael@0: AMOTION_EVENT_AXIS_HAT_X = 15, michael@0: AMOTION_EVENT_AXIS_HAT_Y = 16, michael@0: AMOTION_EVENT_AXIS_LTRIGGER = 17, michael@0: AMOTION_EVENT_AXIS_RTRIGGER = 18, michael@0: AMOTION_EVENT_AXIS_THROTTLE = 19, michael@0: AMOTION_EVENT_AXIS_RUDDER = 20, michael@0: AMOTION_EVENT_AXIS_WHEEL = 21, michael@0: AMOTION_EVENT_AXIS_GAS = 22, michael@0: AMOTION_EVENT_AXIS_BRAKE = 23, michael@0: AMOTION_EVENT_AXIS_DISTANCE = 24, michael@0: AMOTION_EVENT_AXIS_TILT = 25, michael@0: AMOTION_EVENT_AXIS_GENERIC_1 = 32, michael@0: AMOTION_EVENT_AXIS_GENERIC_2 = 33, michael@0: AMOTION_EVENT_AXIS_GENERIC_3 = 34, michael@0: AMOTION_EVENT_AXIS_GENERIC_4 = 35, michael@0: AMOTION_EVENT_AXIS_GENERIC_5 = 36, michael@0: AMOTION_EVENT_AXIS_GENERIC_6 = 37, michael@0: AMOTION_EVENT_AXIS_GENERIC_7 = 38, michael@0: AMOTION_EVENT_AXIS_GENERIC_8 = 39, michael@0: AMOTION_EVENT_AXIS_GENERIC_9 = 40, michael@0: AMOTION_EVENT_AXIS_GENERIC_10 = 41, michael@0: AMOTION_EVENT_AXIS_GENERIC_11 = 42, michael@0: AMOTION_EVENT_AXIS_GENERIC_12 = 43, michael@0: AMOTION_EVENT_AXIS_GENERIC_13 = 44, michael@0: AMOTION_EVENT_AXIS_GENERIC_14 = 45, michael@0: AMOTION_EVENT_AXIS_GENERIC_15 = 46, michael@0: AMOTION_EVENT_AXIS_GENERIC_16 = 47, michael@0: michael@0: // NOTE: If you add a new axis here you must also add it to several other files. michael@0: // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list. michael@0: }; michael@0: michael@0: /* michael@0: * Constants that identify buttons that are associated with motion events. michael@0: * Refer to the documentation on the MotionEvent class for descriptions of each button. michael@0: */ michael@0: enum { michael@0: AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0, michael@0: AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1, michael@0: AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2, michael@0: AMOTION_EVENT_BUTTON_BACK = 1 << 3, michael@0: AMOTION_EVENT_BUTTON_FORWARD = 1 << 4, michael@0: }; michael@0: michael@0: /* michael@0: * Constants that identify tool types. michael@0: * Refer to the documentation on the MotionEvent class for descriptions of each tool type. michael@0: */ michael@0: enum { michael@0: AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0, michael@0: AMOTION_EVENT_TOOL_TYPE_FINGER = 1, michael@0: AMOTION_EVENT_TOOL_TYPE_STYLUS = 2, michael@0: AMOTION_EVENT_TOOL_TYPE_MOUSE = 3, michael@0: AMOTION_EVENT_TOOL_TYPE_ERASER = 4, michael@0: }; michael@0: michael@0: /* michael@0: * Input sources. michael@0: * michael@0: * Refer to the documentation on android.view.InputDevice for more details about input sources michael@0: * and their correct interpretation. michael@0: */ michael@0: enum { michael@0: AINPUT_SOURCE_CLASS_MASK = 0x000000ff, michael@0: michael@0: AINPUT_SOURCE_CLASS_NONE = 0x00000000, michael@0: AINPUT_SOURCE_CLASS_BUTTON = 0x00000001, michael@0: AINPUT_SOURCE_CLASS_POINTER = 0x00000002, michael@0: AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004, michael@0: AINPUT_SOURCE_CLASS_POSITION = 0x00000008, michael@0: AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010, michael@0: }; michael@0: michael@0: enum { michael@0: AINPUT_SOURCE_UNKNOWN = 0x00000000, michael@0: michael@0: AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON, michael@0: AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON, michael@0: AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON, michael@0: AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER, michael@0: AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER, michael@0: AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER, michael@0: AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION, michael@0: AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION, michael@0: AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE, michael@0: AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK, michael@0: michael@0: AINPUT_SOURCE_ANY = 0xffffff00, michael@0: }; michael@0: michael@0: /* michael@0: * Keyboard types. michael@0: * michael@0: * Refer to the documentation on android.view.InputDevice for more details. michael@0: */ michael@0: enum { michael@0: AINPUT_KEYBOARD_TYPE_NONE = 0, michael@0: AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1, michael@0: AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2, michael@0: }; michael@0: michael@0: /* michael@0: * Constants used to retrieve information about the range of motion for a particular michael@0: * coordinate of a motion event. michael@0: * michael@0: * Refer to the documentation on android.view.InputDevice for more details about input sources michael@0: * and their correct interpretation. michael@0: * michael@0: * DEPRECATION NOTICE: These constants are deprecated. Use AMOTION_EVENT_AXIS_* constants instead. michael@0: */ michael@0: enum { michael@0: AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X, michael@0: AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y, michael@0: AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE, michael@0: AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE, michael@0: AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR, michael@0: AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR, michael@0: AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR, michael@0: AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR, michael@0: AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION, michael@0: } __attribute__ ((deprecated)); michael@0: michael@0: michael@0: /* michael@0: * Input event accessors. michael@0: * michael@0: * Note that most functions can only be used on input events that are of a given type. michael@0: * Calling these functions on input events of other types will yield undefined behavior. michael@0: */ michael@0: michael@0: /*** Accessors for all input events. ***/ michael@0: michael@0: /* Get the input event type. */ michael@0: int32_t AInputEvent_getType(const AInputEvent* event); michael@0: michael@0: /* Get the id for the device that an input event came from. michael@0: * michael@0: * Input events can be generated by multiple different input devices. michael@0: * Use the input device id to obtain information about the input michael@0: * device that was responsible for generating a particular event. michael@0: * michael@0: * An input device id of 0 indicates that the event didn't come from a physical device; michael@0: * other numbers are arbitrary and you shouldn't depend on the values. michael@0: * Use the provided input device query API to obtain information about input devices. michael@0: */ michael@0: int32_t AInputEvent_getDeviceId(const AInputEvent* event); michael@0: michael@0: /* Get the input event source. */ michael@0: int32_t AInputEvent_getSource(const AInputEvent* event); michael@0: michael@0: /*** Accessors for key events only. ***/ michael@0: michael@0: /* Get the key event action. */ michael@0: int32_t AKeyEvent_getAction(const AInputEvent* key_event); michael@0: michael@0: /* Get the key event flags. */ michael@0: int32_t AKeyEvent_getFlags(const AInputEvent* key_event); michael@0: michael@0: /* Get the key code of the key event. michael@0: * This is the physical key that was pressed, not the Unicode character. */ michael@0: int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event); michael@0: michael@0: /* Get the hardware key id of this key event. michael@0: * These values are not reliable and vary from device to device. */ michael@0: int32_t AKeyEvent_getScanCode(const AInputEvent* key_event); michael@0: michael@0: /* Get the meta key state. */ michael@0: int32_t AKeyEvent_getMetaState(const AInputEvent* key_event); michael@0: michael@0: /* Get the repeat count of the event. michael@0: * For both key up an key down events, this is the number of times the key has michael@0: * repeated with the first down starting at 0 and counting up from there. For michael@0: * multiple key events, this is the number of down/up pairs that have occurred. */ michael@0: int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event); michael@0: michael@0: /* Get the time of the most recent key down event, in the michael@0: * java.lang.System.nanoTime() time base. If this is a down event, michael@0: * this will be the same as eventTime. michael@0: * Note that when chording keys, this value is the down time of the most recently michael@0: * pressed key, which may not be the same physical key of this event. */ michael@0: int64_t AKeyEvent_getDownTime(const AInputEvent* key_event); michael@0: michael@0: /* Get the time this event occurred, in the michael@0: * java.lang.System.nanoTime() time base. */ michael@0: int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); michael@0: michael@0: /*** Accessors for motion events only. ***/ michael@0: michael@0: /* Get the combined motion event action code and pointer index. */ michael@0: int32_t AMotionEvent_getAction(const AInputEvent* motion_event); michael@0: michael@0: /* Get the motion event flags. */ michael@0: int32_t AMotionEvent_getFlags(const AInputEvent* motion_event); michael@0: michael@0: /* Get the state of any meta / modifier keys that were in effect when the michael@0: * event was generated. */ michael@0: int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event); michael@0: michael@0: /* Get the button state of all buttons that are pressed. */ michael@0: int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event); michael@0: michael@0: /* Get a bitfield indicating which edges, if any, were touched by this motion event. michael@0: * For touch events, clients can use this to determine if the user's finger was michael@0: * touching the edge of the display. */ michael@0: int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event); michael@0: michael@0: /* Get the time when the user originally pressed down to start a stream of michael@0: * position events, in the java.lang.System.nanoTime() time base. */ michael@0: int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event); michael@0: michael@0: /* Get the time when this specific event was generated, michael@0: * in the java.lang.System.nanoTime() time base. */ michael@0: int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event); michael@0: michael@0: /* Get the X coordinate offset. michael@0: * For touch events on the screen, this is the delta that was added to the raw michael@0: * screen coordinates to adjust for the absolute position of the containing windows michael@0: * and views. */ michael@0: float AMotionEvent_getXOffset(const AInputEvent* motion_event); michael@0: michael@0: /* Get the precision of the Y coordinates being reported. michael@0: * For touch events on the screen, this is the delta that was added to the raw michael@0: * screen coordinates to adjust for the absolute position of the containing windows michael@0: * and views. */ michael@0: float AMotionEvent_getYOffset(const AInputEvent* motion_event); michael@0: michael@0: /* Get the precision of the X coordinates being reported. michael@0: * You can multiply this number with an X coordinate sample to find the michael@0: * actual hardware value of the X coordinate. */ michael@0: float AMotionEvent_getXPrecision(const AInputEvent* motion_event); michael@0: michael@0: /* Get the precision of the Y coordinates being reported. michael@0: * You can multiply this number with a Y coordinate sample to find the michael@0: * actual hardware value of the Y coordinate. */ michael@0: float AMotionEvent_getYPrecision(const AInputEvent* motion_event); michael@0: michael@0: /* Get the number of pointers of data contained in this event. michael@0: * Always >= 1. */ michael@0: size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event); michael@0: michael@0: /* Get the pointer identifier associated with a particular pointer michael@0: * data index in this event. The identifier tells you the actual pointer michael@0: * number associated with the data, accounting for individual pointers michael@0: * going up and down since the start of the current gesture. */ michael@0: int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the tool type of a pointer for the given pointer index. michael@0: * The tool type indicates the type of tool used to make contact such as a michael@0: * finger or stylus, if known. */ michael@0: int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the original raw X coordinate of this event. michael@0: * For touch events on the screen, this is the original location of the event michael@0: * on the screen, before it had been adjusted for the containing window michael@0: * and views. */ michael@0: float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the original raw X coordinate of this event. michael@0: * For touch events on the screen, this is the original location of the event michael@0: * on the screen, before it had been adjusted for the containing window michael@0: * and views. */ michael@0: float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the current X coordinate of this event for the given pointer index. michael@0: * Whole numbers are pixels; the value may have a fraction for input devices michael@0: * that are sub-pixel precise. */ michael@0: float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the current Y coordinate of this event for the given pointer index. michael@0: * Whole numbers are pixels; the value may have a fraction for input devices michael@0: * that are sub-pixel precise. */ michael@0: float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the current pressure of this event for the given pointer index. michael@0: * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), michael@0: * although values higher than 1 may be generated depending on the calibration of michael@0: * the input device. */ michael@0: float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the current scaled value of the approximate size for the given pointer index. michael@0: * This represents some approximation of the area of the screen being michael@0: * pressed; the actual value in pixels corresponding to the michael@0: * touch is normalized with the device specific range of values michael@0: * and scaled to a value between 0 and 1. The value of size can be used to michael@0: * determine fat touch events. */ michael@0: float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the current length of the major axis of an ellipse that describes the touch area michael@0: * at the point of contact for the given pointer index. */ michael@0: float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the current length of the minor axis of an ellipse that describes the touch area michael@0: * at the point of contact for the given pointer index. */ michael@0: float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the current length of the major axis of an ellipse that describes the size michael@0: * of the approaching tool for the given pointer index. michael@0: * The tool area represents the estimated size of the finger or pen that is michael@0: * touching the device independent of its actual touch area at the point of contact. */ michael@0: float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the current length of the minor axis of an ellipse that describes the size michael@0: * of the approaching tool for the given pointer index. michael@0: * The tool area represents the estimated size of the finger or pen that is michael@0: * touching the device independent of its actual touch area at the point of contact. */ michael@0: float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the current orientation of the touch area and tool area in radians clockwise from michael@0: * vertical for the given pointer index. michael@0: * An angle of 0 degrees indicates that the major axis of contact is oriented michael@0: * upwards, is perfectly circular or is of unknown orientation. A positive angle michael@0: * indicates that the major axis of contact is oriented to the right. A negative angle michael@0: * indicates that the major axis of contact is oriented to the left. michael@0: * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians michael@0: * (finger pointing fully right). */ michael@0: float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index); michael@0: michael@0: /* Get the value of the request axis for the given pointer index. */ michael@0: float AMotionEvent_getAxisValue(const AInputEvent* motion_event, michael@0: int32_t axis, size_t pointer_index); michael@0: michael@0: /* Get the number of historical points in this event. These are movements that michael@0: * have occurred between this event and the previous event. This only applies michael@0: * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0. michael@0: * Historical samples are indexed from oldest to newest. */ michael@0: size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event); michael@0: michael@0: /* Get the time that a historical movement occurred between this event and michael@0: * the previous event, in the java.lang.System.nanoTime() time base. */ michael@0: int64_t AMotionEvent_getHistoricalEventTime(AInputEvent* motion_event, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical raw X coordinate of this event for the given pointer index that michael@0: * occurred between this event and the previous motion event. michael@0: * For touch events on the screen, this is the original location of the event michael@0: * on the screen, before it had been adjusted for the containing window michael@0: * and views. michael@0: * Whole numbers are pixels; the value may have a fraction for input devices michael@0: * that are sub-pixel precise. */ michael@0: float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical raw Y coordinate of this event for the given pointer index that michael@0: * occurred between this event and the previous motion event. michael@0: * For touch events on the screen, this is the original location of the event michael@0: * on the screen, before it had been adjusted for the containing window michael@0: * and views. michael@0: * Whole numbers are pixels; the value may have a fraction for input devices michael@0: * that are sub-pixel precise. */ michael@0: float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical X coordinate of this event for the given pointer index that michael@0: * occurred between this event and the previous motion event. michael@0: * Whole numbers are pixels; the value may have a fraction for input devices michael@0: * that are sub-pixel precise. */ michael@0: float AMotionEvent_getHistoricalX(AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical Y coordinate of this event for the given pointer index that michael@0: * occurred between this event and the previous motion event. michael@0: * Whole numbers are pixels; the value may have a fraction for input devices michael@0: * that are sub-pixel precise. */ michael@0: float AMotionEvent_getHistoricalY(AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical pressure of this event for the given pointer index that michael@0: * occurred between this event and the previous motion event. michael@0: * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), michael@0: * although values higher than 1 may be generated depending on the calibration of michael@0: * the input device. */ michael@0: float AMotionEvent_getHistoricalPressure(AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the current scaled value of the approximate size for the given pointer index that michael@0: * occurred between this event and the previous motion event. michael@0: * This represents some approximation of the area of the screen being michael@0: * pressed; the actual value in pixels corresponding to the michael@0: * touch is normalized with the device specific range of values michael@0: * and scaled to a value between 0 and 1. The value of size can be used to michael@0: * determine fat touch events. */ michael@0: float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical length of the major axis of an ellipse that describes the touch area michael@0: * at the point of contact for the given pointer index that michael@0: * occurred between this event and the previous motion event. */ michael@0: float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical length of the minor axis of an ellipse that describes the touch area michael@0: * at the point of contact for the given pointer index that michael@0: * occurred between this event and the previous motion event. */ michael@0: float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical length of the major axis of an ellipse that describes the size michael@0: * of the approaching tool for the given pointer index that michael@0: * occurred between this event and the previous motion event. michael@0: * The tool area represents the estimated size of the finger or pen that is michael@0: * touching the device independent of its actual touch area at the point of contact. */ michael@0: float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical length of the minor axis of an ellipse that describes the size michael@0: * of the approaching tool for the given pointer index that michael@0: * occurred between this event and the previous motion event. michael@0: * The tool area represents the estimated size of the finger or pen that is michael@0: * touching the device independent of its actual touch area at the point of contact. */ michael@0: float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical orientation of the touch area and tool area in radians clockwise from michael@0: * vertical for the given pointer index that michael@0: * occurred between this event and the previous motion event. michael@0: * An angle of 0 degrees indicates that the major axis of contact is oriented michael@0: * upwards, is perfectly circular or is of unknown orientation. A positive angle michael@0: * indicates that the major axis of contact is oriented to the right. A negative angle michael@0: * indicates that the major axis of contact is oriented to the left. michael@0: * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians michael@0: * (finger pointing fully right). */ michael@0: float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, michael@0: size_t history_index); michael@0: michael@0: /* Get the historical value of the request axis for the given pointer index michael@0: * that occurred between this event and the previous motion event. */ michael@0: float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, michael@0: int32_t axis, size_t pointer_index, size_t history_index); michael@0: michael@0: michael@0: /* michael@0: * Input queue michael@0: * michael@0: * An input queue is the facility through which you retrieve input michael@0: * events. michael@0: */ michael@0: struct AInputQueue; michael@0: typedef struct AInputQueue AInputQueue; michael@0: michael@0: /* michael@0: * Add this input queue to a looper for processing. See michael@0: * ALooper_addFd() for information on the ident, callback, and data params. michael@0: */ michael@0: void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, michael@0: int ident, ALooper_callbackFunc callback, void* data); michael@0: michael@0: /* michael@0: * Remove the input queue from the looper it is currently attached to. michael@0: */ michael@0: void AInputQueue_detachLooper(AInputQueue* queue); michael@0: michael@0: /* michael@0: * Returns true if there are one or more events available in the michael@0: * input queue. Returns 1 if the queue has events; 0 if michael@0: * it does not have events; and a negative value if there is an error. michael@0: */ michael@0: int32_t AInputQueue_hasEvents(AInputQueue* queue); michael@0: michael@0: /* michael@0: * Returns the next available event from the queue. Returns a negative michael@0: * value if no events are available or an error has occurred. michael@0: */ michael@0: int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent); michael@0: michael@0: /* michael@0: * Sends the key for standard pre-dispatching -- that is, possibly deliver michael@0: * it to the current IME to be consumed before the app. Returns 0 if it michael@0: * was not pre-dispatched, meaning you can process it right now. If non-zero michael@0: * is returned, you must abandon the current event processing and allow the michael@0: * event to appear again in the event queue (if it does not get consumed during michael@0: * pre-dispatching). michael@0: */ michael@0: int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event); michael@0: michael@0: /* michael@0: * Report that dispatching has finished with the given event. michael@0: * This must be called after receiving an event with AInputQueue_get_event(). michael@0: */ michael@0: void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled); michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: #endif // _ANDROID_INPUT_H