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