Skip to content

Commit

Permalink
ANDROID: Fix Android pre3.1 compatibility.
Browse files Browse the repository at this point in the history
This was broken by a50ede2.
  • Loading branch information
digitall committed Feb 27, 2014
1 parent 885013f commit cbf0852
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
1 change: 1 addition & 0 deletions backends/platform/android/android.mk
Expand Up @@ -7,6 +7,7 @@ ANDROID_PLUGIN_VERSIONCODE = 6
JAVA_FILES = \
ScummVM.java \
ScummVMEvents.java \
ScummVMEventsHoneycomb.java \
ScummVMApplication.java \
ScummVMActivity.java \
EditableSurfaceView.java \
Expand Down
Expand Up @@ -4,6 +4,7 @@
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.util.DisplayMetrics;
Expand Down Expand Up @@ -169,7 +170,14 @@ public void onClick(DialogInterface dialog,
_mouseHelper.attach(main_surface);
}

_events = new ScummVMEvents(this, _scummvm, _mouseHelper);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1)
{
_events = new ScummVMEvents(this, _scummvm, _mouseHelper);
}
else
{
_events = new ScummVMEventsHoneycomb(this, _scummvm, _mouseHelper);
}

main_surface.setOnKeyListener(_events);
main_surface.setOnTouchListener(_events);
Expand Down
14 changes: 1 addition & 13 deletions backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -1,6 +1,5 @@
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,18 +68,7 @@ public boolean onTrackballEvent(MotionEvent e) {
return true;
}

public boolean onGenericMotionEvent(final MotionEvent e) {
// 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;
}
}

public boolean onGenericMotionEvent(MotionEvent e) {
return false;
}

Expand Down
@@ -0,0 +1,25 @@
package org.scummvm.scummvm;

import android.content.Context;
import android.view.MotionEvent;
import android.view.InputDevice;

public class ScummVMEventsHoneycomb extends ScummVMEvents {

public ScummVMEventsHoneycomb(Context context, ScummVM scummvm, MouseHelper mouseHelper) {
super(context, scummvm, mouseHelper);
}

@Override
public boolean onGenericMotionEvent(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;
}

return false;
}
}

0 comments on commit cbf0852

Please sign in to comment.