summaryrefslogtreecommitdiff
path: root/samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2013-03-11 15:57:21 -0700
committerMichael Wright <michaelwr@google.com>2013-03-11 15:57:21 -0700
commit8f48506e2d50a9331baf3086e0c33dbceb7c6a3e (patch)
tree032a1d6246dd4265160358e823f2a317da619034 /samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java
parentb74c3ef70bd124cabb9c0d57a95a05b4e2b30c43 (diff)
Update ApiDemos to use new input source check
Change-Id: Iab20881dca49cfef66fa35396942cdb5045137aa
Diffstat (limited to 'samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java')
-rw-r--r--samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java10
1 files changed, 3 insertions, 7 deletions
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java b/samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java
index ce7c749df..10b2f9a72 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java
@@ -142,7 +142,7 @@ public class GameControllerInput extends Activity
public boolean dispatchGenericMotionEvent(MotionEvent event) {
// Check that the event came from a joystick since a generic motion event
// could be almost anything.
- if (isJoystick(event.getSource())
+ if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)
&& event.getAction() == MotionEvent.ACTION_MOVE) {
// Update device state for visualization and logging.
InputDeviceState state = getInputDeviceState(event.getDeviceId());
@@ -195,10 +195,6 @@ public class GameControllerInput extends Activity
}
}
- private static boolean isJoystick(int source) {
- return (source & InputDevice.SOURCE_CLASS_JOYSTICK) != 0;
- }
-
/**
* Tracks the state of joystick axes and game controller buttons for a particular
* input device for diagnostic purposes.
@@ -215,7 +211,7 @@ public class GameControllerInput extends Activity
int numAxes = 0;
final List<MotionRange> ranges = device.getMotionRanges();
for (MotionRange range : ranges) {
- if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
+ if (range.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) {
numAxes += 1;
}
}
@@ -224,7 +220,7 @@ public class GameControllerInput extends Activity
mAxisValues = new float[numAxes];
int i = 0;
for (MotionRange range : ranges) {
- if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
+ if (range.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) {
mAxes[i++] = range.getAxis();
}
}