summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorPrashant Malani <pmalani@google.com>2015-08-25 17:41:34 -0700
committerPrashant Malani <pmalani@google.com>2015-08-28 15:58:24 -0700
commit67322b1ff058d9abadd94c10b0ce167508ead6f5 (patch)
tree625febf82d20a695b1343889b355eaf0bd74f362 /core/java/android/view
parent92fb534298dc2d7e91e6dc1a8d8454b7f3f173f8 (diff)
downloadframeworks_base-67322b1ff058d9abadd94c10b0ce167508ead6f5.zip
frameworks_base-67322b1ff058d9abadd94c10b0ce167508ead6f5.tar.gz
frameworks_base-67322b1ff058d9abadd94c10b0ce167508ead6f5.tar.bz2
Add rotary encoder input source
Devices which have rotating encoders for input devices can mark their MotionEvents as belonging to SOURCE_ROTARY_ENCODER. This is better than mapping such input events to pre-existing input sources, which may result is conflation regarding the expected behaviour of these older input sources. Events emanating from this input soruce will be accessible to the View hierarchy via onGenericMotionEvent(). We also introduce a new axis constant, AXIS_SCROLL, for axis movements that aren't strictly vertical or horizontal. Bug: 18707397 Change-Id: I1ad9af7c87b97d2c98b58b71cab2b780d0c86ec3
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/InputDevice.java9
-rw-r--r--core/java/android/view/MotionEvent.java17
2 files changed, 26 insertions, 0 deletions
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index cc4598d..5592f7a 100644
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -256,6 +256,15 @@ public final class InputDevice implements Parcelable {
public static final int SOURCE_TOUCH_NAVIGATION = 0x00200000 | SOURCE_CLASS_NONE;
/**
+ * The input source is a rotating encoder device whose motions should be interpreted as akin to
+ * those of a scroll wheel.
+ *
+ * @see #SOURCE_CLASS_NONE
+ * {@hide}
+ */
+ public static final int SOURCE_ROTARY_ENCODER = 0x00400000 | SOURCE_CLASS_NONE;
+
+ /**
* The input source is a joystick.
* (It may also be a {@link #SOURCE_GAMEPAD}).
*
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index 6026d04..527d7e5 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -962,6 +962,22 @@ public final class MotionEvent extends InputEvent implements Parcelable {
public static final int AXIS_TILT = 25;
/**
+ * Axis constant: Generic scroll axis of a motion event.
+ * <p>
+ * <ul>
+ * <li>Reports the relative movement of the generic scrolling device.
+ * </ul>
+ * </p><p>
+ * This axis should be used for scroll events that are neither strictly vertical nor horizontal.
+ * A good example would be the rotation of a rotary encoder input device.
+ * </p>
+ *
+ * @see #getAxisValue(int, int)
+ * {@hide}
+ */
+ public static final int AXIS_SCROLL = 26;
+
+ /**
* Axis constant: Generic 1 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*
@@ -1171,6 +1187,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
names.append(AXIS_BRAKE, "AXIS_BRAKE");
names.append(AXIS_DISTANCE, "AXIS_DISTANCE");
names.append(AXIS_TILT, "AXIS_TILT");
+ names.append(AXIS_SCROLL, "AXIS_SCROLL");
names.append(AXIS_GENERIC_1, "AXIS_GENERIC_1");
names.append(AXIS_GENERIC_2, "AXIS_GENERIC_2");
names.append(AXIS_GENERIC_3, "AXIS_GENERIC_3");