diff options
author | David Turner | 2013-10-08 18:26:49 -0700 |
---|---|---|
committer | David Turner | 2013-10-08 18:26:49 -0700 |
commit | d4d90b3f07bb379470a2090a8771e4c73be55ff8 (patch) | |
tree | d5ad543ba1ab17eea5397ce2046487bc9f1bc174 /backends | |
parent | 38c259b14837d8302f0b7b6df572ddbfa9cb319f (diff) | |
parent | 7a1ffe8c59964a502c0168264f9b2872afb94122 (diff) | |
download | scummvm-rg350-d4d90b3f07bb379470a2090a8771e4c73be55ff8.tar.gz scummvm-rg350-d4d90b3f07bb379470a2090a8771e4c73be55ff8.tar.bz2 scummvm-rg350-d4d90b3f07bb379470a2090a8771e4c73be55ff8.zip |
Merge pull request #372 from zeldin/ouya
Basic OUYA support
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/android/android.cpp | 3 | ||||
-rw-r--r-- | backends/platform/android/android.h | 1 | ||||
-rw-r--r-- | backends/platform/android/android.mk | 5 | ||||
-rw-r--r-- | backends/platform/android/events.cpp | 111 | ||||
-rw-r--r-- | backends/platform/android/org/scummvm/scummvm/MouseHelper.java | 18 | ||||
-rw-r--r-- | backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java | 8 | ||||
-rw-r--r-- | backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java | 36 |
7 files changed, 180 insertions, 2 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/android.mk b/backends/platform/android/android.mk index f498c671de..b0df5e7796 100644 --- a/backends/platform/android/android.mk +++ b/backends/platform/android/android.mk @@ -27,11 +27,14 @@ PORT_DISTFILES = $(PATH_DIST)/README.Android RESOURCES = \ $(PATH_RESOURCES)/values/strings.xml \ + $(PATH_RESOURCES)/values/margins.xml \ + $(PATH_RESOURCES)/values-television/margins.xml \ $(PATH_RESOURCES)/layout/main.xml \ $(PATH_RESOURCES)/layout/splash.xml \ $(PATH_RESOURCES)/drawable/gradient.xml \ $(PATH_RESOURCES)/drawable/scummvm.png \ - $(PATH_RESOURCES)/drawable/scummvm_big.png + $(PATH_RESOURCES)/drawable/scummvm_big.png \ + $(PATH_RESOURCES)/drawable-xhdpi/ouya_icon.png PLUGIN_RESOURCES = \ $(PATH_RESOURCES)/values/strings.xml \ diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index db1261e432..5c42db9347 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -64,6 +64,10 @@ enum { JE_RMB_DOWN = 11, JE_RMB_UP = 12, JE_MOUSE_MOVE = 13, + JE_GAMEPAD = 14, + JE_JOYSTICK = 15, + JE_MMB_DOWN = 16, + JE_MMB_UP = 17, JE_QUIT = 0x1000 }; @@ -109,6 +113,25 @@ enum { JKEYCODE_DPAD_CENTER = 23 }; +// gamepad +enum { + JKEYCODE_BUTTON_A = 96, + JKEYCODE_BUTTON_B = 97, + JKEYCODE_BUTTON_C = 98, + JKEYCODE_BUTTON_X = 99, + JKEYCODE_BUTTON_Y = 100, + JKEYCODE_BUTTON_Z = 101, + JKEYCODE_BUTTON_L1 = 102, + JKEYCODE_BUTTON_R1 = 103, + JKEYCODE_BUTTON_L2 = 104, + JKEYCODE_BUTTON_R2 = 105, + JKEYCODE_BUTTON_THUMBL = 106, + JKEYCODE_BUTTON_THUMBR = 107, + JKEYCODE_BUTTON_START = 108, + JKEYCODE_BUTTON_SELECT = 109, + JKEYCODE_BUTTON_MODE = 110, +}; + // meta modifier enum { JMETA_SHIFT = 0x01, @@ -827,6 +850,94 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, return; + case JE_GAMEPAD: + switch (arg1) { + case JACTION_DOWN: + e.type = Common::EVENT_KEYDOWN; + break; + case JACTION_UP: + e.type = Common::EVENT_KEYUP; + break; + default: + LOGE("unhandled jaction on gamepad key: %d", arg1); + return; + } + + switch (arg2) { + case JKEYCODE_BUTTON_A: + case JKEYCODE_BUTTON_B: + switch (arg1) { + case JACTION_DOWN: + e.type = (arg2 == JKEYCODE_BUTTON_A? + Common::EVENT_LBUTTONDOWN : + Common::EVENT_RBUTTONDOWN); + break; + case JACTION_UP: + e.type = (arg2 == JKEYCODE_BUTTON_A? + Common::EVENT_LBUTTONUP : + Common::EVENT_RBUTTONUP); + break; + } + + e.mouse = getEventManager()->getMousePos(); + + break; + + case JKEYCODE_BUTTON_X: + e.kbd.keycode = Common::KEYCODE_ESCAPE; + e.kbd.ascii = Common::ASCII_ESCAPE; + break; + + default: + LOGW("unmapped gamepad key: %d", arg2); + return; + } + + lockMutex(_event_queue_lock); + _event_queue.push(e); + unlockMutex(_event_queue_lock); + + 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_MMB_DOWN: + e.type = Common::EVENT_MAINMENU; + + lockMutex(_event_queue_lock); + _event_queue.push(e); + unlockMutex(_event_queue_lock); + + return; + + case JE_MMB_UP: + // No action + + return; + case JE_QUIT: e.type = Common::EVENT_QUIT; diff --git a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java index 999815593f..8990515b84 100644 --- a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java +++ b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java @@ -14,6 +14,7 @@ public class MouseHelper { private long _rmbGuardTime; private boolean _rmbPressed; private boolean _lmbPressed; + private boolean _mmbPressed; /** * Class initialization fails when this throws an exception. @@ -114,6 +115,23 @@ public class MouseHelper { _rmbPressed = false; } + boolean mmbDown = (buttonState & MotionEvent.BUTTON_TERTIARY) == MotionEvent.BUTTON_TERTIARY; + if (mmbDown) { + if (!_mmbPressed) { + // middle mouse button was pressed just now + _scummvm.pushEvent(ScummVMEvents.JE_MMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0); + } + + _mmbPressed = true; + } else { + if (_mmbPressed) { + // middle mouse button was released just now + _scummvm.pushEvent(ScummVMEvents.JE_MMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0); + } + + _mmbPressed = false; + } + return true; } 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 5f51ffac6c..702215341b 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 @@ -31,6 +32,10 @@ public class ScummVMEvents implements public static final int JE_RMB_DOWN = 11; 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_MMB_DOWN = 16; + public static final int JE_MMB_UP = 17; public static final int JE_QUIT = 0x1000; final protected Context _context; @@ -63,6 +68,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() { @@ -177,6 +194,25 @@ public class ScummVMEvents implements (int)(e.getEventTime() - e.getDownTime()), e.getRepeatCount(), 0); return true; + case KeyEvent.KEYCODE_BUTTON_A: + case KeyEvent.KEYCODE_BUTTON_B: + case KeyEvent.KEYCODE_BUTTON_C: + case KeyEvent.KEYCODE_BUTTON_X: + case KeyEvent.KEYCODE_BUTTON_Y: + case KeyEvent.KEYCODE_BUTTON_Z: + case KeyEvent.KEYCODE_BUTTON_L1: + case KeyEvent.KEYCODE_BUTTON_R1: + case KeyEvent.KEYCODE_BUTTON_L2: + case KeyEvent.KEYCODE_BUTTON_R2: + case KeyEvent.KEYCODE_BUTTON_THUMBL: + case KeyEvent.KEYCODE_BUTTON_THUMBR: + case KeyEvent.KEYCODE_BUTTON_START: + case KeyEvent.KEYCODE_BUTTON_SELECT: + case KeyEvent.KEYCODE_BUTTON_MODE: + _scummvm.pushEvent(JE_GAMEPAD, action, keyCode, + (int)(e.getEventTime() - e.getDownTime()), + e.getRepeatCount(), 0); + return true; } _scummvm.pushEvent(JE_KEY, action, keyCode, |