Skip to content

Commit

Permalink
ANDROID: Fix runtime failure on earlier versions of Android.
Browse files Browse the repository at this point in the history
getAxisValue() is only present from Android 3.1 onwards and
usage causes a runtime failure on earlier versions of Android.

This bug was introduced by a50ede2 with addition of OUYA support.

This solution is as recommended on the Android developer portal.
  • Loading branch information
digitall committed Feb 21, 2014
1 parent cda0598 commit 0def54a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -1,5 +1,6 @@
package org.scummvm.scummvm;

import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.content.Context;
Expand Down Expand Up @@ -69,13 +70,16 @@ public boolean onTrackballEvent(MotionEvent e) {
}

public boolean onGenericMotionEvent(final MotionEvent e) {
if((e.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
_scummvm.pushEvent(JE_JOYSTICK, e.getAction(),
(int)(e.getAxisValue(MotionEvent.AXIS_X)*100),
(int)(e.getAxisValue(MotionEvent.AXIS_Y)*100),
0, 0);
return true;
}
// Make sure we're running on Android 3.1 or higher to use getAxisValue()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
if((e.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
_scummvm.pushEvent(JE_JOYSTICK, e.getAction(),
(int)(e.getAxisValue(MotionEvent.AXIS_X)*100),
(int)(e.getAxisValue(MotionEvent.AXIS_Y)*100),
0, 0);
return true;
}
}

return false;
}
Expand Down

0 comments on commit 0def54a

Please sign in to comment.