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