From f18920ba3182087938e245fab8e3e3008a39606b Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 12 Jun 2015 15:24:38 +0100 Subject: Add new SOURCE_BLUETOOTH_STYLUS. Bug: 21531826 Change-Id: Ib3448230d542a2aadb0f697db33451f69e089612 --- api/current.txt | 1 + api/system-current.txt | 1 + core/java/android/view/InputDevice.java | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/api/current.txt b/api/current.txt index fb60f1c..e73c4d0 100644 --- a/api/current.txt +++ b/api/current.txt @@ -34905,6 +34905,7 @@ package android.view { field public static final deprecated int MOTION_RANGE_X = 0; // 0x0 field public static final deprecated int MOTION_RANGE_Y = 1; // 0x1 field public static final int SOURCE_ANY = -256; // 0xffffff00 + field public static final int SOURCE_BLUETOOTH_STYLUS = 49154; // 0xc002 field public static final int SOURCE_CLASS_BUTTON = 1; // 0x1 field public static final int SOURCE_CLASS_JOYSTICK = 16; // 0x10 field public static final int SOURCE_CLASS_MASK = 255; // 0xff diff --git a/api/system-current.txt b/api/system-current.txt index 7816c3f..a8cd2d8 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -37175,6 +37175,7 @@ package android.view { field public static final deprecated int MOTION_RANGE_X = 0; // 0x0 field public static final deprecated int MOTION_RANGE_Y = 1; // 0x1 field public static final int SOURCE_ANY = -256; // 0xffffff00 + field public static final int SOURCE_BLUETOOTH_STYLUS = 49154; // 0xc002 field public static final int SOURCE_CLASS_BUTTON = 1; // 0x1 field public static final int SOURCE_CLASS_JOYSTICK = 16; // 0x10 field public static final int SOURCE_CLASS_MASK = 255; // 0xff diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java index f39d1f5..cc4598d 100644 --- a/core/java/android/view/InputDevice.java +++ b/core/java/android/view/InputDevice.java @@ -201,6 +201,35 @@ public final class InputDevice implements Parcelable { public static final int SOURCE_STYLUS = 0x00004000 | SOURCE_CLASS_POINTER; /** + * The input device is a Bluetooth stylus. + *

+ * Note that this bit merely indicates that an input device is capable of + * obtaining input from a Bluetooth stylus. To determine whether a given + * touch event was produced by a stylus, examine the tool type returned by + * {@link MotionEvent#getToolType(int)} for each individual pointer. + *

+ * A single touch event may multiple pointers with different tool types, + * such as an event that has one pointer with tool type + * {@link MotionEvent#TOOL_TYPE_FINGER} and another pointer with tool type + * {@link MotionEvent#TOOL_TYPE_STYLUS}. So it is important to examine + * the tool type of each pointer, regardless of the source reported + * by {@link MotionEvent#getSource()}. + *

+ * A bluetooth stylus generally receives its pressure and button state + * information from the stylus itself, and derives the rest from another + * source. For example, a Bluetooth stylus used in conjunction with a + * touchscreen would derive its contact position and pointer size from the + * touchscreen and may not be any more accurate than other tools such as + * fingers. + *

+ * + * @see #SOURCE_STYLUS + * @see #SOURCE_CLASS_POINTER + */ + public static final int SOURCE_BLUETOOTH_STYLUS = + 0x00008000 | SOURCE_STYLUS; + + /** * The input source is a trackball. * * @see #SOURCE_CLASS_TRACKBALL -- cgit v1.1