aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Turner2013-10-08 18:26:49 -0700
committerDavid Turner2013-10-08 18:26:49 -0700
commitd4d90b3f07bb379470a2090a8771e4c73be55ff8 (patch)
treed5ad543ba1ab17eea5397ce2046487bc9f1bc174
parent38c259b14837d8302f0b7b6df572ddbfa9cb319f (diff)
parent7a1ffe8c59964a502c0168264f9b2872afb94122 (diff)
downloadscummvm-rg350-d4d90b3f07bb379470a2090a8771e4c73be55ff8.tar.gz
scummvm-rg350-d4d90b3f07bb379470a2090a8771e4c73be55ff8.tar.bz2
scummvm-rg350-d4d90b3f07bb379470a2090a8771e4c73be55ff8.zip
Merge pull request #372 from zeldin/ouya
Basic OUYA support
-rw-r--r--backends/platform/android/android.cpp3
-rw-r--r--backends/platform/android/android.h1
-rw-r--r--backends/platform/android/android.mk5
-rw-r--r--backends/platform/android/events.cpp111
-rw-r--r--backends/platform/android/org/scummvm/scummvm/MouseHelper.java18
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java8
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java36
-rwxr-xr-xconfigure11
-rw-r--r--dists/android/AndroidManifest.xml1
-rw-r--r--dists/android/AndroidManifest.xml.in1
-rw-r--r--dists/android/res/drawable-xhdpi/ouya_icon.pngbin0 -> 110822 bytes
-rw-r--r--dists/android/res/layout/main.xml4
-rw-r--r--dists/android/res/values-television/margins.xml5
-rw-r--r--dists/android/res/values/margins.xml5
14 files changed, 205 insertions, 4 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,
diff --git a/configure b/configure
index 5af8992845..cb0b8902fc 100755
--- a/configure
+++ b/configure
@@ -864,6 +864,7 @@ Special configuration feature:
motomagx for MotoMAGX
n64 for Nintendo 64
openpandora for OpenPandora
+ ouya for OUYA
ps2 for PlayStation 2
ps3 for PlayStation 3
psp for PlayStation Portable
@@ -1268,7 +1269,7 @@ get_system_exe_extension $guessed_host
NATIVEEXEEXT=$_exeext
case $_host in
-android | android-v7a)
+android | android-v7a | ouya)
_host_os=android
_host_cpu=arm
_host_alias=arm-linux-androideabi
@@ -2050,6 +2051,12 @@ case $_host_os in
CXXFLAGS="$CXXFLAGS -mfpu=vfp"
LDFLAGS="$LDFLAGS -Wl,--fix-cortex-a8"
;;
+ ouya)
+ CXXFLAGS="$CXXFLAGS -march=armv7-a"
+ CXXFLAGS="$CXXFLAGS -mtune=cortex-a9"
+ CXXFLAGS="$CXXFLAGS -mfloat-abi=softfp"
+ CXXFLAGS="$CXXFLAGS -mfpu=neon"
+ ;;
esac
CXXFLAGS="$CXXFLAGS --sysroot=$ANDROID_NDK/platforms/android-4/arch-arm"
CXXFLAGS="$CXXFLAGS -fpic"
@@ -2338,7 +2345,7 @@ if test -n "$_host"; then
# Cross-compiling mode - add your target here if needed
echo "Cross-compiling to $_host"
case "$_host" in
- android | android-v7a)
+ android | android-v7a | ouya)
# we link a .so as default
LDFLAGS="$LDFLAGS -shared"
LDFLAGS="$LDFLAGS -Wl,-Bsymbolic,--no-undefined"
diff --git a/dists/android/AndroidManifest.xml b/dists/android/AndroidManifest.xml
index 320ed16a6e..16d1ee578b 100644
--- a/dists/android/AndroidManifest.xml
+++ b/dists/android/AndroidManifest.xml
@@ -36,6 +36,7 @@
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
+ <category android:name="tv.ouya.intent.category.GAME"/>
</intent-filter>
</activity>
</application>
diff --git a/dists/android/AndroidManifest.xml.in b/dists/android/AndroidManifest.xml.in
index 8f7887eaf5..bf45ffcc0e 100644
--- a/dists/android/AndroidManifest.xml.in
+++ b/dists/android/AndroidManifest.xml.in
@@ -36,6 +36,7 @@
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
+ <category android:name="tv.ouya.intent.category.GAME"/>
</intent-filter>
</activity>
</application>
diff --git a/dists/android/res/drawable-xhdpi/ouya_icon.png b/dists/android/res/drawable-xhdpi/ouya_icon.png
new file mode 100644
index 0000000000..42f9a2a8ce
--- /dev/null
+++ b/dists/android/res/drawable-xhdpi/ouya_icon.png
Binary files differ
diff --git a/dists/android/res/layout/main.xml b/dists/android/res/layout/main.xml
index 8b0d515d62..31aa345cc7 100644
--- a/dists/android/res/layout/main.xml
+++ b/dists/android/res/layout/main.xml
@@ -9,4 +9,8 @@
android:keepScreenOn="true"
android:focusable="true"
android:focusableInTouchMode="true"
+ android:layout_marginTop="@dimen/verticalMargin"
+ android:layout_marginLeft="@dimen/horizontalMargin"
+ android:layout_marginBottom="@dimen/verticalMargin"
+ android:layout_marginRight="@dimen/horizontalMargin"
/>
diff --git a/dists/android/res/values-television/margins.xml b/dists/android/res/values-television/margins.xml
new file mode 100644
index 0000000000..df586eea34
--- /dev/null
+++ b/dists/android/res/values-television/margins.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <dimen name="verticalMargin">45px</dimen>
+ <dimen name="horizontalMargin">80px</dimen>
+</resources>
diff --git a/dists/android/res/values/margins.xml b/dists/android/res/values/margins.xml
new file mode 100644
index 0000000000..a865687b3a
--- /dev/null
+++ b/dists/android/res/values/margins.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <dimen name="verticalMargin">0px</dimen>
+ <dimen name="horizontalMargin">0px</dimen>
+</resources>