Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -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 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 17 | /** |
| 18 | * @addtogroup Input |
| 19 | * @{ |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * @file input.h |
| 24 | */ |
| 25 | |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 26 | #ifndef _ANDROID_INPUT_H |
| 27 | #define _ANDROID_INPUT_H |
| 28 | |
Dan Albert | 494ed55 | 2016-09-23 15:57:45 -0700 | [diff] [blame] | 29 | #include <sys/cdefs.h> |
| 30 | |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 31 | /****************************************************************** |
| 32 | * |
| 33 | * IMPORTANT NOTICE: |
| 34 | * |
| 35 | * This file is part of Android's set of stable system headers |
| 36 | * exposed by the Android NDK (Native Development Kit). |
| 37 | * |
| 38 | * Third-party source AND binary code relies on the definitions |
| 39 | * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. |
| 40 | * |
| 41 | * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) |
| 42 | * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS |
| 43 | * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY |
| 44 | * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES |
| 45 | */ |
| 46 | |
| 47 | /* |
| 48 | * Structures and functions to receive and process input events in |
| 49 | * native code. |
| 50 | * |
| 51 | * NOTE: These functions MUST be implemented by /system/lib/libui.so |
| 52 | */ |
| 53 | |
| 54 | #include <stdint.h> |
| 55 | #include <sys/types.h> |
| 56 | #include <android/keycodes.h> |
Ady Abraham | 2a6c186 | 2022-07-28 22:54:19 +0000 | [diff] [blame] | 57 | |
| 58 | // This file is included by modules that have host support but android/looper.h is not supported |
| 59 | // on host. __REMOVED_IN needs to be defined in order for android/looper.h to be compiled. |
| 60 | #ifndef __BIONIC__ |
| 61 | #define __REMOVED_IN(x) __attribute__((deprecated)) |
| 62 | #endif |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 63 | #include <android/looper.h> |
Ady Abraham | 2a6c186 | 2022-07-28 22:54:19 +0000 | [diff] [blame] | 64 | |
Chris Ye | 1aaa212 | 2020-04-07 19:38:15 -0700 | [diff] [blame] | 65 | #include <jni.h> |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 66 | |
Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 67 | #if !defined(__INTRODUCED_IN) |
| 68 | #define __INTRODUCED_IN(__api_level) /* nothing */ |
| 69 | #endif |
| 70 | |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 71 | #ifdef __cplusplus |
| 72 | extern "C" { |
| 73 | #endif |
| 74 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 75 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 76 | * Key states (may be returned by queries about the current state of a |
| 77 | * particular key code, scan code or switch). |
| 78 | */ |
| 79 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 80 | /** The key state is unknown or the requested key itself is not supported. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 81 | AKEY_STATE_UNKNOWN = -1, |
| 82 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 83 | /** The key is up. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 84 | AKEY_STATE_UP = 0, |
| 85 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 86 | /** The key is down. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 87 | AKEY_STATE_DOWN = 1, |
| 88 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 89 | /** The key is down but is a virtual key press that is being emulated by the system. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 90 | AKEY_STATE_VIRTUAL = 2 |
| 91 | }; |
| 92 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 93 | /** |
Siarhei Vishniakou | 61fafdd | 2018-04-13 11:00:58 -0500 | [diff] [blame] | 94 | * Meta key / modifier state. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 95 | */ |
| 96 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 97 | /** No meta keys are pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 98 | AMETA_NONE = 0, |
| 99 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 100 | /** This mask is used to check whether one of the ALT meta keys is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 101 | AMETA_ALT_ON = 0x02, |
| 102 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 103 | /** This mask is used to check whether the left ALT meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 104 | AMETA_ALT_LEFT_ON = 0x10, |
| 105 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 106 | /** This mask is used to check whether the right ALT meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 107 | AMETA_ALT_RIGHT_ON = 0x20, |
| 108 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 109 | /** This mask is used to check whether one of the SHIFT meta keys is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 110 | AMETA_SHIFT_ON = 0x01, |
| 111 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 112 | /** This mask is used to check whether the left SHIFT meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 113 | AMETA_SHIFT_LEFT_ON = 0x40, |
| 114 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 115 | /** This mask is used to check whether the right SHIFT meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 116 | AMETA_SHIFT_RIGHT_ON = 0x80, |
| 117 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 118 | /** This mask is used to check whether the SYM meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 119 | AMETA_SYM_ON = 0x04, |
| 120 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 121 | /** This mask is used to check whether the FUNCTION meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 122 | AMETA_FUNCTION_ON = 0x08, |
| 123 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 124 | /** This mask is used to check whether one of the CTRL meta keys is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 125 | AMETA_CTRL_ON = 0x1000, |
| 126 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 127 | /** This mask is used to check whether the left CTRL meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 128 | AMETA_CTRL_LEFT_ON = 0x2000, |
| 129 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 130 | /** This mask is used to check whether the right CTRL meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 131 | AMETA_CTRL_RIGHT_ON = 0x4000, |
| 132 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 133 | /** This mask is used to check whether one of the META meta keys is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 134 | AMETA_META_ON = 0x10000, |
| 135 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 136 | /** This mask is used to check whether the left META meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 137 | AMETA_META_LEFT_ON = 0x20000, |
| 138 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 139 | /** This mask is used to check whether the right META meta key is pressed. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 140 | AMETA_META_RIGHT_ON = 0x40000, |
| 141 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 142 | /** This mask is used to check whether the CAPS LOCK meta key is on. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 143 | AMETA_CAPS_LOCK_ON = 0x100000, |
| 144 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 145 | /** This mask is used to check whether the NUM LOCK meta key is on. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 146 | AMETA_NUM_LOCK_ON = 0x200000, |
| 147 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 148 | /** This mask is used to check whether the SCROLL LOCK meta key is on. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 149 | AMETA_SCROLL_LOCK_ON = 0x400000, |
| 150 | }; |
| 151 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 152 | struct AInputEvent; |
| 153 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 154 | * Input events. |
| 155 | * |
| 156 | * Input events are opaque structures. Use the provided accessors functions to |
| 157 | * read their properties. |
| 158 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 159 | typedef struct AInputEvent AInputEvent; |
| 160 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 161 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 162 | * Input event types. |
| 163 | */ |
| 164 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 165 | /** Indicates that the input event is a key event. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 166 | AINPUT_EVENT_TYPE_KEY = 1, |
| 167 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 168 | /** Indicates that the input event is a motion event. */ |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 169 | AINPUT_EVENT_TYPE_MOTION = 2, |
| 170 | |
| 171 | /** Focus event */ |
| 172 | AINPUT_EVENT_TYPE_FOCUS = 3, |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 173 | |
| 174 | /** Capture event */ |
| 175 | AINPUT_EVENT_TYPE_CAPTURE = 4, |
arthurhung | 7632c33 | 2020-12-30 16:58:01 +0800 | [diff] [blame] | 176 | |
| 177 | /** Drag event */ |
| 178 | AINPUT_EVENT_TYPE_DRAG = 5, |
Antonio Kantek | 7cdf8ef | 2021-07-13 18:04:53 -0700 | [diff] [blame] | 179 | |
| 180 | /** TouchMode event */ |
| 181 | AINPUT_EVENT_TYPE_TOUCH_MODE = 6, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 182 | }; |
| 183 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 184 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 185 | * Key event actions. |
| 186 | */ |
| 187 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 188 | /** The key has been pressed down. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 189 | AKEY_EVENT_ACTION_DOWN = 0, |
| 190 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 191 | /** The key has been released. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 192 | AKEY_EVENT_ACTION_UP = 1, |
| 193 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 194 | /** |
| 195 | * Multiple duplicate key events have occurred in a row, or a |
| 196 | * complex string is being delivered. The repeat_count property |
| 197 | * of the key event contains the number of times the given key |
| 198 | * code should be executed. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 199 | */ |
| 200 | AKEY_EVENT_ACTION_MULTIPLE = 2 |
| 201 | }; |
| 202 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 203 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 204 | * Key event flags. |
| 205 | */ |
| 206 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 207 | /** This mask is set if the device woke because of this key event. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 208 | AKEY_EVENT_FLAG_WOKE_HERE = 0x1, |
| 209 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 210 | /** This mask is set if the key event was generated by a software keyboard. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 211 | AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2, |
| 212 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 213 | /** This mask is set if we don't want the key event to cause us to leave touch mode. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 214 | AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4, |
| 215 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 216 | /** |
| 217 | * This mask is set if an event was known to come from a trusted |
| 218 | * part of the system. That is, the event is known to come from |
| 219 | * the user, and could not have been spoofed by a third party |
| 220 | * component. |
| 221 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 222 | AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8, |
| 223 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 224 | /** |
| 225 | * This mask is used for compatibility, to identify enter keys that are |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 226 | * coming from an IME whose enter key has been auto-labelled "next" or |
| 227 | * "done". This allows TextView to dispatch these as normal enter keys |
| 228 | * for old applications, but still do the appropriate action when |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 229 | * receiving them. |
| 230 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 231 | AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10, |
| 232 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 233 | /** |
| 234 | * When associated with up key events, this indicates that the key press |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 235 | * has been canceled. Typically this is used with virtual touch screen |
| 236 | * keys, where the user can slide from the virtual key area on to the |
| 237 | * display: in that case, the application will receive a canceled up |
| 238 | * event and should not perform the action normally associated with the |
| 239 | * key. Note that for this to work, the application can not perform an |
| 240 | * action for a key until it receives an up or the long press timeout has |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 241 | * expired. |
| 242 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 243 | AKEY_EVENT_FLAG_CANCELED = 0x20, |
| 244 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 245 | /** |
| 246 | * This key event was generated by a virtual (on-screen) hard key area. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 247 | * Typically this is an area of the touchscreen, outside of the regular |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 248 | * display, dedicated to "hardware" buttons. |
| 249 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 250 | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40, |
| 251 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 252 | /** |
| 253 | * This flag is set for the first key repeat that occurs after the |
| 254 | * long press timeout. |
| 255 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 256 | AKEY_EVENT_FLAG_LONG_PRESS = 0x80, |
| 257 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 258 | /** |
| 259 | * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long |
| 260 | * press action was executed while it was down. |
| 261 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 262 | AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100, |
| 263 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 264 | /** |
| 265 | * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 266 | * tracked from its initial down. That is, somebody requested that tracking |
| 267 | * started on the key down and a long press has not caused |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 268 | * the tracking to be canceled. |
| 269 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 270 | AKEY_EVENT_FLAG_TRACKING = 0x200, |
| 271 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 272 | /** |
| 273 | * Set when a key event has been synthesized to implement default behavior |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 274 | * for an event that the application did not handle. |
| 275 | * Fallback key events are generated by unhandled trackball motions |
| 276 | * (to emulate a directional keypad) and by certain unhandled key presses |
| 277 | * that are declared in the key map (such as special function numeric keypad |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 278 | * keys when numlock is off). |
| 279 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 280 | AKEY_EVENT_FLAG_FALLBACK = 0x400, |
| 281 | }; |
| 282 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 283 | /** |
| 284 | * Bit shift for the action bits holding the pointer index as |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 285 | * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK. |
| 286 | */ |
| 287 | #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 |
| 288 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 289 | /** Motion event actions */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 290 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 291 | /** Bit mask of the parts of the action code that are the action itself. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 292 | AMOTION_EVENT_ACTION_MASK = 0xff, |
| 293 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 294 | /** |
| 295 | * Bits in the action code that represent a pointer index, used with |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 296 | * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting |
| 297 | * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer |
| 298 | * index where the data for the pointer going up or down can be found. |
| 299 | */ |
| 300 | AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00, |
| 301 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 302 | /** A pressed gesture has started, the motion contains the initial starting location. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 303 | AMOTION_EVENT_ACTION_DOWN = 0, |
| 304 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 305 | /** |
| 306 | * A pressed gesture has finished, the motion contains the final release location |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 307 | * as well as any intermediate points since the last down or move event. |
| 308 | */ |
| 309 | AMOTION_EVENT_ACTION_UP = 1, |
| 310 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 311 | /** |
| 312 | * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 313 | * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as |
| 314 | * any intermediate points since the last down or move event. |
| 315 | */ |
| 316 | AMOTION_EVENT_ACTION_MOVE = 2, |
| 317 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 318 | /** |
| 319 | * The current gesture has been aborted. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 320 | * You will not receive any more points in it. You should treat this as |
| 321 | * an up event, but not perform any action that you normally would. |
| 322 | */ |
| 323 | AMOTION_EVENT_ACTION_CANCEL = 3, |
| 324 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 325 | /** |
| 326 | * A movement has happened outside of the normal bounds of the UI element. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 327 | * This does not provide a full gesture, but only the initial location of the movement/touch. |
| 328 | */ |
| 329 | AMOTION_EVENT_ACTION_OUTSIDE = 4, |
| 330 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 331 | /** |
| 332 | * A non-primary pointer has gone down. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 333 | * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. |
| 334 | */ |
| 335 | AMOTION_EVENT_ACTION_POINTER_DOWN = 5, |
| 336 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 337 | /** |
| 338 | * A non-primary pointer has gone up. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 339 | * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. |
| 340 | */ |
| 341 | AMOTION_EVENT_ACTION_POINTER_UP = 6, |
| 342 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 343 | /** |
| 344 | * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE). |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 345 | * The motion contains the most recent point, as well as any intermediate points since |
| 346 | * the last hover move event. |
| 347 | */ |
| 348 | AMOTION_EVENT_ACTION_HOVER_MOVE = 7, |
| 349 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 350 | /** |
| 351 | * The motion event contains relative vertical and/or horizontal scroll offsets. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 352 | * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL |
| 353 | * and AMOTION_EVENT_AXIS_HSCROLL. |
| 354 | * The pointer may or may not be down when this event is dispatched. |
| 355 | * This action is always delivered to the winder under the pointer, which |
| 356 | * may not be the window currently touched. |
| 357 | */ |
| 358 | AMOTION_EVENT_ACTION_SCROLL = 8, |
| 359 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 360 | /** The pointer is not down but has entered the boundaries of a window or view. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 361 | AMOTION_EVENT_ACTION_HOVER_ENTER = 9, |
| 362 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 363 | /** The pointer is not down but has exited the boundaries of a window or view. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 364 | AMOTION_EVENT_ACTION_HOVER_EXIT = 10, |
Michael Wright | 7b159c9 | 2015-05-14 14:48:03 +0100 | [diff] [blame] | 365 | |
| 366 | /* One or more buttons have been pressed. */ |
| 367 | AMOTION_EVENT_ACTION_BUTTON_PRESS = 11, |
| 368 | |
| 369 | /* One or more buttons have been released. */ |
| 370 | AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 371 | }; |
| 372 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 373 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 374 | * Motion event flags. |
| 375 | */ |
| 376 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 377 | /** |
| 378 | * This flag indicates that the window that received this motion event is partly |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 379 | * or wholly obscured by another visible window above it. This flag is set to true |
| 380 | * even if the event did not directly pass through the obscured area. |
| 381 | * A security sensitive application can check this flag to identify situations in which |
| 382 | * a malicious application may have covered up part of its content for the purpose |
| 383 | * of misleading the user or hijacking touches. An appropriate response might be |
| 384 | * to drop the suspect touches or to take additional precautions to confirm the user's |
| 385 | * actual intent. |
| 386 | */ |
| 387 | AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1, |
| 388 | }; |
| 389 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 390 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 391 | * Motion event edge touch flags. |
| 392 | */ |
| 393 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 394 | /** No edges intersected. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 395 | AMOTION_EVENT_EDGE_FLAG_NONE = 0, |
| 396 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 397 | /** Flag indicating the motion event intersected the top edge of the screen. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 398 | AMOTION_EVENT_EDGE_FLAG_TOP = 0x01, |
| 399 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 400 | /** Flag indicating the motion event intersected the bottom edge of the screen. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 401 | AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02, |
| 402 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 403 | /** Flag indicating the motion event intersected the left edge of the screen. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 404 | AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04, |
| 405 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 406 | /** Flag indicating the motion event intersected the right edge of the screen. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 407 | AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08 |
| 408 | }; |
| 409 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 410 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 411 | * Constants that identify each individual axis of a motion event. |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 412 | * @anchor AMOTION_EVENT_AXIS |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 413 | */ |
| 414 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 415 | /** |
| 416 | * Axis constant: X axis of a motion event. |
| 417 | * |
| 418 | * - For a touch screen, reports the absolute X screen position of the center of |
| 419 | * the touch contact area. The units are display pixels. |
| 420 | * - For a touch pad, reports the absolute X surface position of the center of the touch |
| 421 | * contact area. The units are device-dependent. |
| 422 | * - For a mouse, reports the absolute X screen position of the mouse pointer. |
| 423 | * The units are display pixels. |
| 424 | * - For a trackball, reports the relative horizontal displacement of the trackball. |
| 425 | * The value is normalized to a range from -1.0 (left) to 1.0 (right). |
| 426 | * - For a joystick, reports the absolute X position of the joystick. |
| 427 | * The value is normalized to a range from -1.0 (left) to 1.0 (right). |
| 428 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 429 | AMOTION_EVENT_AXIS_X = 0, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 430 | /** |
| 431 | * Axis constant: Y axis of a motion event. |
| 432 | * |
| 433 | * - For a touch screen, reports the absolute Y screen position of the center of |
| 434 | * the touch contact area. The units are display pixels. |
| 435 | * - For a touch pad, reports the absolute Y surface position of the center of the touch |
| 436 | * contact area. The units are device-dependent. |
| 437 | * - For a mouse, reports the absolute Y screen position of the mouse pointer. |
| 438 | * The units are display pixels. |
| 439 | * - For a trackball, reports the relative vertical displacement of the trackball. |
| 440 | * The value is normalized to a range from -1.0 (up) to 1.0 (down). |
| 441 | * - For a joystick, reports the absolute Y position of the joystick. |
| 442 | * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near). |
| 443 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 444 | AMOTION_EVENT_AXIS_Y = 1, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 445 | /** |
| 446 | * Axis constant: Pressure axis of a motion event. |
| 447 | * |
| 448 | * - For a touch screen or touch pad, reports the approximate pressure applied to the surface |
| 449 | * by a finger or other tool. The value is normalized to a range from |
| 450 | * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1 |
| 451 | * may be generated depending on the calibration of the input device. |
| 452 | * - For a trackball, the value is set to 1 if the trackball button is pressed |
| 453 | * or 0 otherwise. |
| 454 | * - For a mouse, the value is set to 1 if the primary mouse button is pressed |
| 455 | * or 0 otherwise. |
| 456 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 457 | AMOTION_EVENT_AXIS_PRESSURE = 2, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 458 | /** |
| 459 | * Axis constant: Size axis of a motion event. |
| 460 | * |
| 461 | * - For a touch screen or touch pad, reports the approximate size of the contact area in |
| 462 | * relation to the maximum detectable size for the device. The value is normalized |
| 463 | * to a range from 0 (smallest detectable size) to 1 (largest detectable size), |
| 464 | * although it is not a linear scale. This value is of limited use. |
| 465 | * To obtain calibrated size information, see |
| 466 | * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}. |
| 467 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 468 | AMOTION_EVENT_AXIS_SIZE = 3, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 469 | /** |
| 470 | * Axis constant: TouchMajor axis of a motion event. |
| 471 | * |
| 472 | * - For a touch screen, reports the length of the major axis of an ellipse that |
| 473 | * represents the touch area at the point of contact. |
| 474 | * The units are display pixels. |
| 475 | * - For a touch pad, reports the length of the major axis of an ellipse that |
| 476 | * represents the touch area at the point of contact. |
| 477 | * The units are device-dependent. |
| 478 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 479 | AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 480 | /** |
| 481 | * Axis constant: TouchMinor axis of a motion event. |
| 482 | * |
| 483 | * - For a touch screen, reports the length of the minor axis of an ellipse that |
| 484 | * represents the touch area at the point of contact. |
| 485 | * The units are display pixels. |
| 486 | * - For a touch pad, reports the length of the minor axis of an ellipse that |
| 487 | * represents the touch area at the point of contact. |
| 488 | * The units are device-dependent. |
| 489 | * |
| 490 | * When the touch is circular, the major and minor axis lengths will be equal to one another. |
| 491 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 492 | AMOTION_EVENT_AXIS_TOUCH_MINOR = 5, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 493 | /** |
| 494 | * Axis constant: ToolMajor axis of a motion event. |
| 495 | * |
| 496 | * - For a touch screen, reports the length of the major axis of an ellipse that |
| 497 | * represents the size of the approaching finger or tool used to make contact. |
| 498 | * - For a touch pad, reports the length of the major axis of an ellipse that |
| 499 | * represents the size of the approaching finger or tool used to make contact. |
| 500 | * The units are device-dependent. |
| 501 | * |
| 502 | * When the touch is circular, the major and minor axis lengths will be equal to one another. |
| 503 | * |
| 504 | * The tool size may be larger than the touch size since the tool may not be fully |
| 505 | * in contact with the touch sensor. |
| 506 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 507 | AMOTION_EVENT_AXIS_TOOL_MAJOR = 6, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 508 | /** |
| 509 | * Axis constant: ToolMinor axis of a motion event. |
| 510 | * |
| 511 | * - For a touch screen, reports the length of the minor axis of an ellipse that |
| 512 | * represents the size of the approaching finger or tool used to make contact. |
| 513 | * - For a touch pad, reports the length of the minor axis of an ellipse that |
| 514 | * represents the size of the approaching finger or tool used to make contact. |
| 515 | * The units are device-dependent. |
| 516 | * |
| 517 | * When the touch is circular, the major and minor axis lengths will be equal to one another. |
| 518 | * |
| 519 | * The tool size may be larger than the touch size since the tool may not be fully |
| 520 | * in contact with the touch sensor. |
| 521 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 522 | AMOTION_EVENT_AXIS_TOOL_MINOR = 7, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 523 | /** |
| 524 | * Axis constant: Orientation axis of a motion event. |
| 525 | * |
| 526 | * - For a touch screen or touch pad, reports the orientation of the finger |
| 527 | * or tool in radians relative to the vertical plane of the device. |
| 528 | * An angle of 0 radians indicates that the major axis of contact is oriented |
| 529 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
| 530 | * indicates that the major axis of contact is oriented to the right. A negative angle |
| 531 | * indicates that the major axis of contact is oriented to the left. |
| 532 | * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians |
| 533 | * (finger pointing fully right). |
| 534 | * - For a stylus, the orientation indicates the direction in which the stylus |
| 535 | * is pointing in relation to the vertical axis of the current orientation of the screen. |
| 536 | * The range is from -PI radians to PI radians, where 0 is pointing up, |
| 537 | * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians |
| 538 | * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}. |
| 539 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 540 | AMOTION_EVENT_AXIS_ORIENTATION = 8, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 541 | /** |
| 542 | * Axis constant: Vertical Scroll axis of a motion event. |
| 543 | * |
| 544 | * - For a mouse, reports the relative movement of the vertical scroll wheel. |
| 545 | * The value is normalized to a range from -1.0 (down) to 1.0 (up). |
| 546 | * |
| 547 | * This axis should be used to scroll views vertically. |
| 548 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 549 | AMOTION_EVENT_AXIS_VSCROLL = 9, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 550 | /** |
| 551 | * Axis constant: Horizontal Scroll axis of a motion event. |
| 552 | * |
| 553 | * - For a mouse, reports the relative movement of the horizontal scroll wheel. |
| 554 | * The value is normalized to a range from -1.0 (left) to 1.0 (right). |
| 555 | * |
| 556 | * This axis should be used to scroll views horizontally. |
| 557 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 558 | AMOTION_EVENT_AXIS_HSCROLL = 10, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 559 | /** |
| 560 | * Axis constant: Z axis of a motion event. |
| 561 | * |
| 562 | * - For a joystick, reports the absolute Z position of the joystick. |
| 563 | * The value is normalized to a range from -1.0 (high) to 1.0 (low). |
| 564 | * <em>On game pads with two analog joysticks, this axis is often reinterpreted |
| 565 | * to report the absolute X position of the second joystick instead.</em> |
| 566 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 567 | AMOTION_EVENT_AXIS_Z = 11, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 568 | /** |
| 569 | * Axis constant: X Rotation axis of a motion event. |
| 570 | * |
| 571 | * - For a joystick, reports the absolute rotation angle about the X axis. |
| 572 | * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). |
| 573 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 574 | AMOTION_EVENT_AXIS_RX = 12, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 575 | /** |
| 576 | * Axis constant: Y Rotation axis of a motion event. |
| 577 | * |
| 578 | * - For a joystick, reports the absolute rotation angle about the Y axis. |
| 579 | * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). |
| 580 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 581 | AMOTION_EVENT_AXIS_RY = 13, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 582 | /** |
| 583 | * Axis constant: Z Rotation axis of a motion event. |
| 584 | * |
| 585 | * - For a joystick, reports the absolute rotation angle about the Z axis. |
| 586 | * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). |
| 587 | * On game pads with two analog joysticks, this axis is often reinterpreted |
| 588 | * to report the absolute Y position of the second joystick instead. |
| 589 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 590 | AMOTION_EVENT_AXIS_RZ = 14, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 591 | /** |
| 592 | * Axis constant: Hat X axis of a motion event. |
| 593 | * |
| 594 | * - For a joystick, reports the absolute X position of the directional hat control. |
| 595 | * The value is normalized to a range from -1.0 (left) to 1.0 (right). |
| 596 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 597 | AMOTION_EVENT_AXIS_HAT_X = 15, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 598 | /** |
| 599 | * Axis constant: Hat Y axis of a motion event. |
| 600 | * |
| 601 | * - For a joystick, reports the absolute Y position of the directional hat control. |
| 602 | * The value is normalized to a range from -1.0 (up) to 1.0 (down). |
| 603 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 604 | AMOTION_EVENT_AXIS_HAT_Y = 16, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 605 | /** |
| 606 | * Axis constant: Left Trigger axis of a motion event. |
| 607 | * |
| 608 | * - For a joystick, reports the absolute position of the left trigger control. |
| 609 | * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). |
| 610 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 611 | AMOTION_EVENT_AXIS_LTRIGGER = 17, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 612 | /** |
| 613 | * Axis constant: Right Trigger axis of a motion event. |
| 614 | * |
| 615 | * - For a joystick, reports the absolute position of the right trigger control. |
| 616 | * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). |
| 617 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 618 | AMOTION_EVENT_AXIS_RTRIGGER = 18, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 619 | /** |
| 620 | * Axis constant: Throttle axis of a motion event. |
| 621 | * |
| 622 | * - For a joystick, reports the absolute position of the throttle control. |
| 623 | * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed). |
| 624 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 625 | AMOTION_EVENT_AXIS_THROTTLE = 19, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 626 | /** |
| 627 | * Axis constant: Rudder axis of a motion event. |
| 628 | * |
| 629 | * - For a joystick, reports the absolute position of the rudder control. |
| 630 | * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). |
| 631 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 632 | AMOTION_EVENT_AXIS_RUDDER = 20, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 633 | /** |
| 634 | * Axis constant: Wheel axis of a motion event. |
| 635 | * |
| 636 | * - For a joystick, reports the absolute position of the steering wheel control. |
| 637 | * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). |
| 638 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 639 | AMOTION_EVENT_AXIS_WHEEL = 21, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 640 | /** |
| 641 | * Axis constant: Gas axis of a motion event. |
| 642 | * |
| 643 | * - For a joystick, reports the absolute position of the gas (accelerator) control. |
| 644 | * The value is normalized to a range from 0.0 (no acceleration) |
| 645 | * to 1.0 (maximum acceleration). |
| 646 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 647 | AMOTION_EVENT_AXIS_GAS = 22, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 648 | /** |
| 649 | * Axis constant: Brake axis of a motion event. |
| 650 | * |
| 651 | * - For a joystick, reports the absolute position of the brake control. |
| 652 | * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking). |
| 653 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 654 | AMOTION_EVENT_AXIS_BRAKE = 23, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 655 | /** |
| 656 | * Axis constant: Distance axis of a motion event. |
| 657 | * |
| 658 | * - For a stylus, reports the distance of the stylus from the screen. |
| 659 | * A value of 0.0 indicates direct contact and larger values indicate increasing |
| 660 | * distance from the surface. |
| 661 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 662 | AMOTION_EVENT_AXIS_DISTANCE = 24, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 663 | /** |
| 664 | * Axis constant: Tilt axis of a motion event. |
| 665 | * |
| 666 | * - For a stylus, reports the tilt angle of the stylus in radians where |
| 667 | * 0 radians indicates that the stylus is being held perpendicular to the |
| 668 | * surface, and PI/2 radians indicates that the stylus is being held flat |
| 669 | * against the surface. |
| 670 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 671 | AMOTION_EVENT_AXIS_TILT = 25, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 672 | /** |
Prashant Malani | 1941ff5 | 2015-08-11 18:29:28 -0700 | [diff] [blame] | 673 | * Axis constant: Generic scroll axis of a motion event. |
| 674 | * |
| 675 | * - This is used for scroll axis motion events that can't be classified as strictly |
| 676 | * vertical or horizontal. The movement of a rotating scroller is an example of this. |
| 677 | */ |
| 678 | AMOTION_EVENT_AXIS_SCROLL = 26, |
| 679 | /** |
Jun Mukai | fa1706a | 2015-12-03 01:14:46 -0800 | [diff] [blame] | 680 | * Axis constant: The movement of x position of a motion event. |
| 681 | * |
| 682 | * - For a mouse, reports a difference of x position between the previous position. |
| 683 | * This is useful when pointer is captured, in that case the mouse pointer doesn't |
| 684 | * change the location but this axis reports the difference which allows the app |
| 685 | * to see how the mouse is moved. |
| 686 | */ |
| 687 | AMOTION_EVENT_AXIS_RELATIVE_X = 27, |
| 688 | /** |
| 689 | * Axis constant: The movement of y position of a motion event. |
| 690 | * |
Siarhei Vishniakou | 2745c95 | 2021-03-17 20:27:41 +0000 | [diff] [blame] | 691 | * Same as {@link AMOTION_EVENT_AXIS_RELATIVE_X}, but for y position. |
Jun Mukai | fa1706a | 2015-12-03 01:14:46 -0800 | [diff] [blame] | 692 | */ |
| 693 | AMOTION_EVENT_AXIS_RELATIVE_Y = 28, |
| 694 | /** |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 695 | * Axis constant: Generic 1 axis of a motion event. |
| 696 | * The interpretation of a generic axis is device-specific. |
| 697 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 698 | AMOTION_EVENT_AXIS_GENERIC_1 = 32, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 699 | /** |
| 700 | * Axis constant: Generic 2 axis of a motion event. |
| 701 | * The interpretation of a generic axis is device-specific. |
| 702 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 703 | AMOTION_EVENT_AXIS_GENERIC_2 = 33, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 704 | /** |
| 705 | * Axis constant: Generic 3 axis of a motion event. |
| 706 | * The interpretation of a generic axis is device-specific. |
| 707 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 708 | AMOTION_EVENT_AXIS_GENERIC_3 = 34, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 709 | /** |
| 710 | * Axis constant: Generic 4 axis of a motion event. |
| 711 | * The interpretation of a generic axis is device-specific. |
| 712 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 713 | AMOTION_EVENT_AXIS_GENERIC_4 = 35, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 714 | /** |
| 715 | * Axis constant: Generic 5 axis of a motion event. |
| 716 | * The interpretation of a generic axis is device-specific. |
| 717 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 718 | AMOTION_EVENT_AXIS_GENERIC_5 = 36, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 719 | /** |
| 720 | * Axis constant: Generic 6 axis of a motion event. |
| 721 | * The interpretation of a generic axis is device-specific. |
| 722 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 723 | AMOTION_EVENT_AXIS_GENERIC_6 = 37, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 724 | /** |
| 725 | * Axis constant: Generic 7 axis of a motion event. |
| 726 | * The interpretation of a generic axis is device-specific. |
| 727 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 728 | AMOTION_EVENT_AXIS_GENERIC_7 = 38, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 729 | /** |
| 730 | * Axis constant: Generic 8 axis of a motion event. |
| 731 | * The interpretation of a generic axis is device-specific. |
| 732 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 733 | AMOTION_EVENT_AXIS_GENERIC_8 = 39, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 734 | /** |
| 735 | * Axis constant: Generic 9 axis of a motion event. |
| 736 | * The interpretation of a generic axis is device-specific. |
| 737 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 738 | AMOTION_EVENT_AXIS_GENERIC_9 = 40, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 739 | /** |
| 740 | * Axis constant: Generic 10 axis of a motion event. |
| 741 | * The interpretation of a generic axis is device-specific. |
| 742 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 743 | AMOTION_EVENT_AXIS_GENERIC_10 = 41, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 744 | /** |
| 745 | * Axis constant: Generic 11 axis of a motion event. |
| 746 | * The interpretation of a generic axis is device-specific. |
| 747 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 748 | AMOTION_EVENT_AXIS_GENERIC_11 = 42, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 749 | /** |
| 750 | * Axis constant: Generic 12 axis of a motion event. |
| 751 | * The interpretation of a generic axis is device-specific. |
| 752 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 753 | AMOTION_EVENT_AXIS_GENERIC_12 = 43, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 754 | /** |
| 755 | * Axis constant: Generic 13 axis of a motion event. |
| 756 | * The interpretation of a generic axis is device-specific. |
| 757 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 758 | AMOTION_EVENT_AXIS_GENERIC_13 = 44, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 759 | /** |
| 760 | * Axis constant: Generic 14 axis of a motion event. |
| 761 | * The interpretation of a generic axis is device-specific. |
| 762 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 763 | AMOTION_EVENT_AXIS_GENERIC_14 = 45, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 764 | /** |
| 765 | * Axis constant: Generic 15 axis of a motion event. |
| 766 | * The interpretation of a generic axis is device-specific. |
| 767 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 768 | AMOTION_EVENT_AXIS_GENERIC_15 = 46, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 769 | /** |
| 770 | * Axis constant: Generic 16 axis of a motion event. |
| 771 | * The interpretation of a generic axis is device-specific. |
| 772 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 773 | AMOTION_EVENT_AXIS_GENERIC_16 = 47, |
Harry Cutts | 39b7ca2 | 2022-10-05 15:55:48 +0000 | [diff] [blame] | 774 | /** |
| 775 | * Axis constant: X gesture offset axis of a motion event. |
| 776 | * |
| 777 | * - For a touch pad, reports the distance that a swipe gesture has moved in the X axis, as a |
| 778 | * proportion of the touch pad's size. For example, if a touch pad is 1000 units wide, and a |
| 779 | * swipe gesture starts at X = 500 then moves to X = 400, this axis would have a value of |
| 780 | * -0.1. |
| 781 | */ |
| 782 | AMOTION_EVENT_AXIS_GESTURE_X_OFFSET = 48, |
| 783 | /** |
| 784 | * Axis constant: Y gesture offset axis of a motion event. |
| 785 | * |
| 786 | * The same as {@link AMOTION_EVENT_AXIS_GESTURE_X_OFFSET}, but for the Y axis. |
| 787 | */ |
| 788 | AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET = 49, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 789 | |
Yeabkal Wubshit | eee671e | 2022-10-06 15:13:34 -0700 | [diff] [blame] | 790 | /** |
| 791 | * Note: This is not an "Axis constant". It does not represent any axis, nor should it be used |
| 792 | * to represent any axis. It is a constant holding the value of the largest defined axis value, |
| 793 | * to make some computations (like iterating through all possible axes) cleaner. |
| 794 | * Please update the value accordingly if you add a new axis. |
| 795 | */ |
Harry Cutts | 39b7ca2 | 2022-10-05 15:55:48 +0000 | [diff] [blame] | 796 | AMOTION_EVENT_MAXIMUM_VALID_AXIS_VALUE = AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, |
Yeabkal Wubshit | eee671e | 2022-10-06 15:13:34 -0700 | [diff] [blame] | 797 | |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 798 | // NOTE: If you add a new axis here you must also add it to several other files. |
| 799 | // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list. |
Yeabkal Wubshit | eee671e | 2022-10-06 15:13:34 -0700 | [diff] [blame] | 800 | // Update AMOTION_EVENT_MAXIMUM_VALID_AXIS_VALUE accordingly as well. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 801 | }; |
| 802 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 803 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 804 | * Constants that identify buttons that are associated with motion events. |
| 805 | * Refer to the documentation on the MotionEvent class for descriptions of each button. |
| 806 | */ |
| 807 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 808 | /** primary */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 809 | AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 810 | /** secondary */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 811 | AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 812 | /** tertiary */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 813 | AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 814 | /** back */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 815 | AMOTION_EVENT_BUTTON_BACK = 1 << 3, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 816 | /** forward */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 817 | AMOTION_EVENT_BUTTON_FORWARD = 1 << 4, |
Michael Wright | 7b159c9 | 2015-05-14 14:48:03 +0100 | [diff] [blame] | 818 | AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5, |
| 819 | AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 820 | }; |
| 821 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 822 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 823 | * Constants that identify tool types. |
| 824 | * Refer to the documentation on the MotionEvent class for descriptions of each tool type. |
| 825 | */ |
| 826 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 827 | /** unknown */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 828 | AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 829 | /** finger */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 830 | AMOTION_EVENT_TOOL_TYPE_FINGER = 1, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 831 | /** stylus */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 832 | AMOTION_EVENT_TOOL_TYPE_STYLUS = 2, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 833 | /** mouse */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 834 | AMOTION_EVENT_TOOL_TYPE_MOUSE = 3, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 835 | /** eraser */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 836 | AMOTION_EVENT_TOOL_TYPE_ERASER = 4, |
Arthur Hung | 421eb1c | 2020-01-16 00:09:42 +0800 | [diff] [blame] | 837 | /** palm */ |
| 838 | AMOTION_EVENT_TOOL_TYPE_PALM = 5, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 839 | }; |
| 840 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 841 | /** |
Vaibhav | 8576dd7 | 2022-02-11 18:19:06 +0530 | [diff] [blame] | 842 | * Constants that identify different gesture classification types. |
| 843 | */ |
Vaibhav Devmurari | 38fae2a | 2022-03-17 14:21:39 +0000 | [diff] [blame] | 844 | enum AMotionClassification : uint32_t { |
Vaibhav | 8576dd7 | 2022-02-11 18:19:06 +0530 | [diff] [blame] | 845 | /** |
| 846 | * Classification constant: None. |
| 847 | * |
| 848 | * No additional information is available about the current motion event stream. |
| 849 | */ |
| 850 | AMOTION_EVENT_CLASSIFICATION_NONE = 0, |
| 851 | /** |
| 852 | * Classification constant: Ambiguous gesture. |
| 853 | * |
Vaibhav Devmurari | 38fae2a | 2022-03-17 14:21:39 +0000 | [diff] [blame] | 854 | * The user's intent with respect to the current event stream is not yet determined. Events |
| 855 | * starting in AMBIGUOUS_GESTURE will eventually resolve into either DEEP_PRESS or NONE. |
Vaibhav | 8576dd7 | 2022-02-11 18:19:06 +0530 | [diff] [blame] | 856 | * Gestural actions, such as scrolling, should be inhibited until the classification resolves |
| 857 | * to another value or the event stream ends. |
| 858 | */ |
| 859 | AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE = 1, |
| 860 | /** |
| 861 | * Classification constant: Deep press. |
| 862 | * |
| 863 | * The current event stream represents the user intentionally pressing harder on the screen. |
| 864 | * This classification type should be used to accelerate the long press behaviour. |
| 865 | */ |
| 866 | AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS = 2, |
Harry Cutts | 2800fb0 | 2022-09-15 13:49:23 +0000 | [diff] [blame] | 867 | /** |
| 868 | * Classification constant: touchpad two-finger swipe. |
| 869 | * |
| 870 | * The current event stream represents the user swiping with two fingers on a touchpad. |
| 871 | */ |
| 872 | AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE = 3, |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame^] | 873 | /** |
| 874 | * Classification constant: multi-finger swipe. |
| 875 | * |
| 876 | * The current event stream represents the user swiping with three or more fingers on a |
| 877 | * touchpad. Unlike two-finger swipes, these are only to be handled by the system UI, which is |
| 878 | * why they have a separate constant from two-finger swipes. |
| 879 | */ |
| 880 | AMOTION_EVENT_CLASSIFICATION_MULTI_FINGER_SWIPE = 4, |
Vaibhav | 8576dd7 | 2022-02-11 18:19:06 +0530 | [diff] [blame] | 881 | }; |
| 882 | |
| 883 | /** |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 884 | * Input source masks. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 885 | * |
| 886 | * Refer to the documentation on android.view.InputDevice for more details about input sources |
| 887 | * and their correct interpretation. |
| 888 | */ |
| 889 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 890 | /** mask */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 891 | AINPUT_SOURCE_CLASS_MASK = 0x000000ff, |
| 892 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 893 | /** none */ |
Michael Wright | aadaca7 | 2013-03-11 14:20:14 -0700 | [diff] [blame] | 894 | AINPUT_SOURCE_CLASS_NONE = 0x00000000, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 895 | /** button */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 896 | AINPUT_SOURCE_CLASS_BUTTON = 0x00000001, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 897 | /** pointer */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 898 | AINPUT_SOURCE_CLASS_POINTER = 0x00000002, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 899 | /** navigation */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 900 | AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 901 | /** position */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 902 | AINPUT_SOURCE_CLASS_POSITION = 0x00000008, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 903 | /** joystick */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 904 | AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010, |
| 905 | }; |
| 906 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 907 | /** |
| 908 | * Input sources. |
| 909 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 910 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 911 | /** unknown */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 912 | AINPUT_SOURCE_UNKNOWN = 0x00000000, |
| 913 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 914 | /** keyboard */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 915 | AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 916 | /** dpad */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 917 | AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 918 | /** gamepad */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 919 | AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 920 | /** touchscreen */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 921 | AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 922 | /** mouse */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 923 | AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 924 | /** stylus */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 925 | AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER, |
Michael Wright | 7d3ad69 | 2015-06-23 19:04:31 +0100 | [diff] [blame] | 926 | /** bluetooth stylus */ |
Michael Wright | 2f78b68 | 2015-06-12 15:25:08 +0100 | [diff] [blame] | 927 | AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 928 | /** trackball */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 929 | AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION, |
Vladislav Kaznacheev | 78f97b3 | 2016-12-15 18:14:58 -0800 | [diff] [blame] | 930 | /** mouse relative */ |
| 931 | AINPUT_SOURCE_MOUSE_RELATIVE = 0x00020000 | AINPUT_SOURCE_CLASS_NAVIGATION, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 932 | /** touchpad */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 933 | AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 934 | /** navigation */ |
Michael Wright | aadaca7 | 2013-03-11 14:20:14 -0700 | [diff] [blame] | 935 | AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 936 | /** joystick */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 937 | AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK, |
Chris Ye | 0230344 | 2021-01-26 13:21:01 -0800 | [diff] [blame] | 938 | /** HDMI */ |
| 939 | AINPUT_SOURCE_HDMI = 0x02000000 | AINPUT_SOURCE_CLASS_BUTTON, |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 940 | /** sensor */ |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 941 | AINPUT_SOURCE_SENSOR = 0x04000000 | AINPUT_SOURCE_CLASS_NONE, |
Prashant Malani | 1941ff5 | 2015-08-11 18:29:28 -0700 | [diff] [blame] | 942 | /** rotary encoder */ |
| 943 | AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 944 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 945 | /** any */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 946 | AINPUT_SOURCE_ANY = 0xffffff00, |
| 947 | }; |
| 948 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 949 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 950 | * Keyboard types. |
| 951 | * |
| 952 | * Refer to the documentation on android.view.InputDevice for more details. |
Philip Junker | f843796 | 2022-01-25 21:20:19 +0100 | [diff] [blame] | 953 | * Note: When adding a new keyboard type here InputDeviceInfo::setKeyboardType needs to be updated. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 954 | */ |
| 955 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 956 | /** none */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 957 | AINPUT_KEYBOARD_TYPE_NONE = 0, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 958 | /** non alphabetic */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 959 | AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 960 | /** alphabetic */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 961 | AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2, |
| 962 | }; |
| 963 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 964 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 965 | * Constants used to retrieve information about the range of motion for a particular |
| 966 | * coordinate of a motion event. |
| 967 | * |
| 968 | * Refer to the documentation on android.view.InputDevice for more details about input sources |
| 969 | * and their correct interpretation. |
| 970 | * |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 971 | * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 972 | */ |
| 973 | enum { |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 974 | /** x */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 975 | AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 976 | /** y */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 977 | AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 978 | /** pressure */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 979 | AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 980 | /** size */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 981 | AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 982 | /** touch major */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 983 | AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 984 | /** touch minor */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 985 | AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 986 | /** tool major */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 987 | AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 988 | /** tool minor */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 989 | AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 990 | /** orientation */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 991 | AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION, |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 992 | }; |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 993 | |
| 994 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 995 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 996 | * Input event accessors. |
| 997 | * |
| 998 | * Note that most functions can only be used on input events that are of a given type. |
| 999 | * Calling these functions on input events of other types will yield undefined behavior. |
| 1000 | */ |
| 1001 | |
| 1002 | /*** Accessors for all input events. ***/ |
| 1003 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1004 | /** Get the input event type. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1005 | int32_t AInputEvent_getType(const AInputEvent* event); |
| 1006 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1007 | /** Get the id for the device that an input event came from. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1008 | * |
| 1009 | * Input events can be generated by multiple different input devices. |
| 1010 | * Use the input device id to obtain information about the input |
| 1011 | * device that was responsible for generating a particular event. |
| 1012 | * |
| 1013 | * An input device id of 0 indicates that the event didn't come from a physical device; |
| 1014 | * other numbers are arbitrary and you shouldn't depend on the values. |
| 1015 | * Use the provided input device query API to obtain information about input devices. |
| 1016 | */ |
| 1017 | int32_t AInputEvent_getDeviceId(const AInputEvent* event); |
| 1018 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1019 | /** Get the input event source. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1020 | int32_t AInputEvent_getSource(const AInputEvent* event); |
| 1021 | |
Chris Ye | 1aaa212 | 2020-04-07 19:38:15 -0700 | [diff] [blame] | 1022 | /** |
| 1023 | * Releases interface objects created by {@link AKeyEvent_fromJava()} |
| 1024 | * and {@link AMotionEvent_fromJava()}. |
| 1025 | * After returning, the specified AInputEvent* object becomes invalid and should no longer be used. |
| 1026 | * The underlying Java object remains valid and does not change its state. |
Elliott Hughes | dbfde64 | 2021-09-14 10:31:47 -0700 | [diff] [blame] | 1027 | * |
| 1028 | * Available since API level 31. |
Chris Ye | 1aaa212 | 2020-04-07 19:38:15 -0700 | [diff] [blame] | 1029 | */ |
Elliott Hughes | dbfde64 | 2021-09-14 10:31:47 -0700 | [diff] [blame] | 1030 | void AInputEvent_release(const AInputEvent* event) __INTRODUCED_IN(31); |
Chris Ye | 1aaa212 | 2020-04-07 19:38:15 -0700 | [diff] [blame] | 1031 | |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1032 | /*** Accessors for key events only. ***/ |
| 1033 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1034 | /** Get the key event action. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1035 | int32_t AKeyEvent_getAction(const AInputEvent* key_event); |
| 1036 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1037 | /** Get the key event flags. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1038 | int32_t AKeyEvent_getFlags(const AInputEvent* key_event); |
| 1039 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1040 | /** |
| 1041 | * Get the key code of the key event. |
| 1042 | * This is the physical key that was pressed, not the Unicode character. |
| 1043 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1044 | int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event); |
| 1045 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1046 | /** |
| 1047 | * Get the hardware key id of this key event. |
| 1048 | * These values are not reliable and vary from device to device. |
| 1049 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1050 | int32_t AKeyEvent_getScanCode(const AInputEvent* key_event); |
| 1051 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1052 | /** Get the meta key state. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1053 | int32_t AKeyEvent_getMetaState(const AInputEvent* key_event); |
| 1054 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1055 | /** |
| 1056 | * Get the repeat count of the event. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1057 | * For both key up an key down events, this is the number of times the key has |
| 1058 | * repeated with the first down starting at 0 and counting up from there. For |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1059 | * multiple key events, this is the number of down/up pairs that have occurred. |
| 1060 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1061 | int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event); |
| 1062 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1063 | /** |
| 1064 | * Get the time of the most recent key down event, in the |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1065 | * java.lang.System.nanoTime() time base. If this is a down event, |
| 1066 | * this will be the same as eventTime. |
| 1067 | * Note that when chording keys, this value is the down time of the most recently |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1068 | * pressed key, which may not be the same physical key of this event. |
| 1069 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1070 | int64_t AKeyEvent_getDownTime(const AInputEvent* key_event); |
| 1071 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1072 | /** |
| 1073 | * Get the time this event occurred, in the |
| 1074 | * java.lang.System.nanoTime() time base. |
| 1075 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1076 | int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); |
| 1077 | |
Chris Ye | 1aaa212 | 2020-04-07 19:38:15 -0700 | [diff] [blame] | 1078 | /** |
Siarhei Vishniakou | a53d865 | 2020-08-13 23:59:50 -0500 | [diff] [blame] | 1079 | * Creates a native AInputEvent* object that is a copy of the specified Java android.view.KeyEvent. |
| 1080 | * The result may be used with generic and KeyEvent-specific AInputEvent_* functions. The object |
| 1081 | * returned by this function must be disposed using {@link AInputEvent_release()}. |
Elliott Hughes | dbfde64 | 2021-09-14 10:31:47 -0700 | [diff] [blame] | 1082 | * |
| 1083 | * Available since API level 31. |
Chris Ye | 1aaa212 | 2020-04-07 19:38:15 -0700 | [diff] [blame] | 1084 | */ |
Elliott Hughes | dbfde64 | 2021-09-14 10:31:47 -0700 | [diff] [blame] | 1085 | const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent) __INTRODUCED_IN(31); |
Chris Ye | 1aaa212 | 2020-04-07 19:38:15 -0700 | [diff] [blame] | 1086 | |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1087 | /*** Accessors for motion events only. ***/ |
| 1088 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1089 | /** Get the combined motion event action code and pointer index. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1090 | int32_t AMotionEvent_getAction(const AInputEvent* motion_event); |
| 1091 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1092 | /** Get the motion event flags. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1093 | int32_t AMotionEvent_getFlags(const AInputEvent* motion_event); |
| 1094 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1095 | /** |
| 1096 | * Get the state of any meta / modifier keys that were in effect when the |
| 1097 | * event was generated. |
| 1098 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1099 | int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event); |
| 1100 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1101 | /** Get the button state of all buttons that are pressed. */ |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 1102 | int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event); |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1103 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1104 | /** |
| 1105 | * Get a bitfield indicating which edges, if any, were touched by this motion event. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1106 | * For touch events, clients can use this to determine if the user's finger was |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1107 | * touching the edge of the display. |
| 1108 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1109 | int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event); |
| 1110 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1111 | /** |
| 1112 | * Get the time when the user originally pressed down to start a stream of |
| 1113 | * position events, in the java.lang.System.nanoTime() time base. |
| 1114 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1115 | int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event); |
| 1116 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1117 | /** |
| 1118 | * Get the time when this specific event was generated, |
| 1119 | * in the java.lang.System.nanoTime() time base. |
| 1120 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1121 | int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event); |
| 1122 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1123 | /** |
| 1124 | * Get the X coordinate offset. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1125 | * For touch events on the screen, this is the delta that was added to the raw |
| 1126 | * screen coordinates to adjust for the absolute position of the containing windows |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1127 | * and views. |
| 1128 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1129 | float AMotionEvent_getXOffset(const AInputEvent* motion_event); |
| 1130 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1131 | /** |
| 1132 | * Get the Y coordinate offset. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1133 | * For touch events on the screen, this is the delta that was added to the raw |
| 1134 | * screen coordinates to adjust for the absolute position of the containing windows |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1135 | * and views. |
| 1136 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1137 | float AMotionEvent_getYOffset(const AInputEvent* motion_event); |
| 1138 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1139 | /** |
| 1140 | * Get the precision of the X coordinates being reported. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1141 | * You can multiply this number with an X coordinate sample to find the |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1142 | * actual hardware value of the X coordinate. |
| 1143 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1144 | float AMotionEvent_getXPrecision(const AInputEvent* motion_event); |
| 1145 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1146 | /** |
| 1147 | * Get the precision of the Y coordinates being reported. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1148 | * You can multiply this number with a Y coordinate sample to find the |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1149 | * actual hardware value of the Y coordinate. |
| 1150 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1151 | float AMotionEvent_getYPrecision(const AInputEvent* motion_event); |
| 1152 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1153 | /** |
| 1154 | * Get the number of pointers of data contained in this event. |
| 1155 | * Always >= 1. |
| 1156 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1157 | size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event); |
| 1158 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1159 | /** |
| 1160 | * Get the pointer identifier associated with a particular pointer |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1161 | * data index in this event. The identifier tells you the actual pointer |
| 1162 | * number associated with the data, accounting for individual pointers |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1163 | * going up and down since the start of the current gesture. |
| 1164 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1165 | int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index); |
| 1166 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1167 | /** |
| 1168 | * Get the tool type of a pointer for the given pointer index. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1169 | * The tool type indicates the type of tool used to make contact such as a |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1170 | * finger or stylus, if known. |
| 1171 | */ |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 1172 | int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index); |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1173 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1174 | /** |
| 1175 | * Get the original raw X coordinate of this event. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1176 | * For touch events on the screen, this is the original location of the event |
| 1177 | * on the screen, before it had been adjusted for the containing window |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1178 | * and views. |
| 1179 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1180 | float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index); |
| 1181 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1182 | /** |
| 1183 | * Get the original raw X coordinate of this event. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1184 | * For touch events on the screen, this is the original location of the event |
| 1185 | * on the screen, before it had been adjusted for the containing window |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1186 | * and views. |
| 1187 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1188 | float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index); |
| 1189 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1190 | /** |
| 1191 | * Get the current X coordinate of this event for the given pointer index. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1192 | * Whole numbers are pixels; the value may have a fraction for input devices |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1193 | * that are sub-pixel precise. |
| 1194 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1195 | float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index); |
| 1196 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1197 | /** |
| 1198 | * Get the current Y coordinate of this event for the given pointer index. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1199 | * Whole numbers are pixels; the value may have a fraction for input devices |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1200 | * that are sub-pixel precise. |
| 1201 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1202 | float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index); |
| 1203 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1204 | /** |
| 1205 | * Get the current pressure of this event for the given pointer index. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1206 | * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), |
| 1207 | * although values higher than 1 may be generated depending on the calibration of |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1208 | * the input device. |
| 1209 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1210 | float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index); |
| 1211 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1212 | /** |
| 1213 | * Get the current scaled value of the approximate size for the given pointer index. |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1214 | * This represents some approximation of the area of the screen being |
| 1215 | * pressed; the actual value in pixels corresponding to the |
| 1216 | * touch is normalized with the device specific range of values |
| 1217 | * and scaled to a value between 0 and 1. The value of size can be used to |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1218 | * determine fat touch events. |
| 1219 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1220 | float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index); |
| 1221 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1222 | /** |
| 1223 | * Get the current length of the major axis of an ellipse that describes the touch area |
| 1224 | * at the point of contact for the given pointer index. |
| 1225 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1226 | float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index); |
| 1227 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1228 | /** |
| 1229 | * Get the current length of the minor axis of an ellipse that describes the touch area |
| 1230 | * at the point of contact for the given pointer index. |
| 1231 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1232 | float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index); |
| 1233 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1234 | /** |
| 1235 | * Get the current length of the major axis of an ellipse that describes the size |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1236 | * of the approaching tool for the given pointer index. |
| 1237 | * The tool area represents the estimated size of the finger or pen that is |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1238 | * touching the device independent of its actual touch area at the point of contact. |
| 1239 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1240 | float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index); |
| 1241 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1242 | /** |
| 1243 | * Get the current length of the minor axis of an ellipse that describes the size |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1244 | * of the approaching tool for the given pointer index. |
| 1245 | * The tool area represents the estimated size of the finger or pen that is |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1246 | * touching the device independent of its actual touch area at the point of contact. |
| 1247 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1248 | float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index); |
| 1249 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1250 | /** |
| 1251 | * Get the current orientation of the touch area and tool area in radians clockwise from |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1252 | * vertical for the given pointer index. |
| 1253 | * An angle of 0 degrees indicates that the major axis of contact is oriented |
| 1254 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
| 1255 | * indicates that the major axis of contact is oriented to the right. A negative angle |
| 1256 | * indicates that the major axis of contact is oriented to the left. |
| 1257 | * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1258 | * (finger pointing fully right). |
| 1259 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1260 | float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index); |
| 1261 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1262 | /** Get the value of the request axis for the given pointer index. */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1263 | float AMotionEvent_getAxisValue(const AInputEvent* motion_event, |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 1264 | int32_t axis, size_t pointer_index); |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1265 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1266 | /** |
| 1267 | * Get the number of historical points in this event. These are movements that |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1268 | * have occurred between this event and the previous event. This only applies |
| 1269 | * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0. |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1270 | * Historical samples are indexed from oldest to newest. |
| 1271 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1272 | size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event); |
| 1273 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1274 | /** |
| 1275 | * Get the time that a historical movement occurred between this event and |
| 1276 | * the previous event, in the java.lang.System.nanoTime() time base. |
| 1277 | */ |
Andrew Hsieh | 26c2416 | 2013-05-27 12:26:04 +0800 | [diff] [blame] | 1278 | int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1279 | size_t history_index); |
| 1280 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1281 | /** |
| 1282 | * Get the historical raw X coordinate of this event for the given pointer index that |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1283 | * occurred between this event and the previous motion event. |
| 1284 | * For touch events on the screen, this is the original location of the event |
| 1285 | * on the screen, before it had been adjusted for the containing window |
| 1286 | * and views. |
| 1287 | * Whole numbers are pixels; the value may have a fraction for input devices |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1288 | * that are sub-pixel precise. |
| 1289 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1290 | float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index, |
| 1291 | size_t history_index); |
| 1292 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1293 | /** |
| 1294 | * Get the historical raw Y coordinate of this event for the given pointer index that |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1295 | * occurred between this event and the previous motion event. |
| 1296 | * For touch events on the screen, this is the original location of the event |
| 1297 | * on the screen, before it had been adjusted for the containing window |
| 1298 | * and views. |
| 1299 | * Whole numbers are pixels; the value may have a fraction for input devices |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1300 | * that are sub-pixel precise. |
| 1301 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1302 | float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index, |
| 1303 | size_t history_index); |
| 1304 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1305 | /** |
| 1306 | * Get the historical X coordinate of this event for the given pointer index that |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1307 | * occurred between this event and the previous motion event. |
| 1308 | * Whole numbers are pixels; the value may have a fraction for input devices |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1309 | * that are sub-pixel precise. |
| 1310 | */ |
Andrew Hsieh | 26c2416 | 2013-05-27 12:26:04 +0800 | [diff] [blame] | 1311 | float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1312 | size_t history_index); |
| 1313 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1314 | /** |
| 1315 | * Get the historical Y coordinate of this event for the given pointer index that |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1316 | * occurred between this event and the previous motion event. |
| 1317 | * Whole numbers are pixels; the value may have a fraction for input devices |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1318 | * that are sub-pixel precise. |
| 1319 | */ |
Andrew Hsieh | 26c2416 | 2013-05-27 12:26:04 +0800 | [diff] [blame] | 1320 | float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1321 | size_t history_index); |
| 1322 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1323 | /** |
| 1324 | * Get the historical pressure of this event for the given pointer index that |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1325 | * occurred between this event and the previous motion event. |
| 1326 | * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), |
| 1327 | * although values higher than 1 may be generated depending on the calibration of |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1328 | * the input device. |
| 1329 | */ |
Andrew Hsieh | 26c2416 | 2013-05-27 12:26:04 +0800 | [diff] [blame] | 1330 | float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1331 | size_t history_index); |
| 1332 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1333 | /** |
| 1334 | * Get the current scaled value of the approximate size for the given pointer index that |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1335 | * occurred between this event and the previous motion event. |
| 1336 | * This represents some approximation of the area of the screen being |
| 1337 | * pressed; the actual value in pixels corresponding to the |
| 1338 | * touch is normalized with the device specific range of values |
| 1339 | * and scaled to a value between 0 and 1. The value of size can be used to |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1340 | * determine fat touch events. |
| 1341 | */ |
Andrew Hsieh | 26c2416 | 2013-05-27 12:26:04 +0800 | [diff] [blame] | 1342 | float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index, |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1343 | size_t history_index); |
| 1344 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1345 | /** |
| 1346 | * Get the historical length of the major axis of an ellipse that describes the touch area |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1347 | * at the point of contact for the given pointer index that |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1348 | * occurred between this event and the previous motion event. |
| 1349 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1350 | float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index, |
| 1351 | size_t history_index); |
| 1352 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1353 | /** |
| 1354 | * Get the historical length of the minor axis of an ellipse that describes the touch area |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1355 | * at the point of contact for the given pointer index that |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1356 | * occurred between this event and the previous motion event. |
| 1357 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1358 | float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index, |
| 1359 | size_t history_index); |
| 1360 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1361 | /** |
| 1362 | * Get the historical length of the major axis of an ellipse that describes the size |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1363 | * of the approaching tool for the given pointer index that |
| 1364 | * occurred between this event and the previous motion event. |
| 1365 | * The tool area represents the estimated size of the finger or pen that is |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1366 | * touching the device independent of its actual touch area at the point of contact. |
| 1367 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1368 | float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index, |
| 1369 | size_t history_index); |
| 1370 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1371 | /** |
| 1372 | * Get the historical length of the minor axis of an ellipse that describes the size |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1373 | * of the approaching tool for the given pointer index that |
| 1374 | * occurred between this event and the previous motion event. |
| 1375 | * The tool area represents the estimated size of the finger or pen that is |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1376 | * touching the device independent of its actual touch area at the point of contact. |
| 1377 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1378 | float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index, |
| 1379 | size_t history_index); |
| 1380 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1381 | /** |
| 1382 | * Get the historical orientation of the touch area and tool area in radians clockwise from |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1383 | * vertical for the given pointer index that |
| 1384 | * occurred between this event and the previous motion event. |
| 1385 | * An angle of 0 degrees indicates that the major axis of contact is oriented |
| 1386 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
| 1387 | * indicates that the major axis of contact is oriented to the right. A negative angle |
| 1388 | * indicates that the major axis of contact is oriented to the left. |
| 1389 | * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1390 | * (finger pointing fully right). |
| 1391 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1392 | float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, |
| 1393 | size_t history_index); |
| 1394 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1395 | /** |
| 1396 | * Get the historical value of the request axis for the given pointer index |
| 1397 | * that occurred between this event and the previous motion event. |
| 1398 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1399 | float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 1400 | int32_t axis, size_t pointer_index, size_t history_index); |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1401 | |
Chris Ye | 1aaa212 | 2020-04-07 19:38:15 -0700 | [diff] [blame] | 1402 | /** |
Vaibhav | 8576dd7 | 2022-02-11 18:19:06 +0530 | [diff] [blame] | 1403 | * Get the action button for the motion event. Returns a valid action button when the |
| 1404 | * event is associated with a button press or button release action. For other actions |
| 1405 | * the return value is undefined. |
Vaibhav Devmurari | 38fae2a | 2022-03-17 14:21:39 +0000 | [diff] [blame] | 1406 | * |
| 1407 | * @see #AMOTION_EVENT_BUTTON_PRIMARY |
| 1408 | * @see #AMOTION_EVENT_BUTTON_SECONDARY |
| 1409 | * @see #AMOTION_EVENT_BUTTON_TERTIARY |
| 1410 | * @see #AMOTION_EVENT_BUTTON_BACK |
| 1411 | * @see #AMOTION_EVENT_BUTTON_FORWARD |
| 1412 | * @see #AMOTION_EVENT_BUTTON_STYLUS_PRIMARY |
| 1413 | * @see #AMOTION_EVENT_BUTTON_STYLUS_SECONDARY |
Vaibhav | 8576dd7 | 2022-02-11 18:19:06 +0530 | [diff] [blame] | 1414 | */ |
Vaibhav Devmurari | 38fae2a | 2022-03-17 14:21:39 +0000 | [diff] [blame] | 1415 | int32_t AMotionEvent_getActionButton(const AInputEvent* motion_event) |
| 1416 | __INTRODUCED_IN(__ANDROID_API_T__); |
Vaibhav | 8576dd7 | 2022-02-11 18:19:06 +0530 | [diff] [blame] | 1417 | |
| 1418 | /** |
| 1419 | * Returns the classification for the current gesture. |
| 1420 | * The classification may change as more events become available for the same gesture. |
| 1421 | * |
| 1422 | * @see #AMOTION_EVENT_CLASSIFICATION_NONE |
| 1423 | * @see #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE |
| 1424 | * @see #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS |
| 1425 | */ |
Vaibhav Devmurari | 38fae2a | 2022-03-17 14:21:39 +0000 | [diff] [blame] | 1426 | int32_t AMotionEvent_getClassification(const AInputEvent* motion_event) |
| 1427 | __INTRODUCED_IN(__ANDROID_API_T__); |
Vaibhav | 8576dd7 | 2022-02-11 18:19:06 +0530 | [diff] [blame] | 1428 | |
| 1429 | /** |
Siarhei Vishniakou | a53d865 | 2020-08-13 23:59:50 -0500 | [diff] [blame] | 1430 | * Creates a native AInputEvent* object that is a copy of the specified Java |
| 1431 | * android.view.MotionEvent. The result may be used with generic and MotionEvent-specific |
| 1432 | * AInputEvent_* functions. The object returned by this function must be disposed using |
| 1433 | * {@link AInputEvent_release()}. |
Elliott Hughes | dbfde64 | 2021-09-14 10:31:47 -0700 | [diff] [blame] | 1434 | * |
| 1435 | * Available since API level 31. |
Chris Ye | 1aaa212 | 2020-04-07 19:38:15 -0700 | [diff] [blame] | 1436 | */ |
Elliott Hughes | dbfde64 | 2021-09-14 10:31:47 -0700 | [diff] [blame] | 1437 | const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) __INTRODUCED_IN(31); |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1438 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1439 | struct AInputQueue; |
| 1440 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1441 | * Input queue |
| 1442 | * |
| 1443 | * An input queue is the facility through which you retrieve input |
| 1444 | * events. |
| 1445 | */ |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1446 | typedef struct AInputQueue AInputQueue; |
| 1447 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1448 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1449 | * Add this input queue to a looper for processing. See |
| 1450 | * ALooper_addFd() for information on the ident, callback, and data params. |
| 1451 | */ |
| 1452 | void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, |
| 1453 | int ident, ALooper_callbackFunc callback, void* data); |
| 1454 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1455 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1456 | * Remove the input queue from the looper it is currently attached to. |
| 1457 | */ |
| 1458 | void AInputQueue_detachLooper(AInputQueue* queue); |
| 1459 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1460 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1461 | * Returns true if there are one or more events available in the |
| 1462 | * input queue. Returns 1 if the queue has events; 0 if |
| 1463 | * it does not have events; and a negative value if there is an error. |
| 1464 | */ |
| 1465 | int32_t AInputQueue_hasEvents(AInputQueue* queue); |
| 1466 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1467 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1468 | * Returns the next available event from the queue. Returns a negative |
| 1469 | * value if no events are available or an error has occurred. |
| 1470 | */ |
| 1471 | int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent); |
| 1472 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1473 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1474 | * Sends the key for standard pre-dispatching -- that is, possibly deliver |
| 1475 | * it to the current IME to be consumed before the app. Returns 0 if it |
| 1476 | * was not pre-dispatched, meaning you can process it right now. If non-zero |
| 1477 | * is returned, you must abandon the current event processing and allow the |
| 1478 | * event to appear again in the event queue (if it does not get consumed during |
| 1479 | * pre-dispatching). |
| 1480 | */ |
| 1481 | int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event); |
| 1482 | |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1483 | /** |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1484 | * Report that dispatching has finished with the given event. |
| 1485 | * This must be called after receiving an event with AInputQueue_get_event(). |
| 1486 | */ |
| 1487 | void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled); |
| 1488 | |
Jim Blackler | a64c272 | 2021-09-01 16:39:16 +0100 | [diff] [blame] | 1489 | /** |
Prabir Pradhan | 9d43974 | 2021-12-16 03:32:30 -0800 | [diff] [blame] | 1490 | * Returns the AInputQueue* object associated with the supplied Java InputQueue |
| 1491 | * object. The returned native object holds a weak reference to the Java object, |
| 1492 | * and is only valid as long as the Java object has not yet been disposed. You |
| 1493 | * should ensure that there is a strong reference to the Java object and that it |
| 1494 | * has not been disposed before using the returned object. |
Jim Blackler | a64c272 | 2021-09-01 16:39:16 +0100 | [diff] [blame] | 1495 | * |
| 1496 | * Available since API level 33. |
| 1497 | */ |
Prabir Pradhan | b1e1e39 | 2021-12-16 03:28:20 -0800 | [diff] [blame] | 1498 | AInputQueue* AInputQueue_fromJava(JNIEnv* env, jobject inputQueue) __INTRODUCED_IN(33); |
Jim Blackler | a64c272 | 2021-09-01 16:39:16 +0100 | [diff] [blame] | 1499 | |
Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1500 | #ifdef __cplusplus |
| 1501 | } |
| 1502 | #endif |
| 1503 | |
| 1504 | #endif // _ANDROID_INPUT_H |
Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 1505 | |
| 1506 | /** @} */ |