-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_stylus_support.patch
5021 lines (4909 loc) · 197 KB
/
add_stylus_support.patch
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
From 15df6c0d9e9d073c2eeb9ae1adb8a0bd19444901 Mon Sep 17 00:00:00 2001
From: Andrew Hughes <[email protected]>
Date: Wed, 31 Aug 2011 13:35:41 -0700
Subject: [PATCH] Added active stylus support to the Android input framework as detailed
in my thesis, available at
http://digitalcommons.calpoly.edu/theses/536/
This commit comprises the entirety discussed in the thesis, however it
has not been cleaned up or commented well. I hope to have time to do
this in the future.
Change-Id: I7bd6f7f66c793c91530b0c2b75d5c91545b2b8ce
---
Android.mk | 2 +
core/java/android/app/Activity.java | 3 +
core/java/android/app/ContextImpl.java | 12 +
core/java/android/app/IPointerManager.aidl | 28 +
core/java/android/app/Pointer.aidl | 19 +
core/java/android/app/Pointer.java | 153 ++
core/java/android/app/PointerManager.java | 103 +
core/java/android/content/Context.java | 12 +
core/java/android/view/IWindowManager.aidl | 3 +
core/java/android/view/InputDevice.java | 9 +
core/java/android/view/KeyEvent.java | 52 +-
core/java/android/view/MotionEvent.java | 61 +-
core/java/android/view/ViewGroup.java | 6 +
core/java/android/view/ViewRoot.java | 4 +-
core/jni/android_view_MotionEvent.cpp | 8 +-
core/res/res/drawable/pointer.png | Bin 0 -> 287 bytes
.../res/drawable/pointer_side_button_pressed.png | Bin 0 -> 889 bytes
core/res/res/values/attrs.xml | 4 +-
include/ui/EventHub.h | 3 +
include/ui/Input.h | 4 +
include/ui/InputDispatcher.h | 7 +-
include/ui/InputReader.h | 398 ++++
include/ui/InputTransport.h | 2 +
include/ui/KeycodeLabels.h | 2 +
libs/ui/EventHub.cpp | 9 +-
libs/ui/Input.cpp | 2 +
libs/ui/InputDispatcher.cpp | 68 +-
libs/ui/InputReader.cpp | 2374 +++++++++++++++++++-
libs/ui/InputTransport.cpp | 7 +-
libs/ui/tests/InputDispatcher_test.cpp | 20 +-
libs/ui/tests/InputPublisherAndConsumer_test.cpp | 18 +-
libs/ui/tests/InputReader_test.cpp | 4 +-
native/android/input.cpp | 4 +
native/include/android/input.h | 47 +-
native/include/android/keycodes.h | 2 +
services/java/com/android/server/InputManager.java | 5 +-
.../com/android/server/PointerManagerService.java | 390 ++++
services/java/com/android/server/SystemServer.java | 11 +
.../com/android/server/WindowManagerService.java | 8 +
services/jni/com_android_server_InputManager.cpp | 2 +-
40 files changed, 3804 insertions(+), 62 deletions(-)
create mode 100644 core/java/android/app/IPointerManager.aidl
create mode 100644 core/java/android/app/Pointer.aidl
create mode 100644 core/java/android/app/Pointer.java
create mode 100644 core/java/android/app/PointerManager.java
create mode 100644 core/res/res/drawable/pointer.png
create mode 100644 core/res/res/drawable/pointer_side_button_pressed.png
create mode 100644 services/java/com/android/server/PointerManagerService.java
diff --git a/Android.mk b/Android.mk
index e987eb7..96f47fa 100644
--- a/Android.mk
+++ b/Android.mk
@@ -83,6 +83,7 @@ LOCAL_SRC_FILES += \
core/java/android/app/IBackupAgent.aidl \
core/java/android/app/IInstrumentationWatcher.aidl \
core/java/android/app/INotificationManager.aidl \
+ core/java/android/app/IPointerManager.aidl \
core/java/android/app/ISearchManager.aidl \
core/java/android/app/ISearchManagerCallback.aidl \
core/java/android/app/IServiceConnection.aidl \
@@ -239,6 +240,7 @@ aidl_files := \
frameworks/base/core/java/android/accounts/IAccountAuthenticator.aidl \
frameworks/base/core/java/android/accounts/IAccountAuthenticatorResponse.aidl \
frameworks/base/core/java/android/app/Notification.aidl \
+ frameworks/base/core/java/android/app/Pointer.aidl \
frameworks/base/core/java/android/app/PendingIntent.aidl \
frameworks/base/core/java/android/bluetooth/BluetoothDevice.aidl \
frameworks/base/core/java/android/content/ComponentName.aidl \
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index f25c4c3..ee4d95b 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -2092,6 +2092,9 @@ public class Activity extends ContextThemeWrapper
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
onUserInteraction();
+ } else if (ev.getAction() == MotionEvent.ACTION_ENTER_PROXIMITY ||
+ ev.getAction() == MotionEvent.ACTION_EXIT_PROXIMITY) {
+ //onStylusInRange(ev.getAction() == MotionEvent.ACTION_ENTER_PROXIMITY);
}
if (getWindow().superDispatchTouchEvent(ev)) {
return true;
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 2dd5819..7b698cb 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -201,6 +201,7 @@ class ContextImpl extends Context {
private DevicePolicyManager mDevicePolicyManager = null;
private UiModeManager mUiModeManager = null;
private DownloadManager mDownloadManager = null;
+ private PointerManager mPointerManager = null;
private final Object mSync = new Object();
@@ -976,6 +977,8 @@ class ContextImpl extends Context {
return getUiModeManager();
} else if (DOWNLOAD_SERVICE.equals(name)) {
return getDownloadManager();
+ } else if (POINTER_SERVICE.equals(name)) {
+ return getPointerManager();
}
return null;
@@ -1202,6 +1205,15 @@ class ContextImpl extends Context {
}
return mDownloadManager;
}
+
+ private PointerManager getPointerManager() {
+ synchronized (mSync) {
+ if (mPointerManager == null) {
+ mPointerManager = new PointerManager(this);
+ }
+ }
+ return mPointerManager;
+ }
@Override
public int checkPermission(String permission, int pid, int uid) {
diff --git a/core/java/android/app/IPointerManager.aidl b/core/java/android/app/IPointerManager.aidl
new file mode 100644
index 0000000..ce3d172
--- /dev/null
+++ b/core/java/android/app/IPointerManager.aidl
@@ -0,0 +1,28 @@
+/* //device/java/android/android/app/IPointerManager.aidl
+**
+** Copyright 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.app;
+
+import android.app.Pointer;
+
+/** {@hide} */
+interface IPointerManager
+{
+ void changePointer(String pkg, in Pointer pointer);
+ void resetPointer(String pkg);
+ void setVisible(String pkg, boolean visible);
+}
diff --git a/core/java/android/app/Pointer.aidl b/core/java/android/app/Pointer.aidl
new file mode 100644
index 0000000..d802b72
--- /dev/null
+++ b/core/java/android/app/Pointer.aidl
@@ -0,0 +1,19 @@
+/**
+ * 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.app;
+
+parcelable Pointer;
diff --git a/core/java/android/app/Pointer.java b/core/java/android/app/Pointer.java
new file mode 100644
index 0000000..b15e330
--- /dev/null
+++ b/core/java/android/app/Pointer.java
@@ -0,0 +1,153 @@
+/*
+ * 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.app;
+
+import android.content.Context;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class Pointer implements Parcelable
+{
+ /**
+ * The resource id of a drawable to use as the image for the pointer.
+ */
+ private int image;
+
+ /**
+ * The horizontal offset of the image to place the "point" at location 0.
+ */
+ private float offsetX;
+
+ /**
+ * The vertical offset of the image to place the "point" at location 0.
+ */
+ private float offsetY;
+
+ /**
+ * Constructs a Pointer object with image resource and offset values.
+ *
+ * @param image The resource id of the image to use as the pointer.
+ * @param offsetX The horizontal offset of the image to place the "point" at location 0.
+ * @param offsetY The vertical offset of the image to place the "point" at location 0.
+ */
+ public Pointer(int image, float offsetX, float offsetY) {
+ this.image = image;
+ this.offsetX = offsetX;
+ this.offsetY = offsetY;
+ }
+
+ /**
+ * Unflatten the notification from a parcel.
+ */
+ public Pointer(Parcel parcel) {
+ int version = parcel.readInt();
+
+ image = parcel.readInt();
+ offsetX = parcel.readFloat();
+ offsetY = parcel.readFloat();
+ }
+
+ public Pointer clone() {
+ return new Pointer(this.image, this.offsetX, this.offsetY);
+ }
+
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Flatten this notification from a parcel.
+ */
+ public void writeToParcel(Parcel parcel, int flags) {
+ // version code
+ parcel.writeInt(1);
+
+ parcel.writeInt(image);
+ parcel.writeFloat(offsetX);
+ parcel.writeFloat(offsetY);
+ }
+
+ /**
+ * Parcelable.Creator that instantiates Pointer objects
+ */
+ public static final Parcelable.Creator<Pointer> CREATOR
+ = new Parcelable.Creator<Pointer>() {
+
+ public Pointer createFromParcel(Parcel parcel) {
+ return new Pointer(parcel);
+ }
+
+ public Pointer[] newArray(int size) {
+ return new Pointer[size];
+ }
+ };
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Pointer(image=0x");
+ sb.append(Integer.toHexString(this.image));
+ sb.append(",offsetX=");
+ sb.append(Float.toString(this.offsetX));
+ sb.append(",offsetY=");
+ sb.append(Float.toString(this.offsetY));
+ sb.append(")");
+
+ return sb.toString();
+ }
+
+ /**
+ * Set the image resource.
+ *
+ * @param image The resource id of the image to use as the pointer.
+ */
+ public void setImage(int image) {
+ this.image = image;
+ }
+
+ /**
+ * Set the pointer image offset values.
+ *
+ * @param offsetX The horizontal offset of the image to place the "point" at location 0.
+ * @param offsetY The vertical offset of the image to place the "point" at location 0.
+ */
+ public void setOffset(float offsetX, float offsetY) {
+ this.offsetX = offsetX;
+ this.offsetY = offsetY;
+ }
+
+ /**
+ * Get the resource id for the image.
+ */
+ public int getImage() {
+ return image;
+ }
+
+ /**
+ * Get the horizontal offset for the pointer image.
+ */
+ public float getOffsetX() {
+ return offsetX;
+ }
+
+ /**
+ * Get the vertical offset for the pointer image.
+ */
+ public float getOffsetY() {
+ return offsetY;
+ }
+}
diff --git a/core/java/android/app/PointerManager.java b/core/java/android/app/PointerManager.java
new file mode 100644
index 0000000..6717c26
--- /dev/null
+++ b/core/java/android/app/PointerManager.java
@@ -0,0 +1,103 @@
+/*
+ * 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.app;
+
+import android.content.Context;
+import android.os.Binder;
+import android.os.RemoteException;
+import android.os.IBinder;
+import android.os.ServiceManager;
+import android.util.Log;
+
+/**
+ * Class to manage the look of the pointer.
+ *
+ * You do not instantiate this class directly; instead, retrieve it through
+ * {@link android.content.Context#getSystemService}.
+ *
+ * @see android.app.Pointer
+ * @see android.content.Context#getSystemService
+ */
+public class PointerManager
+{
+ private static String TAG = "PointerManager";
+ private static boolean DEBUG = true;
+
+ private static IPointerManager sService;
+
+ private Context mContext;
+
+ /** @hide */
+ static public IPointerManager getService() {
+ if (sService != null) {
+ return sService;
+ }
+ IBinder b = ServiceManager.getService("pointer");
+ sService = IPointerManager.Stub.asInterface(b);
+ return sService;
+ }
+
+ /*package*/ PointerManager(Context context)
+ {
+ mContext = context;
+ }
+
+ /**
+ * Change the current image used for the pointer.
+ *
+ * @param pointer A {@link Pointer} object providing an image and offset to
+ * display a new pointer. Must not be null;
+ */
+ public void changePointer(Pointer pointer) {
+ if (pointer == null) {
+ return;
+ }
+
+ IPointerManager service = getService();
+ String pkg = mContext.getPackageName();
+ try {
+ service.changePointer(pkg, pointer);
+ } catch (RemoteException e) {
+ }
+ }
+
+ /**
+ * Reset the pointer to its default state.
+ */
+ public void resetPointer() {
+ IPointerManager service = getService();
+ String pkg = mContext.getPackageName();
+ try {
+ service.resetPointer(pkg);
+ } catch (RemoteException e) {
+ }
+ }
+
+ /**
+ * Set whether the current pointer is visible or not.
+ *
+ * @param visible Set to true if visible, false if not.
+ */
+ public void setVisibe(boolean visible) {
+ IPointerManager service = getService();
+ String pkg = mContext.getPackageName();
+ try {
+ service.setVisible(pkg, visible);
+ } catch (RemoteException e) {
+ }
+ }
+}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 7563831..d62e984 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -1212,6 +1212,8 @@ public abstract class Context {
* <dd> An {@link android.app.UiModeManager} for controlling UI modes.
* <dt> {@link #DOWNLOAD_SERVICE} ("download")
* <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads
+ * <dt> {@link #POINTER_SERVICE} ("pointer")
+ * <dd> A {@link android.app.PointerManager} for modifying the displayed pointer.
* </dl>
*
* <p>Note: System services obtained via this API may be closely associated with
@@ -1261,6 +1263,8 @@ public abstract class Context {
* @see android.app.UiModeManager
* @see #DOWNLOAD_SERVICE
* @see android.app.DownloadManager
+ * @see #POINTER_SERVICE
+ * @see android.app.PointerManager
*/
public abstract Object getSystemService(String name);
@@ -1557,6 +1561,14 @@ public abstract class Context {
*/
/** @hide */
public static final String SIP_SERVICE = "sip";
+
+ /**
+ * Use with {@link #getSystemService} to retrieve a
+ * {@link android.app.PointerManager} for modifying the displayed pointer.
+ *
+ * @see #getSystemService
+ */
+ public static final String POINTER_SERVICE = "pointer";
/**
* Determine whether the given permission is allowed for a particular
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index d4dd05c..fc64f22 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -156,4 +156,7 @@ interface IWindowManager
* calls back when it changes.
*/
int watchRotation(IRotationWatcher watcher);
+
+ // (Hack) added to get top layer for drawing pointer
+ int getTopAnimLayer();
}
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index dd04975..329dfbc 100755
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -150,6 +150,14 @@ public final class InputDevice implements Parcelable {
public static final int SOURCE_TOUCHPAD = 0x00100000 | SOURCE_CLASS_POSITION;
/**
+ * The input source is an active pen digitizer that is associated with a
+ * display.
+ *
+ * @see #SOURCE_CLASS_POINTER
+ */
+ public static final int SOURCE_ACTIVE_STYLUS = 0x00200000 | SOURCE_CLASS_POINTER;
+
+ /**
* A special input source constant that is used when filtering input devices
* to match devices that provide any type of input source.
*/
@@ -476,6 +484,7 @@ public final class InputDevice implements Parcelable {
appendSourceDescriptionIfApplicable(description, SOURCE_MOUSE, "mouse");
appendSourceDescriptionIfApplicable(description, SOURCE_TRACKBALL, "trackball");
appendSourceDescriptionIfApplicable(description, SOURCE_TOUCHPAD, "touchpad");
+ appendSourceDescriptionIfApplicable(description, SOURCE_ACTIVE_STYLUS, "active stylus");
description.append("\n");
appendRangeDescriptionIfApplicable(description, MOTION_RANGE_X, "x");
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index b58a65c..a10ccd8 100755
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -331,6 +331,12 @@ public class KeyEvent extends InputEvent implements Parcelable {
/** Key code constant: Mode Button key.
* On a game controller, the button labeled Mode. */
public static final int KEYCODE_BUTTON_MODE = 110;
+ /** Key code constant: Primary Stylus Button key.
+ * On an active stylus, the primary side button. */
+ public static final int KEYCODE_BUTTON_STYLUS = 111;
+ /** Key code constant: Secondary Stylus Button key.
+ * On an active stylus, the secondary side button. */
+ public static final int KEYCODE_BUTTON_STYLUS2 = 112;
/**
* @hide
@@ -407,7 +413,7 @@ public class KeyEvent extends InputEvent implements Parcelable {
// native/include/android/keycodes.h
// frameworks/base/include/ui/KeycodeLabels.h
// external/webkit/WebKit/android/plugins/ANPKeyCodes.h
- // tools/puppet_master/PuppetMaster/nav_keys.py
+ // tools/puppet_master/PuppetMaster/nav_keys.py <-- couldn't find
// frameworks/base/core/res/res/values/attrs.xml
// commands/monkey/Monkey.java
// emulator?
@@ -418,7 +424,7 @@ public class KeyEvent extends InputEvent implements Parcelable {
// those new codes. This is intended to maintain a consistent
// set of key code definitions across all Android devices.
- private static final int LAST_KEYCODE = KEYCODE_BUTTON_MODE;
+ private static final int LAST_KEYCODE = KEYCODE_BUTTON_STYLUS2;
/**
* @deprecated There are now more than MAX_KEYCODE keycodes.
@@ -511,6 +517,24 @@ public class KeyEvent extends InputEvent implements Parcelable {
public static final int META_SYM_ON = 0x4;
/**
+ * <p>This mask is used to check whether the primary stylus button is pressed.</p>
+ *
+ * @see #isStylusButtonPressed()
+ * @see #getMetaState()
+ * @see #KEYCODE_BUTTON_STYLUS
+ */
+ public static final int META_BTN_STYLUS_ON = 0x100;
+
+ /**
+ * <p>This mask is used to check whether the secondary stylus button is pressed.</p>
+ *
+ * @see #isSecStylusButtonPressed()
+ * @see #getMetaState()
+ * @see #KEYCODE_BUTTON_STYLUS2
+ */
+ public static final int META_BTN_STYLUS2_ON = 0x200;
+
+ /**
* This mask is set if the device woke because of this key event.
*/
public static final int FLAG_WOKE_HERE = 0x1;
@@ -1079,6 +1103,30 @@ public class KeyEvent extends InputEvent implements Parcelable {
}
/**
+ * <p>Returns the pressed state of the primary stylus button meta key.</p>
+ *
+ * @return true if the primary stylus button is pressed, false otherwise
+ *
+ * @see #KEYCODE_BUTTON_STYLUS
+ * @see #META_BTN_STYLUS_ON
+ */
+ public final boolean isStylusButtonPressed() {
+ return (mMetaState & META_BTN_STYLUS_ON) != 0;
+ }
+
+ /**
+ * <p>Returns the pressed state of the secondary stylus button meta key.</p>
+ *
+ * @return true if the secondary stylus button is pressed, false otherwise
+ *
+ * @see #KEYCODE_BUTTON_STYLUS2
+ * @see #META_BTN_STYLUS2_ON
+ */
+ public final boolean isSecStylusButtonPressed() {
+ return (mMetaState & META_BTN_STYLUS2_ON) != 0;
+ }
+
+ /**
* Retrieve the action of this key event. May be either
* {@link #ACTION_DOWN}, {@link #ACTION_UP}, or {@link #ACTION_MULTIPLE}.
*
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index c2fec96..fb87aee 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -128,7 +128,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
* an up event, but not perform any action that you normally would.
*/
public static final int ACTION_CANCEL = 3;
-
+
/**
* Constant for {@link #getAction}: A movement has happened outside of the
* normal bounds of the UI element. This does not provide a full gesture,
@@ -149,6 +149,26 @@ public final class MotionEvent extends InputEvent implements Parcelable {
public static final int ACTION_POINTER_UP = 6;
/**
+ * Constant for {@link #getAction}: The {@link InputDevice} is hovering
+ * above but not touching the surface. The motion contains the most recent
+ * point, as well as any intermediate points since the last up or hover
+ * event (similar to an {@link #ACTION_MOVE}). This will only occur between
+ * an {@link #ACTION_UP} and {@link #ACTION_DOWN} for {@link InputDevice}s
+ * that support hover.
+ */
+ public static final int ACTION_HOVER = 7;
+
+ /**
+ * TODO: add comment
+ */
+ public static final int ACTION_ENTER_PROXIMITY = 8;
+
+ /**
+ * TODO: add comment
+ */
+ public static final int ACTION_EXIT_PROXIMITY = 9;
+
+ /**
* 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
@@ -252,6 +272,22 @@ public final class MotionEvent extends InputEvent implements Parcelable {
*/
public static final int EDGE_RIGHT = 0x00000008;
+ /**
+ * The tool type used is unknown. This is the default tool type for an
+ * input device that does not support tool type.
+ */
+ public static final int TOOL_TYPE_NONE = 0;
+
+ /**
+ * The event is being performed by the pen tool.
+ */
+ public static final int TOOL_TYPE_PEN = 1;
+
+ /**
+ * The event is being performed by the "rubber" or eraser tool.
+ */
+ public static final int TOOL_TYPE_RUBBER = 2;
+
/*
* Offset for the sample's X coordinate.
*/
@@ -320,6 +356,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
private long mDownTimeNano;
private int mAction;
+ private int mToolType;
private float mXOffset;
private float mYOffset;
private float mXPrecision;
@@ -429,6 +466,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
ev.mEdgeFlags = edgeFlags;
ev.mDownTimeNano = downTime * MS_PER_NS;
ev.mAction = action;
+ ev.mToolType = TOOL_TYPE_NONE;
ev.mFlags = flags;
ev.mMetaState = metaState;
ev.mXOffset = 0;
@@ -491,6 +529,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
ev.mEdgeFlags = edgeFlags;
ev.mDownTimeNano = downTime * MS_PER_NS;
ev.mAction = action;
+ ev.mToolType = TOOL_TYPE_NONE;
ev.mFlags = 0;
ev.mMetaState = metaState;
ev.mXOffset = 0;
@@ -588,6 +627,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
ev.mEdgeFlags = o.mEdgeFlags;
ev.mDownTimeNano = o.mDownTimeNano;
ev.mAction = o.mAction;
+ ev.mToolType = o.mToolType;
ev.mFlags = o.mFlags;
ev.mMetaState = o.mMetaState;
ev.mXOffset = o.mXOffset;
@@ -620,6 +660,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
ev.mEdgeFlags = o.mEdgeFlags;
ev.mDownTimeNano = o.mDownTimeNano;
ev.mAction = o.mAction;
+ ev.mToolType = o.mToolType;
o.mFlags = o.mFlags;
ev.mMetaState = o.mMetaState;
ev.mXOffset = o.mXOffset;
@@ -732,6 +773,13 @@ public final class MotionEvent extends InputEvent implements Parcelable {
}
/**
+ * Return the kind of tool type being used.
+ */
+ public final int getToolType() {
+ return mToolType;
+ }
+
+ /**
* Gets the motion event flags.
*
* @see #FLAG_WINDOW_IS_OBSCURED
@@ -1390,6 +1438,13 @@ public final class MotionEvent extends InputEvent implements Parcelable {
public final void setAction(int action) {
mAction = action;
}
+
+ /**
+ * Sets this event's tool type.
+ */
+ public final void setToolType(int toolType) {
+ mToolType = toolType;
+ }
/**
* Adjust this event's location.
@@ -1534,7 +1589,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
@Override
public String toString() {
return "MotionEvent{" + Integer.toHexString(System.identityHashCode(this))
- + " action=" + mAction + " x=" + getX()
+ + " action=" + mAction + " tooltype=" + mToolType + " x=" + getX()
+ " y=" + getY() + " pressure=" + getPressure() + " size=" + getSize() + "}";
}
@@ -1564,6 +1619,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
ev.mDownTimeNano = in.readLong();
ev.mAction = in.readInt();
+ ev.mToolType = in.readInt();
ev.mXOffset = in.readFloat();
ev.mYOffset = in.readFloat();
ev.mXPrecision = in.readFloat();
@@ -1606,6 +1662,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
out.writeLong(mDownTimeNano);
out.writeInt(mAction);
+ out.writeInt(mToolType);
out.writeFloat(mXOffset);
out.writeFloat(mYOffset);
out.writeFloat(mXPrecision);
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index b9864ba..9dd6da5 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -822,6 +822,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
*/
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
+ Log.d("ViewGroup", "Begin: " + ev.toString());
+
if (!onFilterTouchEventForSecurity(ev)) {
return false;
}
@@ -869,6 +871,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
if (child.dispatchTouchEvent(ev)) {
// Event handled, we have a target now.
mMotionTarget = child;
+ Log.d("ViewGroup", "1: " + ev.toString());
return true;
}
// The event didn't get handled, try the next view.
@@ -900,6 +903,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
ev.setAction(MotionEvent.ACTION_CANCEL);
mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
}
+ Log.d("ViewGroup", "2: " + ev.toString());
return super.dispatchTouchEvent(ev);
}
@@ -920,6 +924,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
// Don't dispatch this event to our own view, because we already
// saw it when intercepting; we just want to give the following
// event to the normal onTouchEvent().
+ Log.d("ViewGroup", "3: " + ev.toString());
return true;
}
@@ -939,6 +944,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
mMotionTarget = null;
}
+ Log.d("ViewGroup", "End: " + ev.toString());
return target.dispatchTouchEvent(ev);
}
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 2361d1f..4c85e4c 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -86,7 +86,7 @@ public final class ViewRoot extends Handler implements ViewParent,
private static final boolean DEBUG_CONFIGURATION = false || LOCAL_LOGV;
private static final boolean WATCH_POINTER = false;
- private static final boolean MEASURE_LATENCY = false;
+ private static final boolean MEASURE_LATENCY = true;
private static LatencyTimer lt;
/**
@@ -2170,6 +2170,8 @@ public final class ViewRoot extends Handler implements ViewParent,
}
private void deliverPointerEvent(MotionEvent event) {
+ Log.d(TAG, "Begin: " + event.toString());
+
if (mTranslator != null) {
mTranslator.translateEventInScreenToAppWindow(event);
}
diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp
index 93fd54f..0f953fd 100644
--- a/core/jni/android_view_MotionEvent.cpp
+++ b/core/jni/android_view_MotionEvent.cpp
@@ -40,6 +40,7 @@ static struct {
jfieldID mSource;
jfieldID mDownTimeNano;
jfieldID mAction;
+ jfieldID mToolType;
jfieldID mXOffset;
jfieldID mYOffset;
jfieldID mXPrecision;
@@ -80,6 +81,8 @@ jobject android_view_MotionEvent_fromNative(JNIEnv* env, const MotionEvent* even
event->getDownTime());
env->SetIntField(eventObj, gMotionEventClassInfo.mAction,
event->getAction());
+ env->SetIntField(eventObj, gMotionEventClassInfo.mToolType,
+ event->getToolType());
env->SetFloatField(eventObj, gMotionEventClassInfo.mXOffset,
event->getXOffset());
env->SetFloatField(eventObj, gMotionEventClassInfo.mYOffset,
@@ -159,6 +162,7 @@ void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj,
jint source = env->GetIntField(eventObj, gMotionEventClassInfo.mSource);
jlong downTimeNano = env->GetLongField(eventObj, gMotionEventClassInfo.mDownTimeNano);
jint action = env->GetIntField(eventObj, gMotionEventClassInfo.mAction);
+ jint toolType = env->GetIntField(eventObj, gMotionEventClassInfo.mToolType);
jfloat xOffset = env->GetFloatField(eventObj, gMotionEventClassInfo.mXOffset);
jfloat yOffset = env->GetFloatField(eventObj, gMotionEventClassInfo.mYOffset);
jfloat xPrecision = env->GetFloatField(eventObj, gMotionEventClassInfo.mXPrecision);
@@ -200,7 +204,7 @@ void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj,
samplePointerCoords[j].orientation = *(srcDataSamples++);
}
- event->initialize(deviceId, source, action, flags, edgeFlags, metaState,
+ event->initialize(deviceId, source, action, toolType, flags, edgeFlags, metaState,
xOffset, yOffset, xPrecision, yPrecision, downTimeNano, sampleEventTime,
numPointers, pointerIdentifiers, samplePointerCoords);
@@ -273,6 +277,8 @@ int register_android_view_MotionEvent(JNIEnv* env) {
"mDownTimeNano", "J");
GET_FIELD_ID(gMotionEventClassInfo.mAction, gMotionEventClassInfo.clazz,
"mAction", "I");
+ GET_FIELD_ID(gMotionEventClassInfo.mToolType, gMotionEventClassInfo.clazz,
+ "mToolType", "I");
GET_FIELD_ID(gMotionEventClassInfo.mXOffset, gMotionEventClassInfo.clazz,
"mXOffset", "F");
GET_FIELD_ID(gMotionEventClassInfo.mYOffset, gMotionEventClassInfo.clazz,
diff --git a/core/res/res/drawable/pointer.png b/core/res/res/drawable/pointer.png
new file mode 100644
index 0000000000000000000000000000000000000000..505590e67248585dea6fba2a591f1a74b131e978
GIT binary patch
literal 287
zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|#^NA%Cx&(BWL^R}Y)RhkE)4%c
zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmP?t27(CoR`?SEkGg364!_l=ltB<
z)VvY~=c3falGGH1^30M91$R&1fbd2>aiF3qPZ!4!i_^&o3Jf);xBvUDd;iz`307)s
zT8v^&TyZr?YNr%d?d%Yo-jeyO?>`R^m}yOTU|Gbz=*yQ9ez#w{IPR+cJvy%kB-6V0
z_W#Gll3!z3yp=cHa4hGvawwn4a{qp!yj!!LtRTy>nb!Xf$Cz6b+3U=`aMqRK#Bp0A
Uah}Offv#ZiboFyt=akR{0BvJky8r+H
literal 0
HcmV?d00001
diff --git a/core/res/res/drawable/pointer_side_button_pressed.png b/core/res/res/drawable/pointer_side_button_pressed.png
new file mode 100644
index 0000000000000000000000000000000000000000..df7fdcaa8336652a5cbcf2943207d4d747d3c009
GIT binary patch
literal 889
zcmV-<1BU#GP)<h;3K|Lk000e1NJLTq0015U0015c1^@s6J20-I00001b5ch_0Itp)
z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipZ7
z7X=st#a9ym000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0008iNkl<Z
zNXNyOPe@cz6vlsV977~#Q4(U%rodeUq4Y<pL5hakWkA<0qJ>HjMByb$A+X{}(jqAP
z<DzI2kztq1xG2VjQY5qt1UIdeawQQGm@Pbacuh0T8&f-*H|M_l&Ntt8?>YC}fS9I@
z+X=J+Ex<`&Kai5w7I+R!0&_N0E0y8}6~F@E6fh`2aqI`s58Sh%`dMyLVhzwez-M4w
zK&OH0KpJSWp$dR)K$DDJmpS#o9pIZb?s!#<wQ=phTXA#1pbgbT%q2Mi^a2?fdIEIW
zQ2kmHSR2;^+!wdohUy{fFl}5HFf8t<4OM4ZskL!81#}TeuNM?RzD-N44sG1El8i;7
zytwH~(rV*Y1R#hZy^q^zLp54ptc^=bN_crE*dUWw-QvE|#_ftqt%2=8F0Q=ui#5zI
z)>I>VPTYQggf=b#Jd(jdHqU(Q3);B)KpS@mcn?h5P_<V2x}|4)1)y!;YH^yJU0veo
z2d9G=JN=_nz5@x78DNafH;-{JDRmcMsv4$uFJ}UPOGCNU0eN46xyNWvNXY}3*#gEM
z<4h9REzUxzJoP)bn5nmN%o|h7l*n_BkxKBNED3y<9Bu&SBDweHS_u=+te9!c-Q5ta
z)$inY^A-^G7$1_rQy>c*1<IDn0+S-<)#R~Y01PD}VA(BT>@o6z?BH2oZ=6%9IIm+e
zjh<3-HdIZ1S6`85?<TVKv2RCDr#HY?AS0baMQcng7jiXbH<AICfX4-3>4%QUykU`L
zLrh}%7U--E)zV)*mp1OaG-r!I_Fo$U0UeY6d%%XOuVl|<Lp1`tl!^Jcvaca;USi#f
zf|lzt17HL=w?XY~pAFSO?3;u(?ilbI*x_r4$TkJc*ig-B<7%Z0HcN5H%0UnC1?aG$
z`m~-aOf7H&xLSqE3&2I-MR5}!8#wX@>ZC_L47AC!F1kH{XQIY@oJ-qpW#AVG)Y)lk
P00000NkvXXu0mjfq)&R7
literal 0
HcmV?d00001
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 715ca3c..23f1f8b 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -936,7 +936,7 @@
<enum name="KEYCODE_MEDIA_REWIND" value="89" />
<enum name="KEYCODE_MEDIA_FAST_FORWARD" value="90" />
<enum name="KEYCODE_MUTE" value="91" />
- enum name="KEYCODE_PAGE_UP" value="92" />
+ <enum name="KEYCODE_PAGE_UP" value="92" />
<enum name="KEYCODE_PAGE_DOWN" value="93" />
<enum name="KEYCODE_PICTSYMBOLS" value="94" />
<enum name="KEYCODE_SWITCH_CHARSET" value="95" />
@@ -955,6 +955,8 @@
<enum name="KEYCODE_BUTTON_START" value="108" />
<enum name="KEYCODE_BUTTON_SELECT" value="109" />
<enum name="KEYCODE_BUTTON_MODE" value="110" />
+ <enum name="KEYCODE_BUTTON_STYLUS" value="111" />
+ <enum name="KEYCODE_BUTTON_STYLUS2" value="112" />
<enum name="KEYCODE_FUNC_1" value="92" />
<enum name="KEYCODE_FUNC_2" value="93" />
<enum name="KEYCODE_FUNC_3" value="94" />
diff --git a/include/ui/EventHub.h b/include/ui/EventHub.h
index d78e35f..e35427e 100644
--- a/include/ui/EventHub.h
+++ b/include/ui/EventHub.h
@@ -119,6 +119,9 @@ enum {
/* The input device has switches. */
INPUT_DEVICE_CLASS_SWITCH = 0x00000080,
+
+ /* The input device is an active pen digitizer */
+ INPUT_DEVICE_CLASS_ACTIVE_DIGITIZER = 0x00000100,
};
/*
diff --git a/include/ui/Input.h b/include/ui/Input.h
index 8c6018b..efe687f 100644
--- a/include/ui/Input.h
+++ b/include/ui/Input.h
@@ -251,6 +251,8 @@ public:
inline int32_t getAction() const { return mAction; }
+ inline int32_t getToolType() const { return mToolType; }
+
inline int32_t getFlags() const { return mFlags; }
inline int32_t getEdgeFlags() const { return mEdgeFlags; }
@@ -371,6 +373,7 @@ public:
int32_t deviceId,
int32_t source,
int32_t action,
+ int32_t toolType,
int32_t flags,
int32_t edgeFlags,
int32_t metaState,
@@ -399,6 +402,7 @@ public:
private:
int32_t mAction;