aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMarcus Comstedt2013-08-08 14:53:36 +0200
committerMarcus Comstedt2013-08-08 14:53:36 +0200
commita50ede203b0424d800d2a1d4460121f9f1de8e7a (patch)
tree0d3fd31307258ca481d37c956415f74525a94265 /backends
parent1b69f8aedee240af79ea871c32a9caadc6a0dd98 (diff)
downloadscummvm-rg350-a50ede203b0424d800d2a1d4460121f9f1de8e7a.tar.gz
scummvm-rg350-a50ede203b0424d800d2a1d4460121f9f1de8e7a.tar.bz2
scummvm-rg350-a50ede203b0424d800d2a1d4460121f9f1de8e7a.zip
ANDROID: Add support for joystick motion
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/android/android.cpp3
-rw-r--r--backends/platform/android/android.h1
-rw-r--r--backends/platform/android/events.cpp26
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java8
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java14
5 files changed, 51 insertions, 1 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index ad80ea7f8c..5e3d1d0db6 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -146,7 +146,8 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
_touchpad_scale(66),
_dpad_scale(4),
_fingersDown(0),
- _trackball_scale(2) {
+ _trackball_scale(2),
+ _joystick_scale(10) {
_fsFactory = new POSIXFilesystemFactory();
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index b4813b3bdf..704ce12f60 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -231,6 +231,7 @@ private:
int _touchpad_scale;
int _trackball_scale;
int _dpad_scale;
+ int _joystick_scale;
int _fingersDown;
void clipMouse(Common::Point &p);
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 5ad9ed825c..4d7ef9caf2 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -65,6 +65,7 @@ enum {
JE_RMB_UP = 12,
JE_MOUSE_MOVE = 13,
JE_GAMEPAD = 14,
+ JE_JOYSTICK = 15,
JE_QUIT = 0x1000
};
@@ -896,6 +897,31 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
break;
+ case JE_JOYSTICK:
+ e.mouse = getEventManager()->getMousePos();
+
+ switch (arg1) {
+ case JACTION_MULTIPLE:
+ e.type = Common::EVENT_MOUSEMOVE;
+
+ // already multiplied by 100
+ e.mouse.x += arg2 * _joystick_scale / _eventScaleX;
+ e.mouse.y += arg3 * _joystick_scale / _eventScaleY;
+
+ clipMouse(e.mouse);
+
+ break;
+ default:
+ LOGE("unhandled jaction on joystick: %d", arg1);
+ return;
+ }
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+
+ return;
+
case JE_QUIT:
e.type = Common::EVENT_QUIT;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 829a948435..5d041dafd2 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -240,6 +240,14 @@ public class ScummVMActivity extends Activity {
return false;
}
+ @Override
+ public boolean onGenericMotionEvent(final MotionEvent e) {
+ if (_events != null)
+ return _events.onGenericMotionEvent(e);
+
+ return false;
+ }
+
private void showKeyboard(boolean show) {
SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface);
InputMethodManager imm = (InputMethodManager)
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
index 9278e7ff1c..21f177f0c7 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -9,6 +9,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.GestureDetector;
+import android.view.InputDevice;
import android.view.inputmethod.InputMethodManager;
public class ScummVMEvents implements
@@ -32,6 +33,7 @@ public class ScummVMEvents implements
public static final int JE_RMB_UP = 12;
public static final int JE_MOUSE_MOVE = 13;
public static final int JE_GAMEPAD = 14;
+ public static final int JE_JOYSTICK = 15;
public static final int JE_QUIT = 0x1000;
final protected Context _context;
@@ -64,6 +66,18 @@ public class ScummVMEvents implements
return true;
}
+ 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;
+ }
+
+ return false;
+ }
+
final static int MSG_MENU_LONG_PRESS = 1;
final private Handler keyHandler = new Handler() {