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