-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMotionEvent.java
More file actions
3681 lines (3405 loc) · 140 KB
/
Copy pathMotionEvent.java
File metadata and controls
3681 lines (3405 loc) · 140 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.view;
import android.graphics.Matrix;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.util.SparseArray;
/**
* Object used to report movement (mouse, pen, finger, trackball) events.
* Motion events may hold either absolute or relative movements and other data,
* depending on the type of device.
*
* <h3>Overview</h3>
* <p>
* Motion events describe movements in terms of an action code and a set of axis values.
* The action code specifies the state change that occurred such as a pointer going
* down or up. The axis values describe the position and other movement properties.
* </p><p>
* For example, when the user first touches the screen, the system delivers a touch
* event to the appropriate {@link View} with the action code {@link #ACTION_DOWN}
* and a set of axis values that include the X and Y coordinates of the touch and
* information about the pressure, size and orientation of the contact area.
* </p><p>
* Some devices can report multiple movement traces at the same time. Multi-touch
* screens emit one movement trace for each finger. The individual fingers or
* other objects that generate movement traces are referred to as <em>pointers</em>.
* Motion events contain information about all of the pointers that are currently active
* even if some of them have not moved since the last event was delivered.
* </p><p>
* The number of pointers only ever changes by one as individual pointers go up and down,
* except when the gesture is canceled.
* </p><p>
* Each pointer has a unique id that is assigned when it first goes down
* (indicated by {@link #ACTION_DOWN} or {@link #ACTION_POINTER_DOWN}). A pointer id
* remains valid until the pointer eventually goes up (indicated by {@link #ACTION_UP}
* or {@link #ACTION_POINTER_UP}) or when the gesture is canceled (indicated by
* {@link #ACTION_CANCEL}).
* </p><p>
* The MotionEvent class provides many methods to query the position and other properties of
* pointers, such as {@link #getX(int)}, {@link #getY(int)}, {@link #getAxisValue},
* {@link #getPointerId(int)}, {@link #getToolType(int)}, and many others. Most of these
* methods accept the pointer index as a parameter rather than the pointer id.
* The pointer index of each pointer in the event ranges from 0 to one less than the value
* returned by {@link #getPointerCount()}.
* </p><p>
* The order in which individual pointers appear within a motion event is undefined.
* Thus the pointer index of a pointer can change from one event to the next but
* the pointer id of a pointer is guaranteed to remain constant as long as the pointer
* remains active. Use the {@link #getPointerId(int)} method to obtain the
* pointer id of a pointer to track it across all subsequent motion events in a gesture.
* Then for successive motion events, use the {@link #findPointerIndex(int)} method
* to obtain the pointer index for a given pointer id in that motion event.
* </p><p>
* Mouse and stylus buttons can be retrieved using {@link #getButtonState()}. It is a
* good idea to check the button state while handling {@link #ACTION_DOWN} as part
* of a touch event. The application may choose to perform some different action
* if the touch event starts due to a secondary button click, such as presenting a
* context menu.
* </p>
*
* <h3>Batching</h3>
* <p>
* For efficiency, motion events with {@link #ACTION_MOVE} may batch together
* multiple movement samples within a single object. The most current
* pointer coordinates are available using {@link #getX(int)} and {@link #getY(int)}.
* Earlier coordinates within the batch are accessed using {@link #getHistoricalX(int, int)}
* and {@link #getHistoricalY(int, int)}. The coordinates are "historical" only
* insofar as they are older than the current coordinates in the batch; however,
* they are still distinct from any other coordinates reported in prior motion events.
* To process all coordinates in the batch in time order, first consume the historical
* coordinates then consume the current coordinates.
* </p><p>
* Example: Consuming all samples for all pointers in a motion event in time order.
* </p><p><pre><code>
* void printSamples(MotionEvent ev) {
* final int historySize = ev.getHistorySize();
* final int pointerCount = ev.getPointerCount();
* for (int h = 0; h < historySize; h++) {
* System.out.printf("At time %d:", ev.getHistoricalEventTime(h));
* for (int p = 0; p < pointerCount; p++) {
* System.out.printf(" pointer %d: (%f,%f)",
* ev.getPointerId(p), ev.getHistoricalX(p, h), ev.getHistoricalY(p, h));
* }
* }
* System.out.printf("At time %d:", ev.getEventTime());
* for (int p = 0; p < pointerCount; p++) {
* System.out.printf(" pointer %d: (%f,%f)",
* ev.getPointerId(p), ev.getX(p), ev.getY(p));
* }
* }
* </code></pre></p>
*
* <h3>Device Types</h3>
* <p>
* The interpretation of the contents of a MotionEvent varies significantly depending
* on the source class of the device.
* </p><p>
* On pointing devices with source class {@link InputDevice#SOURCE_CLASS_POINTER}
* such as touch screens, the pointer coordinates specify absolute
* positions such as view X/Y coordinates. Each complete gesture is represented
* by a sequence of motion events with actions that describe pointer state transitions
* and movements. A gesture starts with a motion event with {@link #ACTION_DOWN}
* that provides the location of the first pointer down. As each additional
* pointer that goes down or up, the framework will generate a motion event with
* {@link #ACTION_POINTER_DOWN} or {@link #ACTION_POINTER_UP} accordingly.
* Pointer movements are described by motion events with {@link #ACTION_MOVE}.
* Finally, a gesture end either when the final pointer goes up as represented
* by a motion event with {@link #ACTION_UP} or when gesture is canceled
* with {@link #ACTION_CANCEL}.
* </p><p>
* Some pointing devices such as mice may support vertical and/or horizontal scrolling.
* A scroll event is reported as a generic motion event with {@link #ACTION_SCROLL} that
* includes the relative scroll offset in the {@link #AXIS_VSCROLL} and
* {@link #AXIS_HSCROLL} axes. See {@link #getAxisValue(int)} for information
* about retrieving these additional axes.
* </p><p>
* On trackball devices with source class {@link InputDevice#SOURCE_CLASS_TRACKBALL},
* the pointer coordinates specify relative movements as X/Y deltas.
* A trackball gesture consists of a sequence of movements described by motion
* events with {@link #ACTION_MOVE} interspersed with occasional {@link #ACTION_DOWN}
* or {@link #ACTION_UP} motion events when the trackball button is pressed or released.
* </p><p>
* On joystick devices with source class {@link InputDevice#SOURCE_CLASS_JOYSTICK},
* the pointer coordinates specify the absolute position of the joystick axes.
* The joystick axis values are normalized to a range of -1.0 to 1.0 where 0.0 corresponds
* to the center position. More information about the set of available axes and the
* range of motion can be obtained using {@link InputDevice#getMotionRange}.
* Some common joystick axes are {@link #AXIS_X}, {@link #AXIS_Y},
* {@link #AXIS_HAT_X}, {@link #AXIS_HAT_Y}, {@link #AXIS_Z} and {@link #AXIS_RZ}.
* </p><p>
* Refer to {@link InputDevice} for more information about how different kinds of
* input devices and sources represent pointer coordinates.
* </p>
*
* <h3>Consistency Guarantees</h3>
* <p>
* Motion events are always delivered to views as a consistent stream of events.
* What constitutes a consistent stream varies depending on the type of device.
* For touch events, consistency implies that pointers go down one at a time,
* move around as a group and then go up one at a time or are canceled.
* </p><p>
* While the framework tries to deliver consistent streams of motion events to
* views, it cannot guarantee it. Some events may be dropped or modified by
* containing views in the application before they are delivered thereby making
* the stream of events inconsistent. Views should always be prepared to
* handle {@link #ACTION_CANCEL} and should tolerate anomalous
* situations such as receiving a new {@link #ACTION_DOWN} without first having
* received an {@link #ACTION_UP} for the prior gesture.
* </p>
*/
public final class MotionEvent extends InputEvent implements Parcelable {
private static final long NS_PER_MS = 1000000;
private static final String LABEL_PREFIX = "AXIS_";
/**
* An invalid pointer id.
*
* This value (-1) can be used as a placeholder to indicate that a pointer id
* has not been assigned or is not available. It cannot appear as
* a pointer id inside a {@link MotionEvent}.
*/
public static final int INVALID_POINTER_ID = -1;
/**
* Bit mask of the parts of the action code that are the action itself.
*/
public static final int ACTION_MASK = 0xff;
/**
* Constant for {@link #getActionMasked}: A pressed gesture has started, the
* motion contains the initial starting location.
* <p>
* This is also a good time to check the button state to distinguish
* secondary and tertiary button clicks and handle them appropriately.
* Use {@link #getButtonState} to retrieve the button state.
* </p>
*/
public static final int ACTION_DOWN = 0;
/**
* Constant for {@link #getActionMasked}: A pressed gesture has finished, the
* motion contains the final release location as well as any intermediate
* points since the last down or move event.
*/
public static final int ACTION_UP = 1;
/**
* Constant for {@link #getActionMasked}: A change has happened during a
* press gesture (between {@link #ACTION_DOWN} and {@link #ACTION_UP}).
* The motion contains the most recent point, as well as any intermediate
* points since the last down or move event.
*/
public static final int ACTION_MOVE = 2;
/**
* Constant for {@link #getActionMasked}: The current gesture has been aborted.
* You will not receive any more points in it. You should treat this as
* an up event, but not perform any action that you normally would.
*/
public static final int ACTION_CANCEL = 3;
/**
* Constant for {@link #getActionMasked}: A movement has happened outside of the
* normal bounds of the UI element. This does not provide a full gesture,
* but only the initial location of the movement/touch.
*/
public static final int ACTION_OUTSIDE = 4;
/**
* Constant for {@link #getActionMasked}: A non-primary pointer has gone down.
* <p>
* Use {@link #getActionIndex} to retrieve the index of the pointer that changed.
* </p><p>
* The index is encoded in the {@link #ACTION_POINTER_INDEX_MASK} bits of the
* unmasked action returned by {@link #getAction}.
* </p>
*/
public static final int ACTION_POINTER_DOWN = 5;
/**
* Constant for {@link #getActionMasked}: A non-primary pointer has gone up.
* <p>
* Use {@link #getActionIndex} to retrieve the index of the pointer that changed.
* </p><p>
* The index is encoded in the {@link #ACTION_POINTER_INDEX_MASK} bits of the
* unmasked action returned by {@link #getAction}.
* </p>
*/
public static final int ACTION_POINTER_UP = 6;
/**
* Constant for {@link #getActionMasked}: A change happened but the pointer
* is not down (unlike {@link #ACTION_MOVE}). The motion contains the most
* recent point, as well as any intermediate points since the last
* hover move event.
* <p>
* This action is always delivered to the window or view under the pointer.
* </p><p>
* This action is not a touch event so it is delivered to
* {@link View#onGenericMotionEvent(MotionEvent)} rather than
* {@link View#onTouchEvent(MotionEvent)}.
* </p>
*/
public static final int ACTION_HOVER_MOVE = 7;
/**
* Constant for {@link #getActionMasked}: The motion event contains relative
* vertical and/or horizontal scroll offsets. Use {@link #getAxisValue(int)}
* to retrieve the information from {@link #AXIS_VSCROLL} and {@link #AXIS_HSCROLL}.
* The pointer may or may not be down when this event is dispatched.
* <p>
* This action is always delivered to the window or view under the pointer, which
* may not be the window or view currently touched.
* </p><p>
* This action is not a touch event so it is delivered to
* {@link View#onGenericMotionEvent(MotionEvent)} rather than
* {@link View#onTouchEvent(MotionEvent)}.
* </p>
*/
public static final int ACTION_SCROLL = 8;
/**
* Constant for {@link #getActionMasked}: The pointer is not down but has entered the
* boundaries of a window or view.
* <p>
* This action is always delivered to the window or view under the pointer.
* </p><p>
* This action is not a touch event so it is delivered to
* {@link View#onGenericMotionEvent(MotionEvent)} rather than
* {@link View#onTouchEvent(MotionEvent)}.
* </p>
*/
public static final int ACTION_HOVER_ENTER = 9;
/**
* Constant for {@link #getActionMasked}: The pointer is not down but has exited the
* boundaries of a window or view.
* <p>
* This action is always delivered to the window or view that was previously under the pointer.
* </p><p>
* This action is not a touch event so it is delivered to
* {@link View#onGenericMotionEvent(MotionEvent)} rather than
* {@link View#onTouchEvent(MotionEvent)}.
* </p>
*/
public static final int ACTION_HOVER_EXIT = 10;
/**
* Constant for {@link #getActionMasked}: A button has been pressed.
*
* <p>
* Use {@link #getActionButton()} to get which button was pressed.
* </p><p>
* This action is not a touch event so it is delivered to
* {@link View#onGenericMotionEvent(MotionEvent)} rather than
* {@link View#onTouchEvent(MotionEvent)}.
* </p>
*/
public static final int ACTION_BUTTON_PRESS = 11;
/**
* Constant for {@link #getActionMasked}: A button has been released.
*
* <p>
* Use {@link #getActionButton()} to get which button was released.
* </p><p>
* This action is not a touch event so it is delivered to
* {@link View#onGenericMotionEvent(MotionEvent)} rather than
* {@link View#onTouchEvent(MotionEvent)}.
* </p>
*/
public static final int ACTION_BUTTON_RELEASE = 12;
/**
* Bits in the action code that represent a pointer index, used with
* {@link #ACTION_POINTER_DOWN} and {@link #ACTION_POINTER_UP}. Shifting
* down by {@link #ACTION_POINTER_INDEX_SHIFT} provides the actual pointer
* index where the data for the pointer going up or down can be found; you can
* get its identifier with {@link #getPointerId(int)} and the actual
* data with {@link #getX(int)} etc.
*
* @see #getActionIndex
*/
public static final int ACTION_POINTER_INDEX_MASK = 0xff00;
/**
* Bit shift for the action bits holding the pointer index as
* defined by {@link #ACTION_POINTER_INDEX_MASK}.
*
* @see #getActionIndex
*/
public static final int ACTION_POINTER_INDEX_SHIFT = 8;
/**
* @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the
* data index associated with {@link #ACTION_POINTER_DOWN}.
*/
@Deprecated
public static final int ACTION_POINTER_1_DOWN = ACTION_POINTER_DOWN | 0x0000;
/**
* @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the
* data index associated with {@link #ACTION_POINTER_DOWN}.
*/
@Deprecated
public static final int ACTION_POINTER_2_DOWN = ACTION_POINTER_DOWN | 0x0100;
/**
* @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the
* data index associated with {@link #ACTION_POINTER_DOWN}.
*/
@Deprecated
public static final int ACTION_POINTER_3_DOWN = ACTION_POINTER_DOWN | 0x0200;
/**
* @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the
* data index associated with {@link #ACTION_POINTER_UP}.
*/
@Deprecated
public static final int ACTION_POINTER_1_UP = ACTION_POINTER_UP | 0x0000;
/**
* @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the
* data index associated with {@link #ACTION_POINTER_UP}.
*/
@Deprecated
public static final int ACTION_POINTER_2_UP = ACTION_POINTER_UP | 0x0100;
/**
* @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the
* data index associated with {@link #ACTION_POINTER_UP}.
*/
@Deprecated
public static final int ACTION_POINTER_3_UP = ACTION_POINTER_UP | 0x0200;
/**
* @deprecated Renamed to {@link #ACTION_POINTER_INDEX_MASK} to match
* the actual data contained in these bits.
*/
@Deprecated
public static final int ACTION_POINTER_ID_MASK = 0xff00;
/**
* @deprecated Renamed to {@link #ACTION_POINTER_INDEX_SHIFT} to match
* the actual data contained in these bits.
*/
@Deprecated
public static final int ACTION_POINTER_ID_SHIFT = 8;
/**
* This flag indicates that the window that received this motion event is partly
* or wholly obscured by another visible window above it. This flag is set to true
* even if the event did not directly pass through the obscured area.
* A security sensitive application can check this flag to identify situations in which
* a malicious application may have covered up part of its content for the purpose
* of misleading the user or hijacking touches. An appropriate response might be
* to drop the suspect touches or to take additional precautions to confirm the user's
* actual intent.
*/
public static final int FLAG_WINDOW_IS_OBSCURED = 0x1;
/**
* Private flag that indicates when the system has detected that this motion event
* may be inconsistent with respect to the sequence of previously delivered motion events,
* such as when a pointer move event is sent but the pointer is not down.
*
* @hide
* @see #isTainted
* @see #setTainted
*/
public static final int FLAG_TAINTED = 0x80000000;
/**
* Private flag indicating that this event was synthesized by the system and
* should be delivered to the accessibility focused view first. When being
* dispatched such an event is not handled by predecessors of the accessibility
* focused view and after the event reaches that view the flag is cleared and
* normal event dispatch is performed. This ensures that the platform can click
* on any view that has accessibility focus which is semantically equivalent to
* asking the view to perform a click accessibility action but more generic as
* views not implementing click action correctly can still be activated.
*
* @hide
* @see #isTargetAccessibilityFocus()
* @see #setTargetAccessibilityFocus(boolean)
*/
public static final int FLAG_TARGET_ACCESSIBILITY_FOCUS = 0x40000000;
/**
* Flag indicating the motion event intersected the top edge of the screen.
*/
public static final int EDGE_TOP = 0x00000001;
/**
* Flag indicating the motion event intersected the bottom edge of the screen.
*/
public static final int EDGE_BOTTOM = 0x00000002;
/**
* Flag indicating the motion event intersected the left edge of the screen.
*/
public static final int EDGE_LEFT = 0x00000004;
/**
* Flag indicating the motion event intersected the right edge of the screen.
*/
public static final int EDGE_RIGHT = 0x00000008;
/**
* Axis constant: X axis of a motion event.
* <p>
* <ul>
* <li>For a touch screen, reports the absolute X screen position of the center of
* the touch contact area. The units are display pixels.
* <li>For a touch pad, reports the absolute X surface position of the center of the touch
* contact area. The units are device-dependent; use {@link InputDevice#getMotionRange(int)}
* to query the effective range of values.
* <li>For a mouse, reports the absolute X screen position of the mouse pointer.
* The units are display pixels.
* <li>For a trackball, reports the relative horizontal displacement of the trackball.
* The value is normalized to a range from -1.0 (left) to 1.0 (right).
* <li>For a joystick, reports the absolute X position of the joystick.
* The value is normalized to a range from -1.0 (left) to 1.0 (right).
* </ul>
* </p>
*
* @see #getX(int)
* @see #getHistoricalX(int, int)
* @see MotionEvent.PointerCoords#x
* @see InputDevice#getMotionRange
*/
public static final int AXIS_X = 0;
/**
* Axis constant: Y axis of a motion event.
* <p>
* <ul>
* <li>For a touch screen, reports the absolute Y screen position of the center of
* the touch contact area. The units are display pixels.
* <li>For a touch pad, reports the absolute Y surface position of the center of the touch
* contact area. The units are device-dependent; use {@link InputDevice#getMotionRange(int)}
* to query the effective range of values.
* <li>For a mouse, reports the absolute Y screen position of the mouse pointer.
* The units are display pixels.
* <li>For a trackball, reports the relative vertical displacement of the trackball.
* The value is normalized to a range from -1.0 (up) to 1.0 (down).
* <li>For a joystick, reports the absolute Y position of the joystick.
* The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
* </ul>
* </p>
*
* @see #getY(int)
* @see #getHistoricalY(int, int)
* @see MotionEvent.PointerCoords#y
* @see InputDevice#getMotionRange
*/
public static final int AXIS_Y = 1;
/**
* Axis constant: Pressure axis of a motion event.
* <p>
* <ul>
* <li>For a touch screen or touch pad, reports the approximate pressure applied to the surface
* by a finger or other tool. The value is normalized to a range from
* 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
* may be generated depending on the calibration of the input device.
* <li>For a trackball, the value is set to 1 if the trackball button is pressed
* or 0 otherwise.
* <li>For a mouse, the value is set to 1 if the primary mouse button is pressed
* or 0 otherwise.
* </ul>
* </p>
*
* @see #getPressure(int)
* @see #getHistoricalPressure(int, int)
* @see MotionEvent.PointerCoords#pressure
* @see InputDevice#getMotionRange
*/
public static final int AXIS_PRESSURE = 2;
/**
* Axis constant: Size axis of a motion event.
* <p>
* <ul>
* <li>For a touch screen or touch pad, reports the approximate size of the contact area in
* relation to the maximum detectable size for the device. The value is normalized
* to a range from 0 (smallest detectable size) to 1 (largest detectable size),
* although it is not a linear scale. This value is of limited use.
* To obtain calibrated size information, use
* {@link #AXIS_TOUCH_MAJOR} or {@link #AXIS_TOOL_MAJOR}.
* </ul>
* </p>
*
* @see #getSize(int)
* @see #getHistoricalSize(int, int)
* @see MotionEvent.PointerCoords#size
* @see InputDevice#getMotionRange
*/
public static final int AXIS_SIZE = 3;
/**
* Axis constant: TouchMajor axis of a motion event.
* <p>
* <ul>
* <li>For a touch screen, reports the length of the major axis of an ellipse that
* represents the touch area at the point of contact.
* The units are display pixels.
* <li>For a touch pad, reports the length of the major axis of an ellipse that
* represents the touch area at the point of contact.
* The units are device-dependent; use {@link InputDevice#getMotionRange(int)}
* to query the effective range of values.
* </ul>
* </p>
*
* @see #getTouchMajor(int)
* @see #getHistoricalTouchMajor(int, int)
* @see MotionEvent.PointerCoords#touchMajor
* @see InputDevice#getMotionRange
*/
public static final int AXIS_TOUCH_MAJOR = 4;
/**
* Axis constant: TouchMinor axis of a motion event.
* <p>
* <ul>
* <li>For a touch screen, reports the length of the minor axis of an ellipse that
* represents the touch area at the point of contact.
* The units are display pixels.
* <li>For a touch pad, reports the length of the minor axis of an ellipse that
* represents the touch area at the point of contact.
* The units are device-dependent; use {@link InputDevice#getMotionRange(int)}
* to query the effective range of values.
* </ul>
* </p><p>
* When the touch is circular, the major and minor axis lengths will be equal to one another.
* </p>
*
* @see #getTouchMinor(int)
* @see #getHistoricalTouchMinor(int, int)
* @see MotionEvent.PointerCoords#touchMinor
* @see InputDevice#getMotionRange
*/
public static final int AXIS_TOUCH_MINOR = 5;
/**
* Axis constant: ToolMajor axis of a motion event.
* <p>
* <ul>
* <li>For a touch screen, reports the length of the major axis of an ellipse that
* represents the size of the approaching finger or tool used to make contact.
* <li>For a touch pad, reports the length of the major axis of an ellipse that
* represents the size of the approaching finger or tool used to make contact.
* The units are device-dependent; use {@link InputDevice#getMotionRange(int)}
* to query the effective range of values.
* </ul>
* </p><p>
* When the touch is circular, the major and minor axis lengths will be equal to one another.
* </p><p>
* The tool size may be larger than the touch size since the tool may not be fully
* in contact with the touch sensor.
* </p>
*
* @see #getToolMajor(int)
* @see #getHistoricalToolMajor(int, int)
* @see MotionEvent.PointerCoords#toolMajor
* @see InputDevice#getMotionRange
*/
public static final int AXIS_TOOL_MAJOR = 6;
/**
* Axis constant: ToolMinor axis of a motion event.
* <p>
* <ul>
* <li>For a touch screen, reports the length of the minor axis of an ellipse that
* represents the size of the approaching finger or tool used to make contact.
* <li>For a touch pad, reports the length of the minor axis of an ellipse that
* represents the size of the approaching finger or tool used to make contact.
* The units are device-dependent; use {@link InputDevice#getMotionRange(int)}
* to query the effective range of values.
* </ul>
* </p><p>
* When the touch is circular, the major and minor axis lengths will be equal to one another.
* </p><p>
* The tool size may be larger than the touch size since the tool may not be fully
* in contact with the touch sensor.
* </p>
*
* @see #getToolMinor(int)
* @see #getHistoricalToolMinor(int, int)
* @see MotionEvent.PointerCoords#toolMinor
* @see InputDevice#getMotionRange
*/
public static final int AXIS_TOOL_MINOR = 7;
/**
* Axis constant: Orientation axis of a motion event.
* <p>
* <ul>
* <li>For a touch screen or touch pad, reports the orientation of the finger
* or tool in radians relative to the vertical plane of the device.
* An angle of 0 radians indicates that the major axis of contact is oriented
* upwards, is perfectly circular or is of unknown orientation. A positive angle
* indicates that the major axis of contact is oriented to the right. A negative angle
* indicates that the major axis of contact is oriented to the left.
* The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
* (finger pointing fully right).
* <li>For a stylus, the orientation indicates the direction in which the stylus
* is pointing in relation to the vertical axis of the current orientation of the screen.
* The range is from -PI radians to PI radians, where 0 is pointing up,
* -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
* is pointing right. See also {@link #AXIS_TILT}.
* </ul>
* </p>
*
* @see #getOrientation(int)
* @see #getHistoricalOrientation(int, int)
* @see MotionEvent.PointerCoords#orientation
* @see InputDevice#getMotionRange
*/
public static final int AXIS_ORIENTATION = 8;
/**
* Axis constant: Vertical Scroll axis of a motion event.
* <p>
* <ul>
* <li>For a mouse, reports the relative movement of the vertical scroll wheel.
* The value is normalized to a range from -1.0 (down) to 1.0 (up).
* </ul>
* </p><p>
* This axis should be used to scroll views vertically.
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_VSCROLL = 9;
/**
* Axis constant: Horizontal Scroll axis of a motion event.
* <p>
* <ul>
* <li>For a mouse, reports the relative movement of the horizontal scroll wheel.
* The value is normalized to a range from -1.0 (left) to 1.0 (right).
* </ul>
* </p><p>
* This axis should be used to scroll views horizontally.
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_HSCROLL = 10;
/**
* Axis constant: Z axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute Z position of the joystick.
* The value is normalized to a range from -1.0 (high) to 1.0 (low).
* <em>On game pads with two analog joysticks, this axis is often reinterpreted
* to report the absolute X position of the second joystick instead.</em>
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_Z = 11;
/**
* Axis constant: X Rotation axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute rotation angle about the X axis.
* The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_RX = 12;
/**
* Axis constant: Y Rotation axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute rotation angle about the Y axis.
* The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_RY = 13;
/**
* Axis constant: Z Rotation axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute rotation angle about the Z axis.
* The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
* <em>On game pads with two analog joysticks, this axis is often reinterpreted
* to report the absolute Y position of the second joystick instead.</em>
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_RZ = 14;
/**
* Axis constant: Hat X axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute X position of the directional hat control.
* The value is normalized to a range from -1.0 (left) to 1.0 (right).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_HAT_X = 15;
/**
* Axis constant: Hat Y axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute Y position of the directional hat control.
* The value is normalized to a range from -1.0 (up) to 1.0 (down).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_HAT_Y = 16;
/**
* Axis constant: Left Trigger axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute position of the left trigger control.
* The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_LTRIGGER = 17;
/**
* Axis constant: Right Trigger axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute position of the right trigger control.
* The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_RTRIGGER = 18;
/**
* Axis constant: Throttle axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute position of the throttle control.
* The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_THROTTLE = 19;
/**
* Axis constant: Rudder axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute position of the rudder control.
* The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_RUDDER = 20;
/**
* Axis constant: Wheel axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute position of the steering wheel control.
* The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_WHEEL = 21;
/**
* Axis constant: Gas axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute position of the gas (accelerator) control.
* The value is normalized to a range from 0.0 (no acceleration)
* to 1.0 (maximum acceleration).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_GAS = 22;
/**
* Axis constant: Brake axis of a motion event.
* <p>
* <ul>
* <li>For a joystick, reports the absolute position of the brake control.
* The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_BRAKE = 23;
/**
* Axis constant: Distance axis of a motion event.
* <p>
* <ul>
* <li>For a stylus, reports the distance of the stylus from the screen.
* A value of 0.0 indicates direct contact and larger values indicate increasing
* distance from the surface.
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_DISTANCE = 24;
/**
* Axis constant: Tilt axis of a motion event.
* <p>
* <ul>
* <li>For a stylus, reports the tilt angle of the stylus in radians where
* 0 radians indicates that the stylus is being held perpendicular to the
* surface, and PI/2 radians indicates that the stylus is being held flat
* against the surface.
* </ul>
* </p>
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int, int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_TILT = 25;
/**
* Axis constant: Generic 1 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_GENERIC_1 = 32;
/**
* Axis constant: Generic 2 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_GENERIC_2 = 33;
/**
* Axis constant: Generic 3 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*
* @see #getAxisValue(int, int)
* @see #getHistoricalAxisValue(int, int, int)
* @see MotionEvent.PointerCoords#getAxisValue(int)
* @see InputDevice#getMotionRange
*/
public static final int AXIS_GENERIC_3 = 34;
/**
* Axis constant: Generic 4 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*