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