input.h 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318
  1. /*
  2. * Copyright (C) 2010 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @addtogroup Input
  18. * @{
  19. */
  20. /**
  21. * @file input.h
  22. */
  23. #ifndef _ANDROID_INPUT_H
  24. #define _ANDROID_INPUT_H
  25. /******************************************************************
  26. *
  27. * IMPORTANT NOTICE:
  28. *
  29. * This file is part of Android's set of stable system headers
  30. * exposed by the Android NDK (Native Development Kit).
  31. *
  32. * Third-party source AND binary code relies on the definitions
  33. * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
  34. *
  35. * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
  36. * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
  37. * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
  38. * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
  39. */
  40. /*
  41. * Structures and functions to receive and process input events in
  42. * native code.
  43. *
  44. * NOTE: These functions MUST be implemented by /system/lib/libui.so
  45. */
  46. #include <stdint.h>
  47. #include <sys/types.h>
  48. #include <android/keycodes.h>
  49. #include <android/looper.h>
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. /**
  54. * Key states (may be returned by queries about the current state of a
  55. * particular key code, scan code or switch).
  56. */
  57. enum {
  58. /** The key state is unknown or the requested key itself is not supported. */
  59. AKEY_STATE_UNKNOWN = -1,
  60. /** The key is up. */
  61. AKEY_STATE_UP = 0,
  62. /** The key is down. */
  63. AKEY_STATE_DOWN = 1,
  64. /** The key is down but is a virtual key press that is being emulated by the system. */
  65. AKEY_STATE_VIRTUAL = 2
  66. };
  67. /**
  68. * Meta key / modifer state.
  69. */
  70. enum {
  71. /** No meta keys are pressed. */
  72. AMETA_NONE = 0,
  73. /** This mask is used to check whether one of the ALT meta keys is pressed. */
  74. AMETA_ALT_ON = 0x02,
  75. /** This mask is used to check whether the left ALT meta key is pressed. */
  76. AMETA_ALT_LEFT_ON = 0x10,
  77. /** This mask is used to check whether the right ALT meta key is pressed. */
  78. AMETA_ALT_RIGHT_ON = 0x20,
  79. /** This mask is used to check whether one of the SHIFT meta keys is pressed. */
  80. AMETA_SHIFT_ON = 0x01,
  81. /** This mask is used to check whether the left SHIFT meta key is pressed. */
  82. AMETA_SHIFT_LEFT_ON = 0x40,
  83. /** This mask is used to check whether the right SHIFT meta key is pressed. */
  84. AMETA_SHIFT_RIGHT_ON = 0x80,
  85. /** This mask is used to check whether the SYM meta key is pressed. */
  86. AMETA_SYM_ON = 0x04,
  87. /** This mask is used to check whether the FUNCTION meta key is pressed. */
  88. AMETA_FUNCTION_ON = 0x08,
  89. /** This mask is used to check whether one of the CTRL meta keys is pressed. */
  90. AMETA_CTRL_ON = 0x1000,
  91. /** This mask is used to check whether the left CTRL meta key is pressed. */
  92. AMETA_CTRL_LEFT_ON = 0x2000,
  93. /** This mask is used to check whether the right CTRL meta key is pressed. */
  94. AMETA_CTRL_RIGHT_ON = 0x4000,
  95. /** This mask is used to check whether one of the META meta keys is pressed. */
  96. AMETA_META_ON = 0x10000,
  97. /** This mask is used to check whether the left META meta key is pressed. */
  98. AMETA_META_LEFT_ON = 0x20000,
  99. /** This mask is used to check whether the right META meta key is pressed. */
  100. AMETA_META_RIGHT_ON = 0x40000,
  101. /** This mask is used to check whether the CAPS LOCK meta key is on. */
  102. AMETA_CAPS_LOCK_ON = 0x100000,
  103. /** This mask is used to check whether the NUM LOCK meta key is on. */
  104. AMETA_NUM_LOCK_ON = 0x200000,
  105. /** This mask is used to check whether the SCROLL LOCK meta key is on. */
  106. AMETA_SCROLL_LOCK_ON = 0x400000,
  107. };
  108. struct AInputEvent;
  109. /**
  110. * Input events.
  111. *
  112. * Input events are opaque structures. Use the provided accessors functions to
  113. * read their properties.
  114. */
  115. typedef struct AInputEvent AInputEvent;
  116. /**
  117. * Input event types.
  118. */
  119. enum {
  120. /** Indicates that the input event is a key event. */
  121. AINPUT_EVENT_TYPE_KEY = 1,
  122. /** Indicates that the input event is a motion event. */
  123. AINPUT_EVENT_TYPE_MOTION = 2
  124. };
  125. /**
  126. * Key event actions.
  127. */
  128. enum {
  129. /** The key has been pressed down. */
  130. AKEY_EVENT_ACTION_DOWN = 0,
  131. /** The key has been released. */
  132. AKEY_EVENT_ACTION_UP = 1,
  133. /**
  134. * Multiple duplicate key events have occurred in a row, or a
  135. * complex string is being delivered. The repeat_count property
  136. * of the key event contains the number of times the given key
  137. * code should be executed.
  138. */
  139. AKEY_EVENT_ACTION_MULTIPLE = 2
  140. };
  141. /**
  142. * Key event flags.
  143. */
  144. enum {
  145. /** This mask is set if the device woke because of this key event. */
  146. AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
  147. /** This mask is set if the key event was generated by a software keyboard. */
  148. AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
  149. /** This mask is set if we don't want the key event to cause us to leave touch mode. */
  150. AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
  151. /**
  152. * This mask is set if an event was known to come from a trusted
  153. * part of the system. That is, the event is known to come from
  154. * the user, and could not have been spoofed by a third party
  155. * component.
  156. */
  157. AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
  158. /**
  159. * This mask is used for compatibility, to identify enter keys that are
  160. * coming from an IME whose enter key has been auto-labelled "next" or
  161. * "done". This allows TextView to dispatch these as normal enter keys
  162. * for old applications, but still do the appropriate action when
  163. * receiving them.
  164. */
  165. AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
  166. /**
  167. * When associated with up key events, this indicates that the key press
  168. * has been canceled. Typically this is used with virtual touch screen
  169. * keys, where the user can slide from the virtual key area on to the
  170. * display: in that case, the application will receive a canceled up
  171. * event and should not perform the action normally associated with the
  172. * key. Note that for this to work, the application can not perform an
  173. * action for a key until it receives an up or the long press timeout has
  174. * expired.
  175. */
  176. AKEY_EVENT_FLAG_CANCELED = 0x20,
  177. /**
  178. * This key event was generated by a virtual (on-screen) hard key area.
  179. * Typically this is an area of the touchscreen, outside of the regular
  180. * display, dedicated to "hardware" buttons.
  181. */
  182. AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
  183. /**
  184. * This flag is set for the first key repeat that occurs after the
  185. * long press timeout.
  186. */
  187. AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
  188. /**
  189. * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
  190. * press action was executed while it was down.
  191. */
  192. AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
  193. /**
  194. * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
  195. * tracked from its initial down. That is, somebody requested that tracking
  196. * started on the key down and a long press has not caused
  197. * the tracking to be canceled.
  198. */
  199. AKEY_EVENT_FLAG_TRACKING = 0x200,
  200. /**
  201. * Set when a key event has been synthesized to implement default behavior
  202. * for an event that the application did not handle.
  203. * Fallback key events are generated by unhandled trackball motions
  204. * (to emulate a directional keypad) and by certain unhandled key presses
  205. * that are declared in the key map (such as special function numeric keypad
  206. * keys when numlock is off).
  207. */
  208. AKEY_EVENT_FLAG_FALLBACK = 0x400,
  209. };
  210. /**
  211. * Bit shift for the action bits holding the pointer index as
  212. * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
  213. */
  214. #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
  215. /** Motion event actions */
  216. enum {
  217. /** Bit mask of the parts of the action code that are the action itself. */
  218. AMOTION_EVENT_ACTION_MASK = 0xff,
  219. /**
  220. * Bits in the action code that represent a pointer index, used with
  221. * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
  222. * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
  223. * index where the data for the pointer going up or down can be found.
  224. */
  225. AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
  226. /** A pressed gesture has started, the motion contains the initial starting location. */
  227. AMOTION_EVENT_ACTION_DOWN = 0,
  228. /**
  229. * A pressed gesture has finished, the motion contains the final release location
  230. * as well as any intermediate points since the last down or move event.
  231. */
  232. AMOTION_EVENT_ACTION_UP = 1,
  233. /**
  234. * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
  235. * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
  236. * any intermediate points since the last down or move event.
  237. */
  238. AMOTION_EVENT_ACTION_MOVE = 2,
  239. /**
  240. * The current gesture has been aborted.
  241. * You will not receive any more points in it. You should treat this as
  242. * an up event, but not perform any action that you normally would.
  243. */
  244. AMOTION_EVENT_ACTION_CANCEL = 3,
  245. /**
  246. * A movement has happened outside of the normal bounds of the UI element.
  247. * This does not provide a full gesture, but only the initial location of the movement/touch.
  248. */
  249. AMOTION_EVENT_ACTION_OUTSIDE = 4,
  250. /**
  251. * A non-primary pointer has gone down.
  252. * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
  253. */
  254. AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
  255. /**
  256. * A non-primary pointer has gone up.
  257. * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
  258. */
  259. AMOTION_EVENT_ACTION_POINTER_UP = 6,
  260. /**
  261. * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
  262. * The motion contains the most recent point, as well as any intermediate points since
  263. * the last hover move event.
  264. */
  265. AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
  266. /**
  267. * The motion event contains relative vertical and/or horizontal scroll offsets.
  268. * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
  269. * and AMOTION_EVENT_AXIS_HSCROLL.
  270. * The pointer may or may not be down when this event is dispatched.
  271. * This action is always delivered to the winder under the pointer, which
  272. * may not be the window currently touched.
  273. */
  274. AMOTION_EVENT_ACTION_SCROLL = 8,
  275. /** The pointer is not down but has entered the boundaries of a window or view. */
  276. AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
  277. /** The pointer is not down but has exited the boundaries of a window or view. */
  278. AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
  279. /* One or more buttons have been pressed. */
  280. AMOTION_EVENT_ACTION_BUTTON_PRESS = 11,
  281. /* One or more buttons have been released. */
  282. AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12,
  283. };
  284. /**
  285. * Motion event flags.
  286. */
  287. enum {
  288. /**
  289. * This flag indicates that the window that received this motion event is partly
  290. * or wholly obscured by another visible window above it. This flag is set to true
  291. * even if the event did not directly pass through the obscured area.
  292. * A security sensitive application can check this flag to identify situations in which
  293. * a malicious application may have covered up part of its content for the purpose
  294. * of misleading the user or hijacking touches. An appropriate response might be
  295. * to drop the suspect touches or to take additional precautions to confirm the user's
  296. * actual intent.
  297. */
  298. AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
  299. };
  300. /**
  301. * Motion event edge touch flags.
  302. */
  303. enum {
  304. /** No edges intersected. */
  305. AMOTION_EVENT_EDGE_FLAG_NONE = 0,
  306. /** Flag indicating the motion event intersected the top edge of the screen. */
  307. AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
  308. /** Flag indicating the motion event intersected the bottom edge of the screen. */
  309. AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
  310. /** Flag indicating the motion event intersected the left edge of the screen. */
  311. AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
  312. /** Flag indicating the motion event intersected the right edge of the screen. */
  313. AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
  314. };
  315. /**
  316. * Constants that identify each individual axis of a motion event.
  317. * @anchor AMOTION_EVENT_AXIS
  318. */
  319. enum {
  320. /**
  321. * Axis constant: X axis of a motion event.
  322. *
  323. * - For a touch screen, reports the absolute X screen position of the center of
  324. * the touch contact area. The units are display pixels.
  325. * - For a touch pad, reports the absolute X surface position of the center of the touch
  326. * contact area. The units are device-dependent.
  327. * - For a mouse, reports the absolute X screen position of the mouse pointer.
  328. * The units are display pixels.
  329. * - For a trackball, reports the relative horizontal displacement of the trackball.
  330. * The value is normalized to a range from -1.0 (left) to 1.0 (right).
  331. * - For a joystick, reports the absolute X position of the joystick.
  332. * The value is normalized to a range from -1.0 (left) to 1.0 (right).
  333. */
  334. AMOTION_EVENT_AXIS_X = 0,
  335. /**
  336. * Axis constant: Y axis of a motion event.
  337. *
  338. * - For a touch screen, reports the absolute Y screen position of the center of
  339. * the touch contact area. The units are display pixels.
  340. * - For a touch pad, reports the absolute Y surface position of the center of the touch
  341. * contact area. The units are device-dependent.
  342. * - For a mouse, reports the absolute Y screen position of the mouse pointer.
  343. * The units are display pixels.
  344. * - For a trackball, reports the relative vertical displacement of the trackball.
  345. * The value is normalized to a range from -1.0 (up) to 1.0 (down).
  346. * - For a joystick, reports the absolute Y position of the joystick.
  347. * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
  348. */
  349. AMOTION_EVENT_AXIS_Y = 1,
  350. /**
  351. * Axis constant: Pressure axis of a motion event.
  352. *
  353. * - For a touch screen or touch pad, reports the approximate pressure applied to the surface
  354. * by a finger or other tool. The value is normalized to a range from
  355. * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
  356. * may be generated depending on the calibration of the input device.
  357. * - For a trackball, the value is set to 1 if the trackball button is pressed
  358. * or 0 otherwise.
  359. * - For a mouse, the value is set to 1 if the primary mouse button is pressed
  360. * or 0 otherwise.
  361. */
  362. AMOTION_EVENT_AXIS_PRESSURE = 2,
  363. /**
  364. * Axis constant: Size axis of a motion event.
  365. *
  366. * - For a touch screen or touch pad, reports the approximate size of the contact area in
  367. * relation to the maximum detectable size for the device. The value is normalized
  368. * to a range from 0 (smallest detectable size) to 1 (largest detectable size),
  369. * although it is not a linear scale. This value is of limited use.
  370. * To obtain calibrated size information, see
  371. * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}.
  372. */
  373. AMOTION_EVENT_AXIS_SIZE = 3,
  374. /**
  375. * Axis constant: TouchMajor axis of a motion event.
  376. *
  377. * - For a touch screen, reports the length of the major axis of an ellipse that
  378. * represents the touch area at the point of contact.
  379. * The units are display pixels.
  380. * - For a touch pad, reports the length of the major axis of an ellipse that
  381. * represents the touch area at the point of contact.
  382. * The units are device-dependent.
  383. */
  384. AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
  385. /**
  386. * Axis constant: TouchMinor axis of a motion event.
  387. *
  388. * - For a touch screen, reports the length of the minor axis of an ellipse that
  389. * represents the touch area at the point of contact.
  390. * The units are display pixels.
  391. * - For a touch pad, reports the length of the minor axis of an ellipse that
  392. * represents the touch area at the point of contact.
  393. * The units are device-dependent.
  394. *
  395. * When the touch is circular, the major and minor axis lengths will be equal to one another.
  396. */
  397. AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
  398. /**
  399. * Axis constant: ToolMajor axis of a motion event.
  400. *
  401. * - For a touch screen, reports the length of the major axis of an ellipse that
  402. * represents the size of the approaching finger or tool used to make contact.
  403. * - For a touch pad, reports the length of the major axis of an ellipse that
  404. * represents the size of the approaching finger or tool used to make contact.
  405. * The units are device-dependent.
  406. *
  407. * When the touch is circular, the major and minor axis lengths will be equal to one another.
  408. *
  409. * The tool size may be larger than the touch size since the tool may not be fully
  410. * in contact with the touch sensor.
  411. */
  412. AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
  413. /**
  414. * Axis constant: ToolMinor axis of a motion event.
  415. *
  416. * - For a touch screen, reports the length of the minor axis of an ellipse that
  417. * represents the size of the approaching finger or tool used to make contact.
  418. * - For a touch pad, reports the length of the minor axis of an ellipse that
  419. * represents the size of the approaching finger or tool used to make contact.
  420. * The units are device-dependent.
  421. *
  422. * When the touch is circular, the major and minor axis lengths will be equal to one another.
  423. *
  424. * The tool size may be larger than the touch size since the tool may not be fully
  425. * in contact with the touch sensor.
  426. */
  427. AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
  428. /**
  429. * Axis constant: Orientation axis of a motion event.
  430. *
  431. * - For a touch screen or touch pad, reports the orientation of the finger
  432. * or tool in radians relative to the vertical plane of the device.
  433. * An angle of 0 radians indicates that the major axis of contact is oriented
  434. * upwards, is perfectly circular or is of unknown orientation. A positive angle
  435. * indicates that the major axis of contact is oriented to the right. A negative angle
  436. * indicates that the major axis of contact is oriented to the left.
  437. * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
  438. * (finger pointing fully right).
  439. * - For a stylus, the orientation indicates the direction in which the stylus
  440. * is pointing in relation to the vertical axis of the current orientation of the screen.
  441. * The range is from -PI radians to PI radians, where 0 is pointing up,
  442. * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
  443. * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}.
  444. */
  445. AMOTION_EVENT_AXIS_ORIENTATION = 8,
  446. /**
  447. * Axis constant: Vertical Scroll axis of a motion event.
  448. *
  449. * - For a mouse, reports the relative movement of the vertical scroll wheel.
  450. * The value is normalized to a range from -1.0 (down) to 1.0 (up).
  451. *
  452. * This axis should be used to scroll views vertically.
  453. */
  454. AMOTION_EVENT_AXIS_VSCROLL = 9,
  455. /**
  456. * Axis constant: Horizontal Scroll axis of a motion event.
  457. *
  458. * - For a mouse, reports the relative movement of the horizontal scroll wheel.
  459. * The value is normalized to a range from -1.0 (left) to 1.0 (right).
  460. *
  461. * This axis should be used to scroll views horizontally.
  462. */
  463. AMOTION_EVENT_AXIS_HSCROLL = 10,
  464. /**
  465. * Axis constant: Z axis of a motion event.
  466. *
  467. * - For a joystick, reports the absolute Z position of the joystick.
  468. * The value is normalized to a range from -1.0 (high) to 1.0 (low).
  469. * <em>On game pads with two analog joysticks, this axis is often reinterpreted
  470. * to report the absolute X position of the second joystick instead.</em>
  471. */
  472. AMOTION_EVENT_AXIS_Z = 11,
  473. /**
  474. * Axis constant: X Rotation axis of a motion event.
  475. *
  476. * - For a joystick, reports the absolute rotation angle about the X axis.
  477. * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
  478. */
  479. AMOTION_EVENT_AXIS_RX = 12,
  480. /**
  481. * Axis constant: Y Rotation axis of a motion event.
  482. *
  483. * - For a joystick, reports the absolute rotation angle about the Y axis.
  484. * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
  485. */
  486. AMOTION_EVENT_AXIS_RY = 13,
  487. /**
  488. * Axis constant: Z Rotation axis of a motion event.
  489. *
  490. * - For a joystick, reports the absolute rotation angle about the Z axis.
  491. * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
  492. * On game pads with two analog joysticks, this axis is often reinterpreted
  493. * to report the absolute Y position of the second joystick instead.
  494. */
  495. AMOTION_EVENT_AXIS_RZ = 14,
  496. /**
  497. * Axis constant: Hat X axis of a motion event.
  498. *
  499. * - For a joystick, reports the absolute X position of the directional hat control.
  500. * The value is normalized to a range from -1.0 (left) to 1.0 (right).
  501. */
  502. AMOTION_EVENT_AXIS_HAT_X = 15,
  503. /**
  504. * Axis constant: Hat Y axis of a motion event.
  505. *
  506. * - For a joystick, reports the absolute Y position of the directional hat control.
  507. * The value is normalized to a range from -1.0 (up) to 1.0 (down).
  508. */
  509. AMOTION_EVENT_AXIS_HAT_Y = 16,
  510. /**
  511. * Axis constant: Left Trigger axis of a motion event.
  512. *
  513. * - For a joystick, reports the absolute position of the left trigger control.
  514. * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
  515. */
  516. AMOTION_EVENT_AXIS_LTRIGGER = 17,
  517. /**
  518. * Axis constant: Right Trigger axis of a motion event.
  519. *
  520. * - For a joystick, reports the absolute position of the right trigger control.
  521. * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
  522. */
  523. AMOTION_EVENT_AXIS_RTRIGGER = 18,
  524. /**
  525. * Axis constant: Throttle axis of a motion event.
  526. *
  527. * - For a joystick, reports the absolute position of the throttle control.
  528. * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
  529. */
  530. AMOTION_EVENT_AXIS_THROTTLE = 19,
  531. /**
  532. * Axis constant: Rudder axis of a motion event.
  533. *
  534. * - For a joystick, reports the absolute position of the rudder control.
  535. * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
  536. */
  537. AMOTION_EVENT_AXIS_RUDDER = 20,
  538. /**
  539. * Axis constant: Wheel axis of a motion event.
  540. *
  541. * - For a joystick, reports the absolute position of the steering wheel control.
  542. * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
  543. */
  544. AMOTION_EVENT_AXIS_WHEEL = 21,
  545. /**
  546. * Axis constant: Gas axis of a motion event.
  547. *
  548. * - For a joystick, reports the absolute position of the gas (accelerator) control.
  549. * The value is normalized to a range from 0.0 (no acceleration)
  550. * to 1.0 (maximum acceleration).
  551. */
  552. AMOTION_EVENT_AXIS_GAS = 22,
  553. /**
  554. * Axis constant: Brake axis of a motion event.
  555. *
  556. * - For a joystick, reports the absolute position of the brake control.
  557. * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
  558. */
  559. AMOTION_EVENT_AXIS_BRAKE = 23,
  560. /**
  561. * Axis constant: Distance axis of a motion event.
  562. *
  563. * - For a stylus, reports the distance of the stylus from the screen.
  564. * A value of 0.0 indicates direct contact and larger values indicate increasing
  565. * distance from the surface.
  566. */
  567. AMOTION_EVENT_AXIS_DISTANCE = 24,
  568. /**
  569. * Axis constant: Tilt axis of a motion event.
  570. *
  571. * - For a stylus, reports the tilt angle of the stylus in radians where
  572. * 0 radians indicates that the stylus is being held perpendicular to the
  573. * surface, and PI/2 radians indicates that the stylus is being held flat
  574. * against the surface.
  575. */
  576. AMOTION_EVENT_AXIS_TILT = 25,
  577. /**
  578. * Axis constant: Generic 1 axis of a motion event.
  579. * The interpretation of a generic axis is device-specific.
  580. */
  581. AMOTION_EVENT_AXIS_GENERIC_1 = 32,
  582. /**
  583. * Axis constant: Generic 2 axis of a motion event.
  584. * The interpretation of a generic axis is device-specific.
  585. */
  586. AMOTION_EVENT_AXIS_GENERIC_2 = 33,
  587. /**
  588. * Axis constant: Generic 3 axis of a motion event.
  589. * The interpretation of a generic axis is device-specific.
  590. */
  591. AMOTION_EVENT_AXIS_GENERIC_3 = 34,
  592. /**
  593. * Axis constant: Generic 4 axis of a motion event.
  594. * The interpretation of a generic axis is device-specific.
  595. */
  596. AMOTION_EVENT_AXIS_GENERIC_4 = 35,
  597. /**
  598. * Axis constant: Generic 5 axis of a motion event.
  599. * The interpretation of a generic axis is device-specific.
  600. */
  601. AMOTION_EVENT_AXIS_GENERIC_5 = 36,
  602. /**
  603. * Axis constant: Generic 6 axis of a motion event.
  604. * The interpretation of a generic axis is device-specific.
  605. */
  606. AMOTION_EVENT_AXIS_GENERIC_6 = 37,
  607. /**
  608. * Axis constant: Generic 7 axis of a motion event.
  609. * The interpretation of a generic axis is device-specific.
  610. */
  611. AMOTION_EVENT_AXIS_GENERIC_7 = 38,
  612. /**
  613. * Axis constant: Generic 8 axis of a motion event.
  614. * The interpretation of a generic axis is device-specific.
  615. */
  616. AMOTION_EVENT_AXIS_GENERIC_8 = 39,
  617. /**
  618. * Axis constant: Generic 9 axis of a motion event.
  619. * The interpretation of a generic axis is device-specific.
  620. */
  621. AMOTION_EVENT_AXIS_GENERIC_9 = 40,
  622. /**
  623. * Axis constant: Generic 10 axis of a motion event.
  624. * The interpretation of a generic axis is device-specific.
  625. */
  626. AMOTION_EVENT_AXIS_GENERIC_10 = 41,
  627. /**
  628. * Axis constant: Generic 11 axis of a motion event.
  629. * The interpretation of a generic axis is device-specific.
  630. */
  631. AMOTION_EVENT_AXIS_GENERIC_11 = 42,
  632. /**
  633. * Axis constant: Generic 12 axis of a motion event.
  634. * The interpretation of a generic axis is device-specific.
  635. */
  636. AMOTION_EVENT_AXIS_GENERIC_12 = 43,
  637. /**
  638. * Axis constant: Generic 13 axis of a motion event.
  639. * The interpretation of a generic axis is device-specific.
  640. */
  641. AMOTION_EVENT_AXIS_GENERIC_13 = 44,
  642. /**
  643. * Axis constant: Generic 14 axis of a motion event.
  644. * The interpretation of a generic axis is device-specific.
  645. */
  646. AMOTION_EVENT_AXIS_GENERIC_14 = 45,
  647. /**
  648. * Axis constant: Generic 15 axis of a motion event.
  649. * The interpretation of a generic axis is device-specific.
  650. */
  651. AMOTION_EVENT_AXIS_GENERIC_15 = 46,
  652. /**
  653. * Axis constant: Generic 16 axis of a motion event.
  654. * The interpretation of a generic axis is device-specific.
  655. */
  656. AMOTION_EVENT_AXIS_GENERIC_16 = 47,
  657. // NOTE: If you add a new axis here you must also add it to several other files.
  658. // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
  659. };
  660. /**
  661. * Constants that identify buttons that are associated with motion events.
  662. * Refer to the documentation on the MotionEvent class for descriptions of each button.
  663. */
  664. enum {
  665. /** primary */
  666. AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
  667. /** secondary */
  668. AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
  669. /** tertiary */
  670. AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
  671. /** back */
  672. AMOTION_EVENT_BUTTON_BACK = 1 << 3,
  673. /** forward */
  674. AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
  675. AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
  676. AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
  677. };
  678. /**
  679. * Constants that identify tool types.
  680. * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
  681. */
  682. enum {
  683. /** unknown */
  684. AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
  685. /** finger */
  686. AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
  687. /** stylus */
  688. AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
  689. /** mouse */
  690. AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
  691. /** eraser */
  692. AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
  693. };
  694. /**
  695. * Input source masks.
  696. *
  697. * Refer to the documentation on android.view.InputDevice for more details about input sources
  698. * and their correct interpretation.
  699. */
  700. enum {
  701. /** mask */
  702. AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
  703. /** none */
  704. AINPUT_SOURCE_CLASS_NONE = 0x00000000,
  705. /** button */
  706. AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
  707. /** pointer */
  708. AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
  709. /** navigation */
  710. AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
  711. /** position */
  712. AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
  713. /** joystick */
  714. AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
  715. };
  716. /**
  717. * Input sources.
  718. */
  719. enum {
  720. /** unknown */
  721. AINPUT_SOURCE_UNKNOWN = 0x00000000,
  722. /** keyboard */
  723. AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
  724. /** dpad */
  725. AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
  726. /** gamepad */
  727. AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
  728. /** touchscreen */
  729. AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
  730. /** mouse */
  731. AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
  732. /** stylus */
  733. AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
  734. /** bluetooth stylus */
  735. AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
  736. /** trackball */
  737. AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
  738. /** touchpad */
  739. AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
  740. /** navigation */
  741. AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
  742. /** gesture sensor (?) */
  743. AINPUT_SOURCE_GESTURE_SENSOR = 0x00400000 | AINPUT_SOURCE_CLASS_NONE,
  744. /** joystick */
  745. AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
  746. /** any */
  747. AINPUT_SOURCE_ANY = 0xffffff00,
  748. };
  749. /**
  750. * Keyboard types.
  751. *
  752. * Refer to the documentation on android.view.InputDevice for more details.
  753. */
  754. enum {
  755. /** none */
  756. AINPUT_KEYBOARD_TYPE_NONE = 0,
  757. /** non alphabetic */
  758. AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
  759. /** alphabetic */
  760. AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
  761. };
  762. /**
  763. * Constants used to retrieve information about the range of motion for a particular
  764. * coordinate of a motion event.
  765. *
  766. * Refer to the documentation on android.view.InputDevice for more details about input sources
  767. * and their correct interpretation.
  768. *
  769. * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead.
  770. */
  771. enum {
  772. /** x */
  773. AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
  774. /** y */
  775. AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
  776. /** pressure */
  777. AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
  778. /** size */
  779. AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
  780. /** touch major */
  781. AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
  782. /** touch minor */
  783. AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
  784. /** tool major */
  785. AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
  786. /** tool minor */
  787. AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
  788. /** orientation */
  789. AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
  790. };
  791. /**
  792. * Input event accessors.
  793. *
  794. * Note that most functions can only be used on input events that are of a given type.
  795. * Calling these functions on input events of other types will yield undefined behavior.
  796. */
  797. /*** Accessors for all input events. ***/
  798. /** Get the input event type. */
  799. int32_t AInputEvent_getType(const AInputEvent* event);
  800. /** Get the id for the device that an input event came from.
  801. *
  802. * Input events can be generated by multiple different input devices.
  803. * Use the input device id to obtain information about the input
  804. * device that was responsible for generating a particular event.
  805. *
  806. * An input device id of 0 indicates that the event didn't come from a physical device;
  807. * other numbers are arbitrary and you shouldn't depend on the values.
  808. * Use the provided input device query API to obtain information about input devices.
  809. */
  810. int32_t AInputEvent_getDeviceId(const AInputEvent* event);
  811. /** Get the input event source. */
  812. int32_t AInputEvent_getSource(const AInputEvent* event);
  813. /*** Accessors for key events only. ***/
  814. /** Get the key event action. */
  815. int32_t AKeyEvent_getAction(const AInputEvent* key_event);
  816. /** Get the key event flags. */
  817. int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
  818. /**
  819. * Get the key code of the key event.
  820. * This is the physical key that was pressed, not the Unicode character.
  821. */
  822. int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
  823. /**
  824. * Get the hardware key id of this key event.
  825. * These values are not reliable and vary from device to device.
  826. */
  827. int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
  828. /** Get the meta key state. */
  829. int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
  830. /**
  831. * Get the repeat count of the event.
  832. * For both key up an key down events, this is the number of times the key has
  833. * repeated with the first down starting at 0 and counting up from there. For
  834. * multiple key events, this is the number of down/up pairs that have occurred.
  835. */
  836. int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
  837. /**
  838. * Get the time of the most recent key down event, in the
  839. * java.lang.System.nanoTime() time base. If this is a down event,
  840. * this will be the same as eventTime.
  841. * Note that when chording keys, this value is the down time of the most recently
  842. * pressed key, which may not be the same physical key of this event.
  843. */
  844. int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
  845. /**
  846. * Get the time this event occurred, in the
  847. * java.lang.System.nanoTime() time base.
  848. */
  849. int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
  850. /*** Accessors for motion events only. ***/
  851. /** Get the combined motion event action code and pointer index. */
  852. int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
  853. /** Get the motion event flags. */
  854. int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
  855. /**
  856. * Get the state of any meta / modifier keys that were in effect when the
  857. * event was generated.
  858. */
  859. int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
  860. /** Get the button state of all buttons that are pressed. */
  861. int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
  862. /**
  863. * Get a bitfield indicating which edges, if any, were touched by this motion event.
  864. * For touch events, clients can use this to determine if the user's finger was
  865. * touching the edge of the display.
  866. */
  867. int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
  868. /**
  869. * Get the time when the user originally pressed down to start a stream of
  870. * position events, in the java.lang.System.nanoTime() time base.
  871. */
  872. int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
  873. /**
  874. * Get the time when this specific event was generated,
  875. * in the java.lang.System.nanoTime() time base.
  876. */
  877. int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
  878. /**
  879. * Get the X coordinate offset.
  880. * For touch events on the screen, this is the delta that was added to the raw
  881. * screen coordinates to adjust for the absolute position of the containing windows
  882. * and views.
  883. */
  884. float AMotionEvent_getXOffset(const AInputEvent* motion_event);
  885. /**
  886. * Get the Y coordinate offset.
  887. * For touch events on the screen, this is the delta that was added to the raw
  888. * screen coordinates to adjust for the absolute position of the containing windows
  889. * and views.
  890. */
  891. float AMotionEvent_getYOffset(const AInputEvent* motion_event);
  892. /**
  893. * Get the precision of the X coordinates being reported.
  894. * You can multiply this number with an X coordinate sample to find the
  895. * actual hardware value of the X coordinate.
  896. */
  897. float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
  898. /**
  899. * Get the precision of the Y coordinates being reported.
  900. * You can multiply this number with a Y coordinate sample to find the
  901. * actual hardware value of the Y coordinate.
  902. */
  903. float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
  904. /**
  905. * Get the number of pointers of data contained in this event.
  906. * Always >= 1.
  907. */
  908. size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
  909. /**
  910. * Get the pointer identifier associated with a particular pointer
  911. * data index in this event. The identifier tells you the actual pointer
  912. * number associated with the data, accounting for individual pointers
  913. * going up and down since the start of the current gesture.
  914. */
  915. int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
  916. /**
  917. * Get the tool type of a pointer for the given pointer index.
  918. * The tool type indicates the type of tool used to make contact such as a
  919. * finger or stylus, if known.
  920. */
  921. int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
  922. /**
  923. * Get the original raw X coordinate of this event.
  924. * For touch events on the screen, this is the original location of the event
  925. * on the screen, before it had been adjusted for the containing window
  926. * and views.
  927. */
  928. float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
  929. /**
  930. * Get the original raw X coordinate of this event.
  931. * For touch events on the screen, this is the original location of the event
  932. * on the screen, before it had been adjusted for the containing window
  933. * and views.
  934. */
  935. float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
  936. /**
  937. * Get the current X coordinate of this event for the given pointer index.
  938. * Whole numbers are pixels; the value may have a fraction for input devices
  939. * that are sub-pixel precise.
  940. */
  941. float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
  942. /**
  943. * Get the current Y coordinate of this event for the given pointer index.
  944. * Whole numbers are pixels; the value may have a fraction for input devices
  945. * that are sub-pixel precise.
  946. */
  947. float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
  948. /**
  949. * Get the current pressure of this event for the given pointer index.
  950. * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
  951. * although values higher than 1 may be generated depending on the calibration of
  952. * the input device.
  953. */
  954. float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
  955. /**
  956. * Get the current scaled value of the approximate size for the given pointer index.
  957. * This represents some approximation of the area of the screen being
  958. * pressed; the actual value in pixels corresponding to the
  959. * touch is normalized with the device specific range of values
  960. * and scaled to a value between 0 and 1. The value of size can be used to
  961. * determine fat touch events.
  962. */
  963. float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
  964. /**
  965. * Get the current length of the major axis of an ellipse that describes the touch area
  966. * at the point of contact for the given pointer index.
  967. */
  968. float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
  969. /**
  970. * Get the current length of the minor axis of an ellipse that describes the touch area
  971. * at the point of contact for the given pointer index.
  972. */
  973. float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
  974. /**
  975. * Get the current length of the major axis of an ellipse that describes the size
  976. * of the approaching tool for the given pointer index.
  977. * The tool area represents the estimated size of the finger or pen that is
  978. * touching the device independent of its actual touch area at the point of contact.
  979. */
  980. float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
  981. /**
  982. * Get the current length of the minor axis of an ellipse that describes the size
  983. * of the approaching tool for the given pointer index.
  984. * The tool area represents the estimated size of the finger or pen that is
  985. * touching the device independent of its actual touch area at the point of contact.
  986. */
  987. float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
  988. /**
  989. * Get the current orientation of the touch area and tool area in radians clockwise from
  990. * vertical for the given pointer index.
  991. * An angle of 0 degrees indicates that the major axis of contact is oriented
  992. * upwards, is perfectly circular or is of unknown orientation. A positive angle
  993. * indicates that the major axis of contact is oriented to the right. A negative angle
  994. * indicates that the major axis of contact is oriented to the left.
  995. * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
  996. * (finger pointing fully right).
  997. */
  998. float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
  999. /** Get the value of the request axis for the given pointer index. */
  1000. float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
  1001. int32_t axis, size_t pointer_index);
  1002. /**
  1003. * Get the number of historical points in this event. These are movements that
  1004. * have occurred between this event and the previous event. This only applies
  1005. * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
  1006. * Historical samples are indexed from oldest to newest.
  1007. */
  1008. size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
  1009. /**
  1010. * Get the time that a historical movement occurred between this event and
  1011. * the previous event, in the java.lang.System.nanoTime() time base.
  1012. */
  1013. int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
  1014. size_t history_index);
  1015. /**
  1016. * Get the historical raw X coordinate of this event for the given pointer index that
  1017. * occurred between this event and the previous motion event.
  1018. * For touch events on the screen, this is the original location of the event
  1019. * on the screen, before it had been adjusted for the containing window
  1020. * and views.
  1021. * Whole numbers are pixels; the value may have a fraction for input devices
  1022. * that are sub-pixel precise.
  1023. */
  1024. float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
  1025. size_t history_index);
  1026. /**
  1027. * Get the historical raw Y coordinate of this event for the given pointer index that
  1028. * occurred between this event and the previous motion event.
  1029. * For touch events on the screen, this is the original location of the event
  1030. * on the screen, before it had been adjusted for the containing window
  1031. * and views.
  1032. * Whole numbers are pixels; the value may have a fraction for input devices
  1033. * that are sub-pixel precise.
  1034. */
  1035. float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
  1036. size_t history_index);
  1037. /**
  1038. * Get the historical X coordinate of this event for the given pointer index that
  1039. * occurred between this event and the previous motion event.
  1040. * Whole numbers are pixels; the value may have a fraction for input devices
  1041. * that are sub-pixel precise.
  1042. */
  1043. float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
  1044. size_t history_index);
  1045. /**
  1046. * Get the historical Y coordinate of this event for the given pointer index that
  1047. * occurred between this event and the previous motion event.
  1048. * Whole numbers are pixels; the value may have a fraction for input devices
  1049. * that are sub-pixel precise.
  1050. */
  1051. float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
  1052. size_t history_index);
  1053. /**
  1054. * Get the historical pressure of this event for the given pointer index that
  1055. * occurred between this event and the previous motion event.
  1056. * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
  1057. * although values higher than 1 may be generated depending on the calibration of
  1058. * the input device.
  1059. */
  1060. float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
  1061. size_t history_index);
  1062. /**
  1063. * Get the current scaled value of the approximate size for the given pointer index that
  1064. * occurred between this event and the previous motion event.
  1065. * This represents some approximation of the area of the screen being
  1066. * pressed; the actual value in pixels corresponding to the
  1067. * touch is normalized with the device specific range of values
  1068. * and scaled to a value between 0 and 1. The value of size can be used to
  1069. * determine fat touch events.
  1070. */
  1071. float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
  1072. size_t history_index);
  1073. /**
  1074. * Get the historical length of the major axis of an ellipse that describes the touch area
  1075. * at the point of contact for the given pointer index that
  1076. * occurred between this event and the previous motion event.
  1077. */
  1078. float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
  1079. size_t history_index);
  1080. /**
  1081. * Get the historical length of the minor axis of an ellipse that describes the touch area
  1082. * at the point of contact for the given pointer index that
  1083. * occurred between this event and the previous motion event.
  1084. */
  1085. float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
  1086. size_t history_index);
  1087. /**
  1088. * Get the historical length of the major axis of an ellipse that describes the size
  1089. * of the approaching tool for the given pointer index that
  1090. * occurred between this event and the previous motion event.
  1091. * The tool area represents the estimated size of the finger or pen that is
  1092. * touching the device independent of its actual touch area at the point of contact.
  1093. */
  1094. float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
  1095. size_t history_index);
  1096. /**
  1097. * Get the historical length of the minor axis of an ellipse that describes the size
  1098. * of the approaching tool for the given pointer index that
  1099. * occurred between this event and the previous motion event.
  1100. * The tool area represents the estimated size of the finger or pen that is
  1101. * touching the device independent of its actual touch area at the point of contact.
  1102. */
  1103. float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
  1104. size_t history_index);
  1105. /**
  1106. * Get the historical orientation of the touch area and tool area in radians clockwise from
  1107. * vertical for the given pointer index that
  1108. * occurred between this event and the previous motion event.
  1109. * An angle of 0 degrees indicates that the major axis of contact is oriented
  1110. * upwards, is perfectly circular or is of unknown orientation. A positive angle
  1111. * indicates that the major axis of contact is oriented to the right. A negative angle
  1112. * indicates that the major axis of contact is oriented to the left.
  1113. * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
  1114. * (finger pointing fully right).
  1115. */
  1116. float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
  1117. size_t history_index);
  1118. /**
  1119. * Get the historical value of the request axis for the given pointer index
  1120. * that occurred between this event and the previous motion event.
  1121. */
  1122. float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
  1123. int32_t axis, size_t pointer_index, size_t history_index);
  1124. struct AInputQueue;
  1125. /**
  1126. * Input queue
  1127. *
  1128. * An input queue is the facility through which you retrieve input
  1129. * events.
  1130. */
  1131. typedef struct AInputQueue AInputQueue;
  1132. /**
  1133. * Add this input queue to a looper for processing. See
  1134. * ALooper_addFd() for information on the ident, callback, and data params.
  1135. */
  1136. void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
  1137. int ident, ALooper_callbackFunc callback, void* data);
  1138. /**
  1139. * Remove the input queue from the looper it is currently attached to.
  1140. */
  1141. void AInputQueue_detachLooper(AInputQueue* queue);
  1142. /**
  1143. * Returns true if there are one or more events available in the
  1144. * input queue. Returns 1 if the queue has events; 0 if
  1145. * it does not have events; and a negative value if there is an error.
  1146. */
  1147. int32_t AInputQueue_hasEvents(AInputQueue* queue);
  1148. /**
  1149. * Returns the next available event from the queue. Returns a negative
  1150. * value if no events are available or an error has occurred.
  1151. */
  1152. int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
  1153. /**
  1154. * Sends the key for standard pre-dispatching -- that is, possibly deliver
  1155. * it to the current IME to be consumed before the app. Returns 0 if it
  1156. * was not pre-dispatched, meaning you can process it right now. If non-zero
  1157. * is returned, you must abandon the current event processing and allow the
  1158. * event to appear again in the event queue (if it does not get consumed during
  1159. * pre-dispatching).
  1160. */
  1161. int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
  1162. /**
  1163. * Report that dispatching has finished with the given event.
  1164. * This must be called after receiving an event with AInputQueue_get_event().
  1165. */
  1166. void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
  1167. #ifdef __cplusplus
  1168. }
  1169. #endif
  1170. #endif // _ANDROID_INPUT_H
  1171. /** @} */