summaryrefslogtreecommitdiff
path: root/core/java/android/view/InputDevice.java
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2013-03-08 14:58:14 -0800
committerMichael Wright <michaelwr@google.com>2013-03-11 16:02:51 -0700
commit74e4156e5c62392c37f4a70358de30dcfff4956f (patch)
treeff7079cdfb9615ea100bcbc2535e7d325530adbc /core/java/android/view/InputDevice.java
parente70748e78b0819bf485efdeabe7f8447b201b13a (diff)
Add InputDevice#isFromSource convenience method
Change-Id: If2d2e37bc3fff5a862ea3652c7ef9778018e7ecc
Diffstat (limited to 'core/java/android/view/InputDevice.java')
-rw-r--r--core/java/android/view/InputDevice.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index 3bb9c01d3c3e..c3dc76d81b99 100644
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -633,6 +633,19 @@ public final class InputDevice implements Parcelable {
return mSource;
}
+
+ /**
+ * Determines whether the event is from the given source.
+ *
+ * @param source The input source to check against. This can be a specific device type,
+ * such as {@link InputDevice#SOURCE_TOUCH_NAVIGATION}, or a more generic device class,
+ * such as {@link InputDevice#SOURCE_CLASS_POINTER}.
+ * @return Whether the event is from the given source.
+ */
+ public boolean isFromSource(int source) {
+ return (getSource() & source) == source;
+ }
+
/**
* Gets the inclusive minimum value for the axis.
* @return The inclusive minimum value.