Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -24194,6 +24194,7 @@ package android.view { method public float getMin(); method public float getRange(); method public int getSource(); method public boolean isFromSource(int); } public abstract class InputEvent implements android.os.Parcelable { Loading @@ -24202,6 +24203,7 @@ package android.view { method public abstract int getDeviceId(); method public abstract long getEventTime(); method public abstract int getSource(); method public boolean isFromSource(int); field public static final android.os.Parcelable.Creator CREATOR; } core/java/android/view/InputDevice.java +13 −0 Original line number Diff line number Diff line Loading @@ -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. Loading core/java/android/view/InputEvent.java +12 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,18 @@ public abstract class InputEvent implements Parcelable { */ public abstract void setSource(int source); /** * 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; } /** * Copies the event. * Loading core/java/android/view/View.java +2 −2 Original line number Diff line number Diff line Loading @@ -8112,13 +8112,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * delivered to the focused view. * </p> * <pre> public boolean onGenericMotionEvent(MotionEvent event) { * if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { * if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) { * if (event.getAction() == MotionEvent.ACTION_MOVE) { * // process the joystick movement... * return true; * } * } * if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { * if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { * switch (event.getAction()) { * case MotionEvent.ACTION_HOVER_MOVE: * // process the mouse hover movement... Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -24194,6 +24194,7 @@ package android.view { method public float getMin(); method public float getRange(); method public int getSource(); method public boolean isFromSource(int); } public abstract class InputEvent implements android.os.Parcelable { Loading @@ -24202,6 +24203,7 @@ package android.view { method public abstract int getDeviceId(); method public abstract long getEventTime(); method public abstract int getSource(); method public boolean isFromSource(int); field public static final android.os.Parcelable.Creator CREATOR; }
core/java/android/view/InputDevice.java +13 −0 Original line number Diff line number Diff line Loading @@ -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. Loading
core/java/android/view/InputEvent.java +12 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,18 @@ public abstract class InputEvent implements Parcelable { */ public abstract void setSource(int source); /** * 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; } /** * Copies the event. * Loading
core/java/android/view/View.java +2 −2 Original line number Diff line number Diff line Loading @@ -8112,13 +8112,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * delivered to the focused view. * </p> * <pre> public boolean onGenericMotionEvent(MotionEvent event) { * if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { * if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) { * if (event.getAction() == MotionEvent.ACTION_MOVE) { * // process the joystick movement... * return true; * } * } * if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { * if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { * switch (event.getAction()) { * case MotionEvent.ACTION_HOVER_MOVE: * // process the mouse hover movement... Loading