diff options
| author | Jeff Brown <jeffbrown@google.com> | 2011-06-30 12:01:10 -0700 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2011-06-30 12:01:10 -0700 |
| commit | f53e7c98636b5ef3a954e839b272e09ed0cf7844 (patch) | |
| tree | 5396ea98473ff5989ff65c3d1eda973079f2ff48 /samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java | |
| parent | d9344bb5fddbf1e2d5bba3f34325d822a07a6ba3 (diff) | |
ApiDemos: Fix array indexing bug in game controller demo.
Change-Id: Ic7f1ce8bed39b2c10dd0e583c3ad118095f14752
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.java | 9 |
1 files changed, 5 insertions, 4 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 8aea94916..fdc30e240 100644 --- a/samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java +++ b/samples/ApiDemos/src/com/example/android/apis/view/GameControllerInput.java @@ -41,6 +41,7 @@ import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; +import java.util.List; import java.util.concurrent.atomic.AtomicLong; @@ -155,7 +156,8 @@ public class GameControllerInput extends Activity { mDevice = device; int numAxes = 0; - for (MotionRange range : device.getMotionRanges()) { + final List<MotionRange> ranges = device.getMotionRanges(); + for (MotionRange range : ranges) { if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { numAxes += 1; } @@ -164,11 +166,10 @@ public class GameControllerInput extends Activity { mAxes = new int[numAxes]; mAxisValues = new float[numAxes]; int i = 0; - for (MotionRange range : device.getMotionRanges()) { + for (MotionRange range : ranges) { if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { - numAxes += 1; + mAxes[i++] = range.getAxis(); } - mAxes[i++] = range.getAxis(); } mKeys = new SparseIntArray(); |
