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, |
| 298 | AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010, |
| 299 | }; |
| 300 | |
| 301 | enum { |
| 302 | AINPUT_SOURCE_UNKNOWN = 0x00000000, |
| 303 | |
| 304 | AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON, |
| 305 | AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON, |
| 306 | AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON, |
| 307 | AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER, |
| 308 | AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER, |
| 309 | AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION, |
| 310 | AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION, |
| 311 | AINPUT_SOURCE_JOYSTICK_LEFT = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK, |
| 312 | AINPUT_SOURCE_JOYSTICK_RIGHT = 0x02000000 | AINPUT_SOURCE_CLASS_JOYSTICK, |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 313 | }; |
| 314 | |
| 315 | /* |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 316 | * Keyboard types. |
| 317 | * |
| 318 | * Refer to the documentation on android.view.InputDevice for more details. |
| 319 | */ |
| 320 | enum { |
| 321 | AINPUT_KEYBOARD_TYPE_NONE = 0, |
| 322 | AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1, |
| 323 | AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2, |
| 324 | }; |
| 325 | |
| 326 | /* |
| 327 | * Constants used to retrieve information about the range of motion for a particular |
| 328 | * coordinate of a motion event. |
| 329 | * |
| 330 | * Refer to the documentation on android.view.InputDevice for more details about input sources |
| 331 | * and their correct interpretation. |
| 332 | */ |
| 333 | enum { |
| 334 | AINPUT_MOTION_RANGE_X = 0, |
| 335 | AINPUT_MOTION_RANGE_Y = 1, |
| 336 | AINPUT_MOTION_RANGE_PRESSURE = 2, |
| 337 | AINPUT_MOTION_RANGE_SIZE = 3, |
| 338 | AINPUT_MOTION_RANGE_TOUCH_MAJOR = 4, |
| 339 | AINPUT_MOTION_RANGE_TOUCH_MINOR = 5, |
| 340 | AINPUT_MOTION_RANGE_TOOL_MAJOR = 6, |
| 341 | AINPUT_MOTION_RANGE_TOOL_MINOR = 7, |
| 342 | AINPUT_MOTION_RANGE_ORIENTATION = 8, |
| 343 | }; |
| 344 | |
| 345 | |
| 346 | /* |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 347 | * Input event accessors. |
| 348 | * |
| 349 | * Note that most functions can only be used on input events that are of a given type. |
| 350 | * Calling these functions on input events of other types will yield undefined behavior. |
| 351 | */ |
| 352 | |
| 353 | /*** Accessors for all input events. ***/ |
| 354 | |
| 355 | /* Get the input event type. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 356 | int32_t AInputEvent_getType(const AInputEvent* event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 357 | |
| 358 | /* Get the id for the device that an input event came from. |
| 359 | * |
| 360 | * Input events can be generated by multiple different input devices. |
| 361 | * Use the input device id to obtain information about the input |
| 362 | * device that was responsible for generating a particular event. |
| 363 | * |
| 364 | * An input device id of 0 indicates that the event didn't come from a physical device; |
| 365 | * other numbers are arbitrary and you shouldn't depend on the values. |
| 366 | * Use the provided input device query API to obtain information about input devices. |
| 367 | */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 368 | int32_t AInputEvent_getDeviceId(const AInputEvent* event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 369 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 370 | /* Get the input event source. */ |
| 371 | int32_t AInputEvent_getSource(const AInputEvent* event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 372 | |
| 373 | /*** Accessors for key events only. ***/ |
| 374 | |
| 375 | /* Get the key event action. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 376 | int32_t AKeyEvent_getAction(const AInputEvent* key_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 377 | |
| 378 | /* Get the key event flags. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 379 | int32_t AKeyEvent_getFlags(const AInputEvent* key_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 380 | |
| 381 | /* Get the key code of the key event. |
| 382 | * This is the physical key that was pressed, not the Unicode character. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 383 | int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 384 | |
| 385 | /* Get the hardware key id of this key event. |
| 386 | * These values are not reliable and vary from device to device. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 387 | int32_t AKeyEvent_getScanCode(const AInputEvent* key_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 388 | |
| 389 | /* Get the meta key state. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 390 | int32_t AKeyEvent_getMetaState(const AInputEvent* key_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 391 | |
| 392 | /* Get the repeat count of the event. |
| 393 | * For both key up an key down events, this is the number of times the key has |
| 394 | * repeated with the first down starting at 0 and counting up from there. For |
| 395 | * 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] | 396 | int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 397 | |
| 398 | /* Get the time of the most recent key down event, in the |
| 399 | * java.lang.System.nanoTime() time base. If this is a down event, |
| 400 | * this will be the same as eventTime. |
| 401 | * Note that when chording keys, this value is the down time of the most recently |
| 402 | * 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] | 403 | int64_t AKeyEvent_getDownTime(const AInputEvent* key_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 404 | |
| 405 | /* Get the time this event occurred, in the |
| 406 | * java.lang.System.nanoTime() time base. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 407 | int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 408 | |
| 409 | /*** Accessors for motion events only. ***/ |
| 410 | |
| 411 | /* Get the combined motion event action code and pointer index. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 412 | int32_t AMotionEvent_getAction(const AInputEvent* motion_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 413 | |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame^] | 414 | /* Get the motion event flags. */ |
| 415 | int32_t AMotionEvent_getFlags(const AInputEvent* motion_event); |
| 416 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 417 | /* Get the state of any meta / modifier keys that were in effect when the |
| 418 | * event was generated. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 419 | int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 420 | |
| 421 | /* Get a bitfield indicating which edges, if any, were touched by this motion event. |
| 422 | * For touch events, clients can use this to determine if the user's finger was |
| 423 | * touching the edge of the display. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 424 | int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 425 | |
| 426 | /* Get the time when the user originally pressed down to start a stream of |
| 427 | * position events, in the java.lang.System.nanoTime() time base. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 428 | int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 429 | |
| 430 | /* Get the time when this specific event was generated, |
| 431 | * in the java.lang.System.nanoTime() time base. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 432 | int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 433 | |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 434 | /* Get the X coordinate offset. |
| 435 | * For touch events on the screen, this is the delta that was added to the raw |
| 436 | * screen coordinates to adjust for the absolute position of the containing windows |
| 437 | * and views. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 438 | float AMotionEvent_getXOffset(const AInputEvent* motion_event); |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 439 | |
| 440 | /* Get the precision of the Y coordinates being reported. |
| 441 | * For touch events on the screen, this is the delta that was added to the raw |
| 442 | * screen coordinates to adjust for the absolute position of the containing windows |
| 443 | * and views. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 444 | float AMotionEvent_getYOffset(const AInputEvent* motion_event); |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 445 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 446 | /* Get the precision of the X coordinates being reported. |
| 447 | * You can multiply this number with an X coordinate sample to find the |
| 448 | * actual hardware value of the X coordinate. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 449 | float AMotionEvent_getXPrecision(const AInputEvent* motion_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 450 | |
| 451 | /* Get the precision of the Y coordinates being reported. |
| 452 | * You can multiply this number with a Y coordinate sample to find the |
| 453 | * actual hardware value of the Y coordinate. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 454 | float AMotionEvent_getYPrecision(const AInputEvent* motion_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 455 | |
| 456 | /* Get the number of pointers of data contained in this event. |
| 457 | * Always >= 1. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 458 | size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 459 | |
| 460 | /* Get the pointer identifier associated with a particular pointer |
| 461 | * data index is this event. The identifier tells you the actual pointer |
| 462 | * number associated with the data, accounting for individual pointers |
| 463 | * going up and down since the start of the current gesture. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 464 | int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 465 | |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 466 | /* Get the original raw X coordinate of this event. |
| 467 | * For touch events on the screen, this is the original location of the event |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 468 | * on the screen, before it had been adjusted for the containing window |
| 469 | * and views. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 470 | float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 471 | |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 472 | /* Get the original raw X coordinate of this event. |
| 473 | * 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] | 474 | * on the screen, before it had been adjusted for the containing window |
| 475 | * and views. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 476 | float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 477 | |
| 478 | /* Get the current X coordinate of this event for the given pointer index. |
| 479 | * Whole numbers are pixels; the value may have a fraction for input devices |
| 480 | * that are sub-pixel precise. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 481 | float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 482 | |
| 483 | /* Get the current Y coordinate of this event for the given pointer index. |
| 484 | * Whole numbers are pixels; the value may have a fraction for input devices |
| 485 | * that are sub-pixel precise. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 486 | float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 487 | |
| 488 | /* Get the current pressure of this event for the given pointer index. |
| 489 | * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), |
| 490 | * however values higher than 1 may be generated depending on the calibration of |
| 491 | * the input device. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 492 | float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 493 | |
| 494 | /* Get the current scaled value of the approximate size for the given pointer index. |
| 495 | * This represents some approximation of the area of the screen being |
| 496 | * pressed; the actual value in pixels corresponding to the |
| 497 | * touch is normalized with the device specific range of values |
| 498 | * and scaled to a value between 0 and 1. The value of size can be used to |
| 499 | * determine fat touch events. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 500 | float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 501 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 502 | /* Get the current length of the major axis of an ellipse that describes the touch area |
| 503 | * at the point of contact for the given pointer index. */ |
| 504 | float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index); |
| 505 | |
| 506 | /* Get the current length of the minor axis of an ellipse that describes the touch area |
| 507 | * at the point of contact for the given pointer index. */ |
| 508 | float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index); |
| 509 | |
| 510 | /* Get the current length of the major axis of an ellipse that describes the size |
| 511 | * of the approaching tool for the given pointer index. |
| 512 | * The tool area represents the estimated size of the finger or pen that is |
| 513 | * touching the device independent of its actual touch area at the point of contact. */ |
| 514 | float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index); |
| 515 | |
| 516 | /* Get the current length of the minor axis of an ellipse that describes the size |
| 517 | * of the approaching tool for the given pointer index. |
| 518 | * The tool area represents the estimated size of the finger or pen that is |
| 519 | * touching the device independent of its actual touch area at the point of contact. */ |
| 520 | float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index); |
| 521 | |
| 522 | /* Get the current orientation of the touch area and tool area in radians clockwise from |
| 523 | * vertical for the given pointer index. |
| 524 | * An angle of 0 degrees indicates that the major axis of contact is oriented |
| 525 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
| 526 | * indicates that the major axis of contact is oriented to the right. A negative angle |
| 527 | * indicates that the major axis of contact is oriented to the left. |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 528 | * 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] | 529 | * (finger pointing fully right). */ |
| 530 | float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index); |
| 531 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 532 | /* Get the number of historical points in this event. These are movements that |
| 533 | * have occurred between this event and the previous event. This only applies |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 534 | * 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] | 535 | * Historical samples are indexed from oldest to newest. */ |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 536 | size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 537 | |
| 538 | /* Get the time that a historical movement occurred between this event and |
| 539 | * the previous event, in the java.lang.System.nanoTime() time base. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 540 | int64_t AMotionEvent_getHistoricalEventTime(AInputEvent* motion_event, |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 541 | size_t history_index); |
| 542 | |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 543 | /* Get the historical raw X coordinate of this event for the given pointer index that |
| 544 | * occurred between this event and the previous motion event. |
| 545 | * For touch events on the screen, this is the original location of the event |
| 546 | * on the screen, before it had been adjusted for the containing window |
| 547 | * and views. |
| 548 | * Whole numbers are pixels; the value may have a fraction for input devices |
| 549 | * that are sub-pixel precise. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 550 | float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index); |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 551 | |
| 552 | /* Get the historical raw Y coordinate of this event for the given pointer index that |
| 553 | * occurred between this event and the previous motion event. |
| 554 | * For touch events on the screen, this is the original location of the event |
| 555 | * on the screen, before it had been adjusted for the containing window |
| 556 | * and views. |
| 557 | * Whole numbers are pixels; the value may have a fraction for input devices |
| 558 | * that are sub-pixel precise. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 559 | float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index); |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 560 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 561 | /* Get the historical X coordinate of this event for the given pointer index that |
| 562 | * occurred between this event and the previous motion event. |
| 563 | * Whole numbers are pixels; the value may have a fraction for input devices |
| 564 | * that are sub-pixel precise. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 565 | float AMotionEvent_getHistoricalX(AInputEvent* motion_event, size_t pointer_index, |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 566 | size_t history_index); |
| 567 | |
| 568 | /* Get the historical Y coordinate of this event for the given pointer index that |
| 569 | * occurred between this event and the previous motion event. |
| 570 | * Whole numbers are pixels; the value may have a fraction for input devices |
| 571 | * that are sub-pixel precise. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 572 | float AMotionEvent_getHistoricalY(AInputEvent* motion_event, size_t pointer_index, |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 573 | size_t history_index); |
| 574 | |
| 575 | /* Get the historical pressure of this event for the given pointer index that |
| 576 | * occurred between this event and the previous motion event. |
| 577 | * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), |
| 578 | * however values higher than 1 may be generated depending on the calibration of |
| 579 | * the input device. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 580 | float AMotionEvent_getHistoricalPressure(AInputEvent* motion_event, size_t pointer_index, |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 581 | size_t history_index); |
| 582 | |
| 583 | /* Get the current scaled value of the approximate size for the given pointer index that |
| 584 | * occurred between this event and the previous motion event. |
| 585 | * This represents some approximation of the area of the screen being |
| 586 | * pressed; the actual value in pixels corresponding to the |
| 587 | * touch is normalized with the device specific range of values |
| 588 | * and scaled to a value between 0 and 1. The value of size can be used to |
| 589 | * determine fat touch events. */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 590 | float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index, |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 591 | size_t history_index); |
| 592 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 593 | /* Get the historical length of the major axis of an ellipse that describes the touch area |
| 594 | * at the point of contact for the given pointer index that |
| 595 | * occurred between this event and the previous motion event. */ |
| 596 | float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index, |
| 597 | size_t history_index); |
| 598 | |
| 599 | /* Get the historical length of the minor axis of an ellipse that describes the touch area |
| 600 | * at the point of contact for the given pointer index that |
| 601 | * occurred between this event and the previous motion event. */ |
| 602 | float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index, |
| 603 | size_t history_index); |
| 604 | |
| 605 | /* Get the historical length of the major axis of an ellipse that describes the size |
| 606 | * of the approaching tool for the given pointer index that |
| 607 | * occurred between this event and the previous motion event. |
| 608 | * The tool area represents the estimated size of the finger or pen that is |
| 609 | * touching the device independent of its actual touch area at the point of contact. */ |
| 610 | float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index, |
| 611 | size_t history_index); |
| 612 | |
| 613 | /* Get the historical length of the minor axis of an ellipse that describes the size |
| 614 | * of the approaching tool for the given pointer index that |
| 615 | * occurred between this event and the previous motion event. |
| 616 | * The tool area represents the estimated size of the finger or pen that is |
| 617 | * touching the device independent of its actual touch area at the point of contact. */ |
| 618 | float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index, |
| 619 | size_t history_index); |
| 620 | |
| 621 | /* Get the historical orientation of the touch area and tool area in radians clockwise from |
| 622 | * vertical for the given pointer index that |
| 623 | * occurred between this event and the previous motion event. |
| 624 | * An angle of 0 degrees indicates that the major axis of contact is oriented |
| 625 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
| 626 | * indicates that the major axis of contact is oriented to the right. A negative angle |
| 627 | * indicates that the major axis of contact is oriented to the left. |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 628 | * 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] | 629 | * (finger pointing fully right). */ |
| 630 | float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, |
| 631 | size_t history_index); |
| 632 | |
| 633 | |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 634 | /* |
| 635 | * Input queue |
| 636 | * |
| 637 | * An input queue is the facility through which you retrieve input |
| 638 | * events. |
| 639 | */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 640 | struct AInputQueue; |
| 641 | typedef struct AInputQueue AInputQueue; |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 642 | |
| 643 | /* |
Dianne Hackborn | 85448bb | 2010-07-07 14:27:31 -0700 | [diff] [blame] | 644 | * Add this input queue to a looper for processing. See |
Dianne Hackborn | 42c03e5 | 2010-09-07 15:28:30 -0700 | [diff] [blame] | 645 | * ALooper_addFd() for information on the ident, callback, and data params. |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 646 | */ |
Dianne Hackborn | 6826741 | 2010-07-02 18:52:01 -0700 | [diff] [blame] | 647 | void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, |
Dianne Hackborn | 42c03e5 | 2010-09-07 15:28:30 -0700 | [diff] [blame] | 648 | int ident, ALooper_callbackFunc* callback, void* data); |
Dianne Hackborn | 6826741 | 2010-07-02 18:52:01 -0700 | [diff] [blame] | 649 | |
| 650 | /* |
| 651 | * Remove the input queue from the looper it is currently attached to. |
| 652 | */ |
| 653 | void AInputQueue_detachLooper(AInputQueue* queue); |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 654 | |
| 655 | /* |
| 656 | * Returns true if there are one or more events available in the |
| 657 | * input queue. Returns 1 if the queue has events; 0 if |
| 658 | * it does not have events; and a negative value if there is an error. |
| 659 | */ |
Dianne Hackborn | 2c6081c | 2010-07-15 17:44:53 -0700 | [diff] [blame] | 660 | int32_t AInputQueue_hasEvents(AInputQueue* queue); |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 661 | |
| 662 | /* |
| 663 | * Returns the next available event from the queue. Returns a negative |
| 664 | * value if no events are available or an error has occurred. |
| 665 | */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 666 | int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent); |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 667 | |
| 668 | /* |
Dianne Hackborn | 2c6081c | 2010-07-15 17:44:53 -0700 | [diff] [blame] | 669 | * Sends the key for standard pre-dispatching -- that is, possibly deliver |
| 670 | * it to the current IME to be consumed before the app. Returns 0 if it |
| 671 | * was not pre-dispatched, meaning you can process it right now. If non-zero |
| 672 | * is returned, you must abandon the current event processing and allow the |
| 673 | * event to appear again in the event queue (if it does not get consumed during |
| 674 | * pre-dispatching). |
| 675 | */ |
| 676 | int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event); |
| 677 | |
| 678 | /* |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 679 | * Report that dispatching has finished with the given event. |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 680 | * This must be called after receiving an event with AInputQueue_get_event(). |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 681 | */ |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 682 | void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled); |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 683 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 684 | #ifdef __cplusplus |
| 685 | } |
| 686 | #endif |
| 687 | |
| 688 | #endif // _ANDROID_INPUT_H |