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