From 0def54a60d8a5c6e63bb5db238bbadf388dede97 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Fri, 21 Feb 2014 16:29:23 +0000 Subject: ANDROID: Fix runtime failure on earlier versions of Android. 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 a50ede20 with addition of OUYA support. This solution is as recommended on the Android developer portal. --- .../android/org/scummvm/scummvm/ScummVMEvents.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'backends/platform/android') diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java index 702215341b..eef5d1911b 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java +++ b/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; @@ -69,13 +70,16 @@ public class ScummVMEvents implements } 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; } -- cgit v1.2.3