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