widget/gonk/libui/android_input.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/libui/android_input.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,850 @@
     1.4 +/*
     1.5 + * Copyright (C) 2010 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef _ANDROID_INPUT_H
    1.21 +#define _ANDROID_INPUT_H
    1.22 +
    1.23 +/******************************************************************
    1.24 + *
    1.25 + * IMPORTANT NOTICE:
    1.26 + *
    1.27 + *   This file is part of Android's set of stable system headers
    1.28 + *   exposed by the Android NDK (Native Development Kit).
    1.29 + *
    1.30 + *   Third-party source AND binary code relies on the definitions
    1.31 + *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
    1.32 + *
    1.33 + *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
    1.34 + *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
    1.35 + *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
    1.36 + *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
    1.37 + */
    1.38 +
    1.39 +/*
    1.40 + * Structures and functions to receive and process input events in
    1.41 + * native code.
    1.42 + *
    1.43 + * NOTE: These functions MUST be implemented by /system/lib/libui.so
    1.44 + */
    1.45 +
    1.46 +#include <stdint.h>
    1.47 +#include <sys/types.h>
    1.48 +#include "android_keycodes.h"
    1.49 +#include <android/looper.h>
    1.50 +
    1.51 +#ifdef __cplusplus
    1.52 +extern "C" {
    1.53 +#endif
    1.54 +
    1.55 +/*
    1.56 + * Key states (may be returned by queries about the current state of a
    1.57 + * particular key code, scan code or switch).
    1.58 + */
    1.59 +enum {
    1.60 +    /* The key state is unknown or the requested key itself is not supported. */
    1.61 +    AKEY_STATE_UNKNOWN = -1,
    1.62 +
    1.63 +    /* The key is up. */
    1.64 +    AKEY_STATE_UP = 0,
    1.65 +
    1.66 +    /* The key is down. */
    1.67 +    AKEY_STATE_DOWN = 1,
    1.68 +
    1.69 +    /* The key is down but is a virtual key press that is being emulated by the system. */
    1.70 +    AKEY_STATE_VIRTUAL = 2
    1.71 +};
    1.72 +
    1.73 +/*
    1.74 + * Meta key / modifer state.
    1.75 + */
    1.76 +enum {
    1.77 +    /* No meta keys are pressed. */
    1.78 +    AMETA_NONE = 0,
    1.79 +
    1.80 +    /* This mask is used to check whether one of the ALT meta keys is pressed. */
    1.81 +    AMETA_ALT_ON = 0x02,
    1.82 +
    1.83 +    /* This mask is used to check whether the left ALT meta key is pressed. */
    1.84 +    AMETA_ALT_LEFT_ON = 0x10,
    1.85 +
    1.86 +    /* This mask is used to check whether the right ALT meta key is pressed. */
    1.87 +    AMETA_ALT_RIGHT_ON = 0x20,
    1.88 +
    1.89 +    /* This mask is used to check whether one of the SHIFT meta keys is pressed. */
    1.90 +    AMETA_SHIFT_ON = 0x01,
    1.91 +
    1.92 +    /* This mask is used to check whether the left SHIFT meta key is pressed. */
    1.93 +    AMETA_SHIFT_LEFT_ON = 0x40,
    1.94 +
    1.95 +    /* This mask is used to check whether the right SHIFT meta key is pressed. */
    1.96 +    AMETA_SHIFT_RIGHT_ON = 0x80,
    1.97 +
    1.98 +    /* This mask is used to check whether the SYM meta key is pressed. */
    1.99 +    AMETA_SYM_ON = 0x04,
   1.100 +
   1.101 +    /* This mask is used to check whether the FUNCTION meta key is pressed. */
   1.102 +    AMETA_FUNCTION_ON = 0x08,
   1.103 +
   1.104 +    /* This mask is used to check whether one of the CTRL meta keys is pressed. */
   1.105 +    AMETA_CTRL_ON = 0x1000,
   1.106 +
   1.107 +    /* This mask is used to check whether the left CTRL meta key is pressed. */
   1.108 +    AMETA_CTRL_LEFT_ON = 0x2000,
   1.109 +
   1.110 +    /* This mask is used to check whether the right CTRL meta key is pressed. */
   1.111 +    AMETA_CTRL_RIGHT_ON = 0x4000,
   1.112 +
   1.113 +    /* This mask is used to check whether one of the META meta keys is pressed. */
   1.114 +    AMETA_META_ON = 0x10000,
   1.115 +
   1.116 +    /* This mask is used to check whether the left META meta key is pressed. */
   1.117 +    AMETA_META_LEFT_ON = 0x20000,
   1.118 +
   1.119 +    /* This mask is used to check whether the right META meta key is pressed. */
   1.120 +    AMETA_META_RIGHT_ON = 0x40000,
   1.121 +
   1.122 +    /* This mask is used to check whether the CAPS LOCK meta key is on. */
   1.123 +    AMETA_CAPS_LOCK_ON = 0x100000,
   1.124 +
   1.125 +    /* This mask is used to check whether the NUM LOCK meta key is on. */
   1.126 +    AMETA_NUM_LOCK_ON = 0x200000,
   1.127 +
   1.128 +    /* This mask is used to check whether the SCROLL LOCK meta key is on. */
   1.129 +    AMETA_SCROLL_LOCK_ON = 0x400000,
   1.130 +};
   1.131 +
   1.132 +/*
   1.133 + * Input events.
   1.134 + *
   1.135 + * Input events are opaque structures.  Use the provided accessors functions to
   1.136 + * read their properties.
   1.137 + */
   1.138 +struct AInputEvent;
   1.139 +typedef struct AInputEvent AInputEvent;
   1.140 +
   1.141 +/*
   1.142 + * Input event types.
   1.143 + */
   1.144 +enum {
   1.145 +    /* Indicates that the input event is a key event. */
   1.146 +    AINPUT_EVENT_TYPE_KEY = 1,
   1.147 +
   1.148 +    /* Indicates that the input event is a motion event. */
   1.149 +    AINPUT_EVENT_TYPE_MOTION = 2
   1.150 +};
   1.151 +
   1.152 +/*
   1.153 + * Key event actions.
   1.154 + */
   1.155 +enum {
   1.156 +    /* The key has been pressed down. */
   1.157 +    AKEY_EVENT_ACTION_DOWN = 0,
   1.158 +
   1.159 +    /* The key has been released. */
   1.160 +    AKEY_EVENT_ACTION_UP = 1,
   1.161 +
   1.162 +    /* Multiple duplicate key events have occurred in a row, or a complex string is
   1.163 +     * being delivered.  The repeat_count property of the key event contains the number
   1.164 +     * of times the given key code should be executed.
   1.165 +     */
   1.166 +    AKEY_EVENT_ACTION_MULTIPLE = 2
   1.167 +};
   1.168 +
   1.169 +/*
   1.170 + * Key event flags.
   1.171 + */
   1.172 +enum {
   1.173 +    /* This mask is set if the device woke because of this key event. */
   1.174 +    AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
   1.175 +
   1.176 +    /* This mask is set if the key event was generated by a software keyboard. */
   1.177 +    AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
   1.178 +
   1.179 +    /* This mask is set if we don't want the key event to cause us to leave touch mode. */
   1.180 +    AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
   1.181 +
   1.182 +    /* This mask is set if an event was known to come from a trusted part
   1.183 +     * of the system.  That is, the event is known to come from the user,
   1.184 +     * and could not have been spoofed by a third party component. */
   1.185 +    AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
   1.186 +
   1.187 +    /* This mask is used for compatibility, to identify enter keys that are
   1.188 +     * coming from an IME whose enter key has been auto-labelled "next" or
   1.189 +     * "done".  This allows TextView to dispatch these as normal enter keys
   1.190 +     * for old applications, but still do the appropriate action when
   1.191 +     * receiving them. */
   1.192 +    AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
   1.193 +
   1.194 +    /* When associated with up key events, this indicates that the key press
   1.195 +     * has been canceled.  Typically this is used with virtual touch screen
   1.196 +     * keys, where the user can slide from the virtual key area on to the
   1.197 +     * display: in that case, the application will receive a canceled up
   1.198 +     * event and should not perform the action normally associated with the
   1.199 +     * key.  Note that for this to work, the application can not perform an
   1.200 +     * action for a key until it receives an up or the long press timeout has
   1.201 +     * expired. */
   1.202 +    AKEY_EVENT_FLAG_CANCELED = 0x20,
   1.203 +
   1.204 +    /* This key event was generated by a virtual (on-screen) hard key area.
   1.205 +     * Typically this is an area of the touchscreen, outside of the regular
   1.206 +     * display, dedicated to "hardware" buttons. */
   1.207 +    AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
   1.208 +
   1.209 +    /* This flag is set for the first key repeat that occurs after the
   1.210 +     * long press timeout. */
   1.211 +    AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
   1.212 +
   1.213 +    /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
   1.214 +     * press action was executed while it was down. */
   1.215 +    AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
   1.216 +
   1.217 +    /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
   1.218 +     * tracked from its initial down.  That is, somebody requested that tracking
   1.219 +     * started on the key down and a long press has not caused
   1.220 +     * the tracking to be canceled. */
   1.221 +    AKEY_EVENT_FLAG_TRACKING = 0x200,
   1.222 +
   1.223 +    /* Set when a key event has been synthesized to implement default behavior
   1.224 +     * for an event that the application did not handle.
   1.225 +     * Fallback key events are generated by unhandled trackball motions
   1.226 +     * (to emulate a directional keypad) and by certain unhandled key presses
   1.227 +     * that are declared in the key map (such as special function numeric keypad
   1.228 +     * keys when numlock is off). */
   1.229 +    AKEY_EVENT_FLAG_FALLBACK = 0x400,
   1.230 +};
   1.231 +
   1.232 +/*
   1.233 + * Motion event actions.
   1.234 + */
   1.235 +
   1.236 +/* Bit shift for the action bits holding the pointer index as
   1.237 + * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
   1.238 + */
   1.239 +#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
   1.240 +
   1.241 +enum {
   1.242 +    /* Bit mask of the parts of the action code that are the action itself.
   1.243 +     */
   1.244 +    AMOTION_EVENT_ACTION_MASK = 0xff,
   1.245 +
   1.246 +    /* Bits in the action code that represent a pointer index, used with
   1.247 +     * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP.  Shifting
   1.248 +     * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
   1.249 +     * index where the data for the pointer going up or down can be found.
   1.250 +     */
   1.251 +    AMOTION_EVENT_ACTION_POINTER_INDEX_MASK  = 0xff00,
   1.252 +
   1.253 +    /* A pressed gesture has started, the motion contains the initial starting location.
   1.254 +     */
   1.255 +    AMOTION_EVENT_ACTION_DOWN = 0,
   1.256 +
   1.257 +    /* A pressed gesture has finished, the motion contains the final release location
   1.258 +     * as well as any intermediate points since the last down or move event.
   1.259 +     */
   1.260 +    AMOTION_EVENT_ACTION_UP = 1,
   1.261 +
   1.262 +    /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
   1.263 +     * AMOTION_EVENT_ACTION_UP).  The motion contains the most recent point, as well as
   1.264 +     * any intermediate points since the last down or move event.
   1.265 +     */
   1.266 +    AMOTION_EVENT_ACTION_MOVE = 2,
   1.267 +
   1.268 +    /* The current gesture has been aborted.
   1.269 +     * You will not receive any more points in it.  You should treat this as
   1.270 +     * an up event, but not perform any action that you normally would.
   1.271 +     */
   1.272 +    AMOTION_EVENT_ACTION_CANCEL = 3,
   1.273 +
   1.274 +    /* A movement has happened outside of the normal bounds of the UI element.
   1.275 +     * This does not provide a full gesture, but only the initial location of the movement/touch.
   1.276 +     */
   1.277 +    AMOTION_EVENT_ACTION_OUTSIDE = 4,
   1.278 +
   1.279 +    /* A non-primary pointer has gone down.
   1.280 +     * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
   1.281 +     */
   1.282 +    AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
   1.283 +
   1.284 +    /* A non-primary pointer has gone up.
   1.285 +     * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
   1.286 +     */
   1.287 +    AMOTION_EVENT_ACTION_POINTER_UP = 6,
   1.288 +
   1.289 +    /* A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
   1.290 +     * The motion contains the most recent point, as well as any intermediate points since
   1.291 +     * the last hover move event.
   1.292 +     */
   1.293 +    AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
   1.294 +
   1.295 +    /* The motion event contains relative vertical and/or horizontal scroll offsets.
   1.296 +     * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
   1.297 +     * and AMOTION_EVENT_AXIS_HSCROLL.
   1.298 +     * The pointer may or may not be down when this event is dispatched.
   1.299 +     * This action is always delivered to the winder under the pointer, which
   1.300 +     * may not be the window currently touched.
   1.301 +     */
   1.302 +    AMOTION_EVENT_ACTION_SCROLL = 8,
   1.303 +
   1.304 +    /* The pointer is not down but has entered the boundaries of a window or view.
   1.305 +     */
   1.306 +    AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
   1.307 +
   1.308 +    /* The pointer is not down but has exited the boundaries of a window or view.
   1.309 +     */
   1.310 +    AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
   1.311 +};
   1.312 +
   1.313 +/*
   1.314 + * Motion event flags.
   1.315 + */
   1.316 +enum {
   1.317 +    /* This flag indicates that the window that received this motion event is partly
   1.318 +     * or wholly obscured by another visible window above it.  This flag is set to true
   1.319 +     * even if the event did not directly pass through the obscured area.
   1.320 +     * A security sensitive application can check this flag to identify situations in which
   1.321 +     * a malicious application may have covered up part of its content for the purpose
   1.322 +     * of misleading the user or hijacking touches.  An appropriate response might be
   1.323 +     * to drop the suspect touches or to take additional precautions to confirm the user's
   1.324 +     * actual intent.
   1.325 +     */
   1.326 +    AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
   1.327 +};
   1.328 +
   1.329 +/*
   1.330 + * Motion event edge touch flags.
   1.331 + */
   1.332 +enum {
   1.333 +    /* No edges intersected */
   1.334 +    AMOTION_EVENT_EDGE_FLAG_NONE = 0,
   1.335 +
   1.336 +    /* Flag indicating the motion event intersected the top edge of the screen. */
   1.337 +    AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
   1.338 +
   1.339 +    /* Flag indicating the motion event intersected the bottom edge of the screen. */
   1.340 +    AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
   1.341 +
   1.342 +    /* Flag indicating the motion event intersected the left edge of the screen. */
   1.343 +    AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
   1.344 +
   1.345 +    /* Flag indicating the motion event intersected the right edge of the screen. */
   1.346 +    AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
   1.347 +};
   1.348 +
   1.349 +/*
   1.350 + * Constants that identify each individual axis of a motion event.
   1.351 + * Refer to the documentation on the MotionEvent class for descriptions of each axis.
   1.352 + */
   1.353 +enum {
   1.354 +    AMOTION_EVENT_AXIS_X = 0,
   1.355 +    AMOTION_EVENT_AXIS_Y = 1,
   1.356 +    AMOTION_EVENT_AXIS_PRESSURE = 2,
   1.357 +    AMOTION_EVENT_AXIS_SIZE = 3,
   1.358 +    AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
   1.359 +    AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
   1.360 +    AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
   1.361 +    AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
   1.362 +    AMOTION_EVENT_AXIS_ORIENTATION = 8,
   1.363 +    AMOTION_EVENT_AXIS_VSCROLL = 9,
   1.364 +    AMOTION_EVENT_AXIS_HSCROLL = 10,
   1.365 +    AMOTION_EVENT_AXIS_Z = 11,
   1.366 +    AMOTION_EVENT_AXIS_RX = 12,
   1.367 +    AMOTION_EVENT_AXIS_RY = 13,
   1.368 +    AMOTION_EVENT_AXIS_RZ = 14,
   1.369 +    AMOTION_EVENT_AXIS_HAT_X = 15,
   1.370 +    AMOTION_EVENT_AXIS_HAT_Y = 16,
   1.371 +    AMOTION_EVENT_AXIS_LTRIGGER = 17,
   1.372 +    AMOTION_EVENT_AXIS_RTRIGGER = 18,
   1.373 +    AMOTION_EVENT_AXIS_THROTTLE = 19,
   1.374 +    AMOTION_EVENT_AXIS_RUDDER = 20,
   1.375 +    AMOTION_EVENT_AXIS_WHEEL = 21,
   1.376 +    AMOTION_EVENT_AXIS_GAS = 22,
   1.377 +    AMOTION_EVENT_AXIS_BRAKE = 23,
   1.378 +    AMOTION_EVENT_AXIS_DISTANCE = 24,
   1.379 +    AMOTION_EVENT_AXIS_TILT = 25,
   1.380 +    AMOTION_EVENT_AXIS_GENERIC_1 = 32,
   1.381 +    AMOTION_EVENT_AXIS_GENERIC_2 = 33,
   1.382 +    AMOTION_EVENT_AXIS_GENERIC_3 = 34,
   1.383 +    AMOTION_EVENT_AXIS_GENERIC_4 = 35,
   1.384 +    AMOTION_EVENT_AXIS_GENERIC_5 = 36,
   1.385 +    AMOTION_EVENT_AXIS_GENERIC_6 = 37,
   1.386 +    AMOTION_EVENT_AXIS_GENERIC_7 = 38,
   1.387 +    AMOTION_EVENT_AXIS_GENERIC_8 = 39,
   1.388 +    AMOTION_EVENT_AXIS_GENERIC_9 = 40,
   1.389 +    AMOTION_EVENT_AXIS_GENERIC_10 = 41,
   1.390 +    AMOTION_EVENT_AXIS_GENERIC_11 = 42,
   1.391 +    AMOTION_EVENT_AXIS_GENERIC_12 = 43,
   1.392 +    AMOTION_EVENT_AXIS_GENERIC_13 = 44,
   1.393 +    AMOTION_EVENT_AXIS_GENERIC_14 = 45,
   1.394 +    AMOTION_EVENT_AXIS_GENERIC_15 = 46,
   1.395 +    AMOTION_EVENT_AXIS_GENERIC_16 = 47,
   1.396 +
   1.397 +    // NOTE: If you add a new axis here you must also add it to several other files.
   1.398 +    //       Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
   1.399 +};
   1.400 +
   1.401 +/*
   1.402 + * Constants that identify buttons that are associated with motion events.
   1.403 + * Refer to the documentation on the MotionEvent class for descriptions of each button.
   1.404 + */
   1.405 +enum {
   1.406 +    AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
   1.407 +    AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
   1.408 +    AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
   1.409 +    AMOTION_EVENT_BUTTON_BACK = 1 << 3,
   1.410 +    AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
   1.411 +};
   1.412 +
   1.413 +/*
   1.414 + * Constants that identify tool types.
   1.415 + * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
   1.416 + */
   1.417 +enum {
   1.418 +    AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
   1.419 +    AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
   1.420 +    AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
   1.421 +    AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
   1.422 +    AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
   1.423 +};
   1.424 +
   1.425 +/*
   1.426 + * Input sources.
   1.427 + *
   1.428 + * Refer to the documentation on android.view.InputDevice for more details about input sources
   1.429 + * and their correct interpretation.
   1.430 + */
   1.431 +enum {
   1.432 +    AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
   1.433 +
   1.434 +    AINPUT_SOURCE_CLASS_NONE = 0x00000000,
   1.435 +    AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
   1.436 +    AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
   1.437 +    AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
   1.438 +    AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
   1.439 +    AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
   1.440 +};
   1.441 +
   1.442 +enum {
   1.443 +    AINPUT_SOURCE_UNKNOWN = 0x00000000,
   1.444 +
   1.445 +    AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
   1.446 +    AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
   1.447 +    AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
   1.448 +    AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
   1.449 +    AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
   1.450 +    AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
   1.451 +    AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
   1.452 +    AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
   1.453 +    AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
   1.454 +    AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
   1.455 +
   1.456 +    AINPUT_SOURCE_ANY = 0xffffff00,
   1.457 +};
   1.458 +
   1.459 +/*
   1.460 + * Keyboard types.
   1.461 + *
   1.462 + * Refer to the documentation on android.view.InputDevice for more details.
   1.463 + */
   1.464 +enum {
   1.465 +    AINPUT_KEYBOARD_TYPE_NONE = 0,
   1.466 +    AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
   1.467 +    AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
   1.468 +};
   1.469 +
   1.470 +/*
   1.471 + * Constants used to retrieve information about the range of motion for a particular
   1.472 + * coordinate of a motion event.
   1.473 + *
   1.474 + * Refer to the documentation on android.view.InputDevice for more details about input sources
   1.475 + * and their correct interpretation.
   1.476 + *
   1.477 + * DEPRECATION NOTICE: These constants are deprecated.  Use AMOTION_EVENT_AXIS_* constants instead.
   1.478 + */
   1.479 +enum {
   1.480 +    AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
   1.481 +    AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
   1.482 +    AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
   1.483 +    AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
   1.484 +    AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
   1.485 +    AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
   1.486 +    AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
   1.487 +    AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
   1.488 +    AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
   1.489 +} __attribute__ ((deprecated));
   1.490 +
   1.491 +
   1.492 +/*
   1.493 + * Input event accessors.
   1.494 + *
   1.495 + * Note that most functions can only be used on input events that are of a given type.
   1.496 + * Calling these functions on input events of other types will yield undefined behavior.
   1.497 + */
   1.498 +
   1.499 +/*** Accessors for all input events. ***/
   1.500 +
   1.501 +/* Get the input event type. */
   1.502 +int32_t AInputEvent_getType(const AInputEvent* event);
   1.503 +
   1.504 +/* Get the id for the device that an input event came from.
   1.505 + *
   1.506 + * Input events can be generated by multiple different input devices.
   1.507 + * Use the input device id to obtain information about the input
   1.508 + * device that was responsible for generating a particular event.
   1.509 + *
   1.510 + * An input device id of 0 indicates that the event didn't come from a physical device;
   1.511 + * other numbers are arbitrary and you shouldn't depend on the values.
   1.512 + * Use the provided input device query API to obtain information about input devices.
   1.513 + */
   1.514 +int32_t AInputEvent_getDeviceId(const AInputEvent* event);
   1.515 +
   1.516 +/* Get the input event source. */
   1.517 +int32_t AInputEvent_getSource(const AInputEvent* event);
   1.518 +
   1.519 +/*** Accessors for key events only. ***/
   1.520 +
   1.521 +/* Get the key event action. */
   1.522 +int32_t AKeyEvent_getAction(const AInputEvent* key_event);
   1.523 +
   1.524 +/* Get the key event flags. */
   1.525 +int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
   1.526 +
   1.527 +/* Get the key code of the key event.
   1.528 + * This is the physical key that was pressed, not the Unicode character. */
   1.529 +int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
   1.530 +
   1.531 +/* Get the hardware key id of this key event.
   1.532 + * These values are not reliable and vary from device to device. */
   1.533 +int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
   1.534 +
   1.535 +/* Get the meta key state. */
   1.536 +int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
   1.537 +
   1.538 +/* Get the repeat count of the event.
   1.539 + * For both key up an key down events, this is the number of times the key has
   1.540 + * repeated with the first down starting at 0 and counting up from there.  For
   1.541 + * multiple key events, this is the number of down/up pairs that have occurred. */
   1.542 +int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
   1.543 +
   1.544 +/* Get the time of the most recent key down event, in the
   1.545 + * java.lang.System.nanoTime() time base.  If this is a down event,
   1.546 + * this will be the same as eventTime.
   1.547 + * Note that when chording keys, this value is the down time of the most recently
   1.548 + * pressed key, which may not be the same physical key of this event. */
   1.549 +int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
   1.550 +
   1.551 +/* Get the time this event occurred, in the
   1.552 + * java.lang.System.nanoTime() time base. */
   1.553 +int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
   1.554 +
   1.555 +/*** Accessors for motion events only. ***/
   1.556 +
   1.557 +/* Get the combined motion event action code and pointer index. */
   1.558 +int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
   1.559 +
   1.560 +/* Get the motion event flags. */
   1.561 +int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
   1.562 +
   1.563 +/* Get the state of any meta / modifier keys that were in effect when the
   1.564 + * event was generated. */
   1.565 +int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
   1.566 +
   1.567 +/* Get the button state of all buttons that are pressed. */
   1.568 +int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
   1.569 +
   1.570 +/* Get a bitfield indicating which edges, if any, were touched by this motion event.
   1.571 + * For touch events, clients can use this to determine if the user's finger was
   1.572 + * touching the edge of the display. */
   1.573 +int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
   1.574 +
   1.575 +/* Get the time when the user originally pressed down to start a stream of
   1.576 + * position events, in the java.lang.System.nanoTime() time base. */
   1.577 +int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
   1.578 +
   1.579 +/* Get the time when this specific event was generated,
   1.580 + * in the java.lang.System.nanoTime() time base. */
   1.581 +int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
   1.582 +
   1.583 +/* Get the X coordinate offset.
   1.584 + * For touch events on the screen, this is the delta that was added to the raw
   1.585 + * screen coordinates to adjust for the absolute position of the containing windows
   1.586 + * and views. */
   1.587 +float AMotionEvent_getXOffset(const AInputEvent* motion_event);
   1.588 +
   1.589 +/* Get the precision of the Y coordinates being reported.
   1.590 + * For touch events on the screen, this is the delta that was added to the raw
   1.591 + * screen coordinates to adjust for the absolute position of the containing windows
   1.592 + * and views. */
   1.593 +float AMotionEvent_getYOffset(const AInputEvent* motion_event);
   1.594 +
   1.595 +/* Get the precision of the X coordinates being reported.
   1.596 + * You can multiply this number with an X coordinate sample to find the
   1.597 + * actual hardware value of the X coordinate. */
   1.598 +float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
   1.599 +
   1.600 +/* Get the precision of the Y coordinates being reported.
   1.601 + * You can multiply this number with a Y coordinate sample to find the
   1.602 + * actual hardware value of the Y coordinate. */
   1.603 +float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
   1.604 +
   1.605 +/* Get the number of pointers of data contained in this event.
   1.606 + * Always >= 1. */
   1.607 +size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
   1.608 +
   1.609 +/* Get the pointer identifier associated with a particular pointer
   1.610 + * data index in this event.  The identifier tells you the actual pointer
   1.611 + * number associated with the data, accounting for individual pointers
   1.612 + * going up and down since the start of the current gesture. */
   1.613 +int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
   1.614 +
   1.615 +/* Get the tool type of a pointer for the given pointer index.
   1.616 + * The tool type indicates the type of tool used to make contact such as a
   1.617 + * finger or stylus, if known. */
   1.618 +int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
   1.619 +
   1.620 +/* Get the original raw X coordinate of this event.
   1.621 + * For touch events on the screen, this is the original location of the event
   1.622 + * on the screen, before it had been adjusted for the containing window
   1.623 + * and views. */
   1.624 +float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
   1.625 +
   1.626 +/* Get the original raw X coordinate of this event.
   1.627 + * For touch events on the screen, this is the original location of the event
   1.628 + * on the screen, before it had been adjusted for the containing window
   1.629 + * and views. */
   1.630 +float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
   1.631 +
   1.632 +/* Get the current X coordinate of this event for the given pointer index.
   1.633 + * Whole numbers are pixels; the value may have a fraction for input devices
   1.634 + * that are sub-pixel precise. */
   1.635 +float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
   1.636 +
   1.637 +/* Get the current Y coordinate of this event for the given pointer index.
   1.638 + * Whole numbers are pixels; the value may have a fraction for input devices
   1.639 + * that are sub-pixel precise. */
   1.640 +float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
   1.641 +
   1.642 +/* Get the current pressure of this event for the given pointer index.
   1.643 + * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
   1.644 + * although values higher than 1 may be generated depending on the calibration of
   1.645 + * the input device. */
   1.646 +float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
   1.647 +
   1.648 +/* Get the current scaled value of the approximate size for the given pointer index.
   1.649 + * This represents some approximation of the area of the screen being
   1.650 + * pressed; the actual value in pixels corresponding to the
   1.651 + * touch is normalized with the device specific range of values
   1.652 + * and scaled to a value between 0 and 1.  The value of size can be used to
   1.653 + * determine fat touch events. */
   1.654 +float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
   1.655 +
   1.656 +/* Get the current length of the major axis of an ellipse that describes the touch area
   1.657 + * at the point of contact for the given pointer index. */
   1.658 +float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
   1.659 +
   1.660 +/* Get the current length of the minor axis of an ellipse that describes the touch area
   1.661 + * at the point of contact for the given pointer index. */
   1.662 +float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
   1.663 +
   1.664 +/* Get the current length of the major axis of an ellipse that describes the size
   1.665 + * of the approaching tool for the given pointer index.
   1.666 + * The tool area represents the estimated size of the finger or pen that is
   1.667 + * touching the device independent of its actual touch area at the point of contact. */
   1.668 +float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
   1.669 +
   1.670 +/* Get the current length of the minor axis of an ellipse that describes the size
   1.671 + * of the approaching tool for the given pointer index.
   1.672 + * The tool area represents the estimated size of the finger or pen that is
   1.673 + * touching the device independent of its actual touch area at the point of contact. */
   1.674 +float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
   1.675 +
   1.676 +/* Get the current orientation of the touch area and tool area in radians clockwise from
   1.677 + * vertical for the given pointer index.
   1.678 + * An angle of 0 degrees indicates that the major axis of contact is oriented
   1.679 + * upwards, is perfectly circular or is of unknown orientation.  A positive angle
   1.680 + * indicates that the major axis of contact is oriented to the right.  A negative angle
   1.681 + * indicates that the major axis of contact is oriented to the left.
   1.682 + * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
   1.683 + * (finger pointing fully right). */
   1.684 +float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
   1.685 +
   1.686 +/* Get the value of the request axis for the given pointer index. */
   1.687 +float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
   1.688 +        int32_t axis, size_t pointer_index);
   1.689 +
   1.690 +/* Get the number of historical points in this event.  These are movements that
   1.691 + * have occurred between this event and the previous event.  This only applies
   1.692 + * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
   1.693 + * Historical samples are indexed from oldest to newest. */
   1.694 +size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
   1.695 +
   1.696 +/* Get the time that a historical movement occurred between this event and
   1.697 + * the previous event, in the java.lang.System.nanoTime() time base. */
   1.698 +int64_t AMotionEvent_getHistoricalEventTime(AInputEvent* motion_event,
   1.699 +        size_t history_index);
   1.700 +
   1.701 +/* Get the historical raw X coordinate of this event for the given pointer index that
   1.702 + * occurred between this event and the previous motion event.
   1.703 + * For touch events on the screen, this is the original location of the event
   1.704 + * on the screen, before it had been adjusted for the containing window
   1.705 + * and views.
   1.706 + * Whole numbers are pixels; the value may have a fraction for input devices
   1.707 + * that are sub-pixel precise. */
   1.708 +float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
   1.709 +        size_t history_index);
   1.710 +
   1.711 +/* Get the historical raw Y coordinate of this event for the given pointer index that
   1.712 + * occurred between this event and the previous motion event.
   1.713 + * For touch events on the screen, this is the original location of the event
   1.714 + * on the screen, before it had been adjusted for the containing window
   1.715 + * and views.
   1.716 + * Whole numbers are pixels; the value may have a fraction for input devices
   1.717 + * that are sub-pixel precise. */
   1.718 +float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
   1.719 +        size_t history_index);
   1.720 +
   1.721 +/* Get the historical X coordinate of this event for the given pointer index that
   1.722 + * occurred between this event and the previous motion event.
   1.723 + * Whole numbers are pixels; the value may have a fraction for input devices
   1.724 + * that are sub-pixel precise. */
   1.725 +float AMotionEvent_getHistoricalX(AInputEvent* motion_event, size_t pointer_index,
   1.726 +        size_t history_index);
   1.727 +
   1.728 +/* Get the historical Y coordinate of this event for the given pointer index that
   1.729 + * occurred between this event and the previous motion event.
   1.730 + * Whole numbers are pixels; the value may have a fraction for input devices
   1.731 + * that are sub-pixel precise. */
   1.732 +float AMotionEvent_getHistoricalY(AInputEvent* motion_event, size_t pointer_index,
   1.733 +        size_t history_index);
   1.734 +
   1.735 +/* Get the historical pressure of this event for the given pointer index that
   1.736 + * occurred between this event and the previous motion event.
   1.737 + * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
   1.738 + * although values higher than 1 may be generated depending on the calibration of
   1.739 + * the input device. */
   1.740 +float AMotionEvent_getHistoricalPressure(AInputEvent* motion_event, size_t pointer_index,
   1.741 +        size_t history_index);
   1.742 +
   1.743 +/* Get the current scaled value of the approximate size for the given pointer index that
   1.744 + * occurred between this event and the previous motion event.
   1.745 + * This represents some approximation of the area of the screen being
   1.746 + * pressed; the actual value in pixels corresponding to the
   1.747 + * touch is normalized with the device specific range of values
   1.748 + * and scaled to a value between 0 and 1.  The value of size can be used to
   1.749 + * determine fat touch events. */
   1.750 +float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index,
   1.751 +        size_t history_index);
   1.752 +
   1.753 +/* Get the historical length of the major axis of an ellipse that describes the touch area
   1.754 + * at the point of contact for the given pointer index that
   1.755 + * occurred between this event and the previous motion event. */
   1.756 +float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
   1.757 +        size_t history_index);
   1.758 +
   1.759 +/* Get the historical length of the minor axis of an ellipse that describes the touch area
   1.760 + * at the point of contact for the given pointer index that
   1.761 + * occurred between this event and the previous motion event. */
   1.762 +float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
   1.763 +        size_t history_index);
   1.764 +
   1.765 +/* Get the historical length of the major axis of an ellipse that describes the size
   1.766 + * of the approaching tool for the given pointer index that
   1.767 + * occurred between this event and the previous motion event.
   1.768 + * The tool area represents the estimated size of the finger or pen that is
   1.769 + * touching the device independent of its actual touch area at the point of contact. */
   1.770 +float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
   1.771 +        size_t history_index);
   1.772 +
   1.773 +/* Get the historical length of the minor axis of an ellipse that describes the size
   1.774 + * of the approaching tool for the given pointer index that
   1.775 + * occurred between this event and the previous motion event.
   1.776 + * The tool area represents the estimated size of the finger or pen that is
   1.777 + * touching the device independent of its actual touch area at the point of contact. */
   1.778 +float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
   1.779 +        size_t history_index);
   1.780 +
   1.781 +/* Get the historical orientation of the touch area and tool area in radians clockwise from
   1.782 + * vertical for the given pointer index that
   1.783 + * occurred between this event and the previous motion event.
   1.784 + * An angle of 0 degrees indicates that the major axis of contact is oriented
   1.785 + * upwards, is perfectly circular or is of unknown orientation.  A positive angle
   1.786 + * indicates that the major axis of contact is oriented to the right.  A negative angle
   1.787 + * indicates that the major axis of contact is oriented to the left.
   1.788 + * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
   1.789 + * (finger pointing fully right). */
   1.790 +float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
   1.791 +        size_t history_index);
   1.792 +
   1.793 +/* Get the historical value of the request axis for the given pointer index
   1.794 + * that occurred between this event and the previous motion event. */
   1.795 +float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
   1.796 +        int32_t axis, size_t pointer_index, size_t history_index);
   1.797 +
   1.798 +
   1.799 +/*
   1.800 + * Input queue
   1.801 + *
   1.802 + * An input queue is the facility through which you retrieve input
   1.803 + * events.
   1.804 + */
   1.805 +struct AInputQueue;
   1.806 +typedef struct AInputQueue AInputQueue;
   1.807 +
   1.808 +/*
   1.809 + * Add this input queue to a looper for processing.  See
   1.810 + * ALooper_addFd() for information on the ident, callback, and data params.
   1.811 + */
   1.812 +void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
   1.813 +        int ident, ALooper_callbackFunc callback, void* data);
   1.814 +
   1.815 +/*
   1.816 + * Remove the input queue from the looper it is currently attached to.
   1.817 + */
   1.818 +void AInputQueue_detachLooper(AInputQueue* queue);
   1.819 +
   1.820 +/*
   1.821 + * Returns true if there are one or more events available in the
   1.822 + * input queue.  Returns 1 if the queue has events; 0 if
   1.823 + * it does not have events; and a negative value if there is an error.
   1.824 + */
   1.825 +int32_t AInputQueue_hasEvents(AInputQueue* queue);
   1.826 +
   1.827 +/*
   1.828 + * Returns the next available event from the queue.  Returns a negative
   1.829 + * value if no events are available or an error has occurred.
   1.830 + */
   1.831 +int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
   1.832 +
   1.833 +/*
   1.834 + * Sends the key for standard pre-dispatching -- that is, possibly deliver
   1.835 + * it to the current IME to be consumed before the app.  Returns 0 if it
   1.836 + * was not pre-dispatched, meaning you can process it right now.  If non-zero
   1.837 + * is returned, you must abandon the current event processing and allow the
   1.838 + * event to appear again in the event queue (if it does not get consumed during
   1.839 + * pre-dispatching).
   1.840 + */
   1.841 +int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
   1.842 +
   1.843 +/*
   1.844 + * Report that dispatching has finished with the given event.
   1.845 + * This must be called after receiving an event with AInputQueue_get_event().
   1.846 + */
   1.847 +void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
   1.848 +
   1.849 +#ifdef __cplusplus
   1.850 +}
   1.851 +#endif
   1.852 +
   1.853 +#endif // _ANDROID_INPUT_H

mercurial