Debian Codegraph @

src/base/android/castleandroidinternalinput.pas

raw
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 { @exclude Internal for the engine. }
18 unit CastleAndroidInternalInput;
19
20 {$I castleconf.inc}
21
22 interface
23
24 uses ctypes, CastleAndroidInternalLooper, CastleAndroidInternalKeycodes;
25
26 (******************************************************************
27 *
28 * IMPORTANT NOTICE:
29 *
30 * This file is part of Android's set of stable system headers
31 * exposed by the Android NDK (Native Development Kit).
32 *
33 * Third-party source AND binary code relies on the definitions
34 * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
35 *
36 * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
37 * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
38 * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
39 * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
40 *)
41
42 (*
43 * Structures and functions to receive and process input events in
44 * native code.
45 *
46 * NOTE: These functions MUST be implemented by /system/lib/libui.so
47 *)
48
49 (*
50 * Key states (may be returned by queries about the current state of a
51 * particular key code, scan code or switch).
52 *)
53 const
54 (* The key state is unknown or the requested key itself is not supported. *)
55 AKEY_STATE_UNKNOWN = - 1;
56 (* The key is up. *)
57 AKEY_STATE_UP = 0;
58 (* The key is down. *)
59 AKEY_STATE_DOWN = 1;
60 (* The key is down but is a virtual key press that is being emulated by the system. *)
61 AKEY_STATE_VIRTUAL = 2;
62
63 (*
64 * Meta key / modifer state.
65 *)
66 const
67 (* No meta keys are pressed. *)
68 AMETA_NONE = 0;
69 (* This mask is used to check whether one of the ALT meta keys is pressed. *)
70 AMETA_ALT_ON = $02;
71 (* This mask is used to check whether the left ALT meta key is pressed. *)
72 AMETA_ALT_LEFT_ON = $10;
73 (* This mask is used to check whether the right ALT meta key is pressed. *)
74 AMETA_ALT_RIGHT_ON = $20;
75 (* This mask is used to check whether one of the SHIFT meta keys is pressed. *)
76 AMETA_SHIFT_ON = $01;
77 (* This mask is used to check whether the left SHIFT meta key is pressed. *)
78 AMETA_SHIFT_LEFT_ON = $40;
79 (* This mask is used to check whether the right SHIFT meta key is pressed. *)
80 AMETA_SHIFT_RIGHT_ON = $80;
81 (* This mask is used to check whether the SYM meta key is pressed. *)
82 AMETA_SYM_ON = $04;
83
84 (*
85 * Input events.
86 *
87 * Input events are opaque structures. Use the provided accessors functions to
88 * read their properties.
89 *)
90 type
91 PPAInputEvent = ^PAInputEvent;
92 PAInputEvent = ^AInputEvent;
93
94 AInputEvent = record end;
95
96 (*
97 * Input event types.
98 *)
99 const
100 (* Indicates that the input event is a key event. *)
101 AINPUT_EVENT_TYPE_KEY = 1;
102 (* Indicates that the input event is a motion event. *)
103 AINPUT_EVENT_TYPE_MOTION = 2;
104
105 (*
106 * Key event actions.
107 *)
108 const
109 (* The key has been pressed down. *)
110 AKEY_EVENT_ACTION_DOWN = 0;
111 (* The key has been released. *)
112 AKEY_EVENT_ACTION_UP = 1;
113 (* Multiple duplicate key events have occurred in a row, or a complex string is
114 * being delivered. The repeat_count property of the key event contains the number
115 * of times the given key code should be executed.
116 *)
117 AKEY_EVENT_ACTION_MULTIPLE = 2;
118
119 (*
120 * Key event flags.
121 *)
122 const
123 (* This mask is set if the device woke because of this key event. *)
124 AKEY_EVENT_FLAG_WOKE_HERE = $1;
125 (* This mask is set if the key event was generated by a software keyboard. *)
126 AKEY_EVENT_FLAG_SOFT_KEYBOARD = $2;
127 (* This mask is set if we don't want the key event to cause us to leave touch mode. *)
128 AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = $4;
129 (* This mask is set if an event was known to come from a trusted part
130 * of the system. That is, the event is known to come from the user,
131 * and could not have been spoofed by a third party component. *)
132 AKEY_EVENT_FLAG_FROM_SYSTEM = $8;
133 (* This mask is used for compatibility, to identify enter keys that are
134 * coming from an IME whose enter key has been auto-labelled "next" or
135 * "done". This allows TextView to dispatch these as normal enter keys
136 * for old applications, but still do the appropriate action when
137 * receiving them. *)
138 AKEY_EVENT_FLAG_EDITOR_ACTION = $10;
139 (* When associated with up key events, this indicates that the key press
140 * has been canceled. Typically this is used with virtual touch screen
141 * keys, where the user can slide from the virtual key area on to the
142 * display: in that case, the application will receive a canceled up
143 * event and should not perform the action normally associated with the
144 * key. Note that for this to work, the application can not perform an
145 * action for a key until it receives an up or the long press timeout has
146 * expired. *)
147 AKEY_EVENT_FLAG_CANCELED = $20;
148 (* This key event was generated by a virtual (on-screen) hard key area.
149 * Typically this is an area of the touchscreen, outside of the regular
150 * display, dedicated to "hardware" buttons. *)
151 AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = $40;
152 (* This flag is set for the first key repeat that occurs after the
153 * long press timeout. *)
154 AKEY_EVENT_FLAG_LONG_PRESS = $80;
155 (* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
156 * press action was executed while it was down. *)
157 AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = $100;
158 (* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
159 * tracked from its initial down. That is, somebody requested that tracking
160 * started on the key down and a long press has not caused
161 * the tracking to be canceled. *)
162 AKEY_EVENT_FLAG_TRACKING = $200;
163
164
165 (*
166 * Motion event actions.
167 *)
168
169 (* Bit shift for the action bits holding the pointer index as
170 * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
171 *)
172 const
173 AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT = 8;
174
175 const
176 (* Bit mask of the parts of the action code that are the action itself.
177 *)
178 AMOTION_EVENT_ACTION_MASK = $ff;
179 (* Bits in the action code that represent a pointer index, used with
180 * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
181 * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
182 * index where the data for the pointer going up or down can be found.
183 *)
184 AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = $ff00;
185 (* A pressed gesture has started, the motion contains the initial starting location.
186 *)
187 AMOTION_EVENT_ACTION_DOWN = 0;
188 (* A pressed gesture has finished, the motion contains the final release location
189 * as well as any intermediate points since the last down or move event.
190 *)
191 AMOTION_EVENT_ACTION_UP = 1;
192 (* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
193 * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
194 * any intermediate points since the last down or move event.
195 *)
196 AMOTION_EVENT_ACTION_MOVE = 2;
197 (* The current gesture has been aborted.
198 * You will not receive any more points in it. You should treat this as
199 * an up event, but not perform any action that you normally would.
200 *)
201 AMOTION_EVENT_ACTION_CANCEL = 3;
202 (* A movement has happened outside of the normal bounds of the UI element.
203 * This does not provide a full gesture, but only the initial location of the movement/touch.
204 *)
205 AMOTION_EVENT_ACTION_OUTSIDE = 4;
206 (* A non-primary pointer has gone down.
207 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
208 *)
209 AMOTION_EVENT_ACTION_POINTER_DOWN = 5;
210 (* A non-primary pointer has gone up.
211 * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
212 *)
213 AMOTION_EVENT_ACTION_POINTER_UP = 6;
214
215 (*
216 * Motion event flags.
217 *)
218
219 const
220 (* This flag indicates that the window that received this motion event is partly
221 * or wholly obscured by another visible window above it. This flag is set to true
222 * even if the event did not directly pass through the obscured area.
223 * A security sensitive application can check this flag to identify situations in which
224 * a malicious application may have covered up part of its content for the purpose
225 * of misleading the user or hijacking touches. An appropriate response might be
226 * to drop the suspect touches or to take additional precautions to confirm the user's
227 * actual intent.
228 *)
229 AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = $1;
230
231 (*
232 * Motion event edge touch flags.
233 *)
234
235 const
236 (* No edges intersected *)
237 AMOTION_EVENT_EDGE_FLAG_NONE = 0;
238 (* Flag indicating the motion event intersected the top edge of the screen. *)
239 AMOTION_EVENT_EDGE_FLAG_TOP = $01;
240 (* Flag indicating the motion event intersected the bottom edge of the screen. *)
241 AMOTION_EVENT_EDGE_FLAG_BOTTOM = $02;
242 (* Flag indicating the motion event intersected the left edge of the screen. *)
243 AMOTION_EVENT_EDGE_FLAG_LEFT = $04;
244 (* Flag indicating the motion event intersected the right edge of the screen. *)
245 AMOTION_EVENT_EDGE_FLAG_RIGHT = $08;
246
247 (*
248 * Input sources.
249 *
250 * Refer to the documentation on android.view.InputDevice for more details about input sources
251 * and their correct interpretation.
252 *)
253
254 const
255 AINPUT_SOURCE_CLASS_MASK = $000000ff;
256 AINPUT_SOURCE_CLASS_BUTTON = $00000001;
257 AINPUT_SOURCE_CLASS_POINTER = $00000002;
258 AINPUT_SOURCE_CLASS_NAVIGATION = $00000004;
259 AINPUT_SOURCE_CLASS_POSITION = $00000008;
260
261 const
262 AINPUT_SOURCE_UNKNOWN = $00000000;
263 AINPUT_SOURCE_KEYBOARD = $00000100 or AINPUT_SOURCE_CLASS_BUTTON;
264 AINPUT_SOURCE_DPAD = $00000200 or AINPUT_SOURCE_CLASS_BUTTON;
265 AINPUT_SOURCE_TOUCHSCREEN = $00001000 or AINPUT_SOURCE_CLASS_POINTER;
266 AINPUT_SOURCE_MOUSE = $00002000 or AINPUT_SOURCE_CLASS_POINTER;
267 AINPUT_SOURCE_TRACKBALL = $00010000 or AINPUT_SOURCE_CLASS_NAVIGATION;
268 AINPUT_SOURCE_TOUCHPAD = $00100000 or AINPUT_SOURCE_CLASS_POSITION;
269 AINPUT_SOURCE_ANY = $ffffff00;
270
271 (*
272 * Keyboard types.
273 *
274 * Refer to the documentation on android.view.InputDevice for more details.
275 *)
276
277 const
278 AINPUT_KEYBOARD_TYPE_NONE = 0;
279 AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1;
280 AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2;
281
282 (*
283 * Constants used to retrieve information about the range of motion for a particular
284 * coordinate of a motion event.
285 *
286 * Refer to the documentation on android.view.InputDevice for more details about input sources
287 * and their correct interpretation.
288 *)
289
290 const
291 AINPUT_MOTION_RANGE_X = 0;
292 AINPUT_MOTION_RANGE_Y = 1;
293 AINPUT_MOTION_RANGE_PRESSURE = 2;
294 AINPUT_MOTION_RANGE_SIZE = 3;
295 AINPUT_MOTION_RANGE_TOUCH_MAJOR = 4;
296 AINPUT_MOTION_RANGE_TOUCH_MINOR = 5;
297 AINPUT_MOTION_RANGE_TOOL_MAJOR = 6;
298 AINPUT_MOTION_RANGE_TOOL_MINOR = 7;
299 AINPUT_MOTION_RANGE_ORIENTATION = 8;
300
301
302 (*
303 * Input event accessors.
304 *
305 * Note that most functions can only be used on input events that are of a given type.
306 * Calling these functions on input events of other types will yield undefined behavior.
307 *)
308
309 (*** Accessors for all input events. ** *)
310
311 (* Get the input event type. *)
312 function AInputEvent_getType(event: PAInputEvent): cint32; cdecl; external;
313
314 (* Get the id for the device that an input event came from.
315 *
316 * Input events can be generated by multiple different input devices.
317 * Use the input device id to obtain information about the input
318 * device that was responsible for generating a particular event.
319 *
320 * An input device id of 0 indicates that the event didn't come from a physical device;
321 * other numbers are arbitrary and you shouldn't depend on the values.
322 * Use the provided input device query API to obtain information about input devices.
323 *)
324 function AInputEvent_getDeviceId(event: PAInputEvent): cint32; cdecl; external;
325
326 (* Get the input event source. *)
327 function AInputEvent_getSource(event: PAInputEvent): cint32; cdecl; external;
328
329 (*** Accessors for key events only. ** *)
330
331 (* Get the key event action. *)
332
333 function AKeyEvent_getAction(key_event: PAInputEvent): cint32; cdecl; external;
334
335 (* Get the key event flags. *)
336
337 function AKeyEvent_getFlags(key_event: PAInputEvent): cint32; cdecl; external;
338
339 (* Get the key code of the key event.
340 * This is the physical key that was pressed, not the Unicode character. *)
341
342 function AKeyEvent_getKeyCode(key_event: PAInputEvent): cint32; cdecl; external;
343
344 (* Get the hardware key id of this key event.
345 * These values are not reliable and vary from device to device. *)
346
347 function AKeyEvent_getScanCode(key_event: PAInputEvent): cint32; cdecl; external;
348
349 (* Get the meta key state. *)
350
351 function AKeyEvent_getMetaState(key_event: PAInputEvent): cint32; cdecl; external;
352
353 (* Get the repeat count of the event.
354 * For both key up an key down events, this is the number of times the key has
355 * repeated with the first down starting at 0 and counting up from there. For
356 * multiple key events, this is the number of down/up pairs that have occurred. *)
357
358 function AKeyEvent_getRepeatCount(key_event: PAInputEvent): cint32; cdecl; external;
359
360 (* Get the time of the most recent key down event, in the
361 * java.lang.System.nanoTime() time base. If this is a down event,
362 * this will be the same as eventTime.
363 * Note that when chording keys, this value is the down time of the most recently
364 * pressed key, which may not be the same physical key of this event. *)
365
366 function AKeyEvent_getDownTime(key_event: PAInputEvent): cint64; cdecl; external;
367
368 (* Get the time this event occurred, in the
369 * java.lang.System.nanoTime() time base. *)
370
371 function AKeyEvent_getEventTime(key_event: PAInputEvent): cint64; cdecl; external;
372
373 (*** Accessors for motion events only. ** *)
374
375 (* Get the combined motion event action code and pointer index. *)
376
377 function AMotionEvent_getAction(motion_event: PAInputEvent): cint32; cdecl; external;
378
379 (* Get the motion event flags. *)
380
381 function AMotionEvent_getFlags(motion_event: PAInputEvent): cint32; cdecl; external;
382
383 (* Get the state of any meta / modifier keys that were in effect when the
384 * event was generated. *)
385
386 function AMotionEvent_getMetaState(motion_event: PAInputEvent): cint32; cdecl; external;
387
388 (* Get a bitfield indicating which edges, if any, were touched by this motion event.
389 * For touch events, clients can use this to determine if the user's finger was
390 * touching the edge of the display. *)
391
392 function AMotionEvent_getEdgeFlags(motion_event: PAInputEvent): cint32; cdecl; external;
393
394 (* Get the time when the user originally pressed down to start a stream of
395 * position events, in the java.lang.System.nanoTime() time base. *)
396
397 function AMotionEvent_getDownTime(motion_event: PAInputEvent): cint64; cdecl; external;
398
399 (* Get the time when this specific event was generated,
400 * in the java.lang.System.nanoTime() time base. *)
401
402 function AMotionEvent_getEventTime(motion_event: PAInputEvent): cint64; cdecl; external;
403
404 (* Get the X coordinate offset.
405 * For touch events on the screen, this is the delta that was added to the raw
406 * screen coordinates to adjust for the absolute position of the containing windows
407 * and views. *)
408
409 function AMotionEvent_getXOffset(motion_event: PAInputEvent): cfloat; cdecl; external;
410
411 (* Get the precision of the Y coordinates being reported.
412 * For touch events on the screen, this is the delta that was added to the raw
413 * screen coordinates to adjust for the absolute position of the containing windows
414 * and views. *)
415
416 function AMotionEvent_getYOffset(motion_event: PAInputEvent): cfloat; cdecl; external;
417
418 (* Get the precision of the X coordinates being reported.
419 * You can multiply this number with an X coordinate sample to find the
420 * actual hardware value of the X coordinate. *)
421
422 function AMotionEvent_getXPrecision(motion_event: PAInputEvent): cfloat; cdecl; external;
423
424 (* Get the precision of the Y coordinates being reported.
425 * You can multiply this number with a Y coordinate sample to find the
426 * actual hardware value of the Y coordinate. *)
427
428 function AMotionEvent_getYPrecision(motion_event: PAInputEvent): cfloat; cdecl; external;
429
430 (* Get the number of pointers of data contained in this event.
431 * Always >= 1. *)
432
433 function AMotionEvent_getPointerCount(motion_event: PAInputEvent): csize_t; cdecl; external;
434
435 (* Get the pointer identifier associated with a particular pointer
436 * data index is this event. The identifier tells you the actual pointer
437 * number associated with the data, accounting for individual pointers
438 * going up and down since the start of the current gesture. *)
439
440 function AMotionEvent_getPointerId(motion_event: PAInputEvent; pointer_index: csize_t): cint32; cdecl; external;
441
442 (* Get the original raw X coordinate of this event.
443 * For touch events on the screen, this is the original location of the event
444 * on the screen, before it had been adjusted for the containing window
445 * and views. *)
446
447 function AMotionEvent_getRawX(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
448
449 (* Get the original raw X coordinate of this event.
450 * For touch events on the screen, this is the original location of the event
451 * on the screen, before it had been adjusted for the containing window
452 * and views. *)
453
454 function AMotionEvent_getRawY(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
455
456 (* Get the current X coordinate of this event for the given pointer index.
457 * Whole numbers are pixels; the value may have a fraction for input devices
458 * that are sub-pixel precise. *)
459
460 function AMotionEvent_getX(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
461
462 (* Get the current Y coordinate of this event for the given pointer index.
463 * Whole numbers are pixels; the value may have a fraction for input devices
464 * that are sub-pixel precise. *)
465
466 function AMotionEvent_getY(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
467
468 (* Get the current pressure of this event for the given pointer index.
469 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
470 * however values higher than 1 may be generated depending on the calibration of
471 * the input device. *)
472
473 function AMotionEvent_getPressure(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
474
475 (* Get the current scaled value of the approximate size for the given pointer index.
476 * This represents some approximation of the area of the screen being
477 * pressed; the actual value in pixels corresponding to the
478 * touch is normalized with the device specific range of values
479 * and scaled to a value between 0 and 1. The value of size can be used to
480 * determine fat touch events. *)
481
482 function AMotionEvent_getSize(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
483
484 (* Get the current length of the major axis of an ellipse that describes the touch area
485 * at the point of contact for the given pointer index. *)
486
487 function AMotionEvent_getTouchMajor(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
488
489 (* Get the current length of the minor axis of an ellipse that describes the touch area
490 * at the point of contact for the given pointer index. *)
491
492 function AMotionEvent_getTouchMinor(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
493
494 (* Get the current length of the major axis of an ellipse that describes the size
495 * of the approaching tool for the given pointer index.
496 * The tool area represents the estimated size of the finger or pen that is
497 * touching the device independent of its actual touch area at the point of contact. *)
498
499 function AMotionEvent_getToolMajor(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
500
501 (* Get the current length of the minor axis of an ellipse that describes the size
502 * of the approaching tool for the given pointer index.
503 * The tool area represents the estimated size of the finger or pen that is
504 * touching the device independent of its actual touch area at the point of contact. *)
505
506 function AMotionEvent_getToolMinor(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
507
508 (* Get the current orientation of the touch area and tool area in radians clockwise from
509 * vertical for the given pointer index.
510 * An angle of 0 degrees indicates that the major axis of contact is oriented
511 * upwards, is perfectly circular or is of unknown orientation. A positive angle
512 * indicates that the major axis of contact is oriented to the right. A negative angle
513 * indicates that the major axis of contact is oriented to the left.
514 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
515 * (finger pointing fully right). *)
516
517 function AMotionEvent_getOrientation(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
518
519 (* Get the number of historical points in this event. These are movements that
520 * have occurred between this event and the previous event. This only applies
521 * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
522 * Historical samples are indexed from oldest to newest. *)
523
524 function AMotionEvent_getHistorySize(motion_event: PAInputEvent): csize_t; cdecl; external;
525
526 (* Get the time that a historical movement occurred between this event and
527 * the previous event, in the java.lang.System.nanoTime() time base. *)
528
529 function AMotionEvent_getHistoricalEventTime(motion_event: PAInputEvent; history_index: csize_t): cint64; cdecl; external;
530
531 (* Get the historical raw X coordinate of this event for the given pointer index that
532 * occurred between this event and the previous motion event.
533 * For touch events on the screen, this is the original location of the event
534 * on the screen, before it had been adjusted for the containing window
535 * and views.
536 * Whole numbers are pixels; the value may have a fraction for input devices
537 * that are sub-pixel precise. *)
538
539 function AMotionEvent_getHistoricalRawX(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
540
541 (* Get the historical raw Y coordinate of this event for the given pointer index that
542 * occurred between this event and the previous motion event.
543 * For touch events on the screen, this is the original location of the event
544 * on the screen, before it had been adjusted for the containing window
545 * and views.
546 * Whole numbers are pixels; the value may have a fraction for input devices
547 * that are sub-pixel precise. *)
548
549 function AMotionEvent_getHistoricalRawY(motion_event: PAInputEvent; pointer_index: csize_t): cfloat; cdecl; external;
550
551 (* Get the historical X coordinate of this event for the given pointer index that
552 * occurred between this event and the previous motion event.
553 * Whole numbers are pixels; the value may have a fraction for input devices
554 * that are sub-pixel precise. *)
555
556 function AMotionEvent_getHistoricalX(motion_event: PAInputEvent; pointer_index, history_index: csize_t): cfloat; cdecl; external;
557
558 (* Get the historical Y coordinate of this event for the given pointer index that
559 * occurred between this event and the previous motion event.
560 * Whole numbers are pixels; the value may have a fraction for input devices
561 * that are sub-pixel precise. *)
562
563 function AMotionEvent_getHistoricalY(motion_event: PAInputEvent; pointer_index, history_index: csize_t): cfloat; cdecl; external;
564
565 (* Get the historical pressure of this event for the given pointer index that
566 * occurred between this event and the previous motion event.
567 * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
568 * however values higher than 1 may be generated depending on the calibration of
569 * the input device. *)
570
571 function AMotionEvent_getHistoricalPressure(motion_event: PAInputEvent; pointer_index, history_index: csize_t): cfloat; cdecl; external;
572
573 (* Get the current scaled value of the approximate size for the given pointer index that
574 * occurred between this event and the previous motion event.
575 * This represents some approximation of the area of the screen being
576 * pressed; the actual value in pixels corresponding to the
577 * touch is normalized with the device specific range of values
578 * and scaled to a value between 0 and 1. The value of size can be used to
579 * determine fat touch events. *)
580
581 function AMotionEvent_getHistoricalSize(motion_event: PAInputEvent; pointer_index, history_index: csize_t): cfloat; cdecl; external;
582
583 (* Get the historical length of the major axis of an ellipse that describes the touch area
584 * at the point of contact for the given pointer index that
585 * occurred between this event and the previous motion event. *)
586
587 function AMotionEvent_getHistoricalTouchMajor(motion_event: PAInputEvent; pointer_index, history_index: csize_t): cfloat; cdecl; external;
588
589 (* Get the historical length of the minor axis of an ellipse that describes the touch area
590 * at the point of contact for the given pointer index that
591 * occurred between this event and the previous motion event. *)
592
593 function AMotionEvent_getHistoricalTouchMinor(motion_event: PAInputEvent; pointer_index, history_index: csize_t): cfloat; cdecl; external;
594
595 (* Get the historical length of the major axis of an ellipse that describes the size
596 * of the approaching tool for the given pointer index that
597 * occurred between this event and the previous motion event.
598 * The tool area represents the estimated size of the finger or pen that is
599 * touching the device independent of its actual touch area at the point of contact. *)
600
601 function AMotionEvent_getHistoricalToolMajor(motion_event: PAInputEvent; pointer_index, history_index: csize_t): cfloat; cdecl; external;
602
603 (* Get the historical length of the minor axis of an ellipse that describes the size
604 * of the approaching tool for the given pointer index that
605 * occurred between this event and the previous motion event.
606 * The tool area represents the estimated size of the finger or pen that is
607 * touching the device independent of its actual touch area at the point of contact. *)
608
609 function AMotionEvent_getHistoricalToolMinor(motion_event: PAInputEvent; pointer_index, history_index: csize_t): cfloat; cdecl; external;
610
611 (* Get the historical orientation of the touch area and tool area in radians clockwise from
612 * vertical for the given pointer index that
613 * occurred between this event and the previous motion event.
614 * An angle of 0 degrees indicates that the major axis of contact is oriented
615 * upwards, is perfectly circular or is of unknown orientation. A positive angle
616 * indicates that the major axis of contact is oriented to the right. A negative angle
617 * indicates that the major axis of contact is oriented to the left.
618 * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
619 * (finger pointing fully right). *)
620
621 function AMotionEvent_getHistoricalOrientation(motion_event: PAInputEvent; pointer_index, history_index: csize_t): cfloat; cdecl; external;
622
623
624 (*
625 * Input queue
626 *
627 * An input queue is the facility through which you retrieve input
628 * events.
629 *)
630
631 type
632 PAInputQueue = ^AInputQueue;
633 AInputQueue = record end;
634
635 (*
636 * Add this input queue to a looper for processing. See
637 * ALooper_addFd() for information on the ident, callback, and data params.
638 *)
639 procedure AInputQueue_attachLooper(queue: PAInputQueue; looper: PALooper; ident: cint; callback: ALooper_callbackFunc; data: Pointer); cdecl; external;
640
641 (*
642 * Remove the input queue from the looper it is currently attached to.
643 *)
644
645 procedure AInputQueue_detachLooper(queue: PAInputQueue); cdecl; external;
646
647 (*
648 * Returns true if there are one or more events available in the
649 * input queue. Returns 1 if the queue has events; 0 if
650 * it does not have events; and a negative value if there is an error.
651 *)
652
653 function AInputQueue_hasEvents(queue: PAInputQueue): cint32; cdecl; external;
654
655 (*
656 * Returns the next available event from the queue. Returns a negative
657 * value if no events are available or an error has occurred.
658 *)
659 function AInputQueue_getEvent(queue: PAInputQueue; outEvent: PPAInputEvent): cint32; cdecl; external;
660
661 (*
662 * Sends the key for standard pre-dispatching -- that is, possibly deliver
663 * it to the current IME to be consumed before the app. Returns 0 if it
664 * was not pre-dispatched, meaning you can process it right now. If non-zero
665 * is returned, you must abandon the current event processing and allow the
666 * event to appear again in the event queue (if it does not get consumed during
667 * pre-dispatching).
668 *)
669 function AInputQueue_preDispatchEvent(queue: PAInputQueue; event: PAInputEvent): cint32; cdecl; external;
670
671 (*
672 * Report that dispatching has finished with the given event.
673 * This must be called after receiving an event with AInputQueue_get_event().
674 *)
675
676 procedure AInputQueue_finishEvent(queue: PAInputQueue; event: PAInputEvent; handled: boolean32); cdecl; external;
677
678 implementation
679
680 end.
681