aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/android
diff options
context:
space:
mode:
authorCameron Cawley2019-10-13 21:31:18 +0100
committerFilippos Karapetis2019-10-23 07:41:31 +0300
commit94a53ccb0f1dc2d67124b382f26d51582aa4f394 (patch)
tree1e762d2f07e4757ee18e9a9b77cb2452ba1383e1 /backends/platform/android
parente620372d87271767899743b3521a4055af36cc61 (diff)
downloadscummvm-rg350-94a53ccb0f1dc2d67124b382f26d51582aa4f394.tar.gz
scummvm-rg350-94a53ccb0f1dc2d67124b382f26d51582aa4f394.tar.bz2
scummvm-rg350-94a53ccb0f1dc2d67124b382f26d51582aa4f394.zip
ANDROID: Add swap menu and back buttons option
Diffstat (limited to 'backends/platform/android')
-rw-r--r--backends/platform/android/android.cpp16
-rw-r--r--backends/platform/android/android.h1
-rw-r--r--backends/platform/android/events.cpp37
3 files changed, 42 insertions, 12 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 7d5bce9c85..c1f8a6c493 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -102,7 +102,8 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
_dpad_scale(4),
_fingersDown(0),
_trackball_scale(2),
- _joystick_scale(10) {
+ _joystick_scale(10),
+ _swap_menu_and_back(false) {
_fsFactory = new POSIXFilesystemFactory();
@@ -307,6 +308,7 @@ void OSystem_Android::initBackend() {
ConfMan.registerDefault("aspect_ratio", true);
ConfMan.registerDefault("touchpad_mouse_mode", true);
ConfMan.registerDefault("onscreen_control", true);
+ ConfMan.registerDefault("swap_menu_and_back", false);
ConfMan.setInt("autosave_period", 0);
ConfMan.setBool("FM_high_quality", false);
@@ -325,6 +327,11 @@ void OSystem_Android::initBackend() {
else
ConfMan.setBool("onscreen_control", true);
+ if (ConfMan.hasKey("swap_menu_and_back_buttons"))
+ _swap_menu_and_back = ConfMan.getBool("swap_menu_and_back_buttons");
+ else
+ ConfMan.setBool("swap_menu_and_back_buttons", false);
+
// must happen before creating TimerManager to avoid race in
// creating EventManager
setupKeymapper();
@@ -365,6 +372,7 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureOpenUrl ||
f == kFeatureTouchpadMode ||
f == kFeatureOnScreenControl ||
+ f == kFeatureSwapMenuAndBackButtons ||
f == kFeatureClipboardSupport) {
return true;
}
@@ -387,6 +395,10 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) {
ConfMan.setBool("onscreen_control", enable);
JNI::showKeyboardControl(enable);
break;
+ case kFeatureSwapMenuAndBackButtons:
+ ConfMan.setBool("swap_menu_and_back_buttons", enable);
+ _swap_menu_and_back = enable;
+ break;
default:
ModularBackend::setFeatureState(f, enable);
break;
@@ -401,6 +413,8 @@ bool OSystem_Android::getFeatureState(Feature f) {
return ConfMan.getBool("touchpad_mouse_mode");
case kFeatureOnScreenControl:
return ConfMan.getBool("onscreen_control");
+ case kFeatureSwapMenuAndBackButtons:
+ return ConfMan.getBool("swap_menu_and_back_buttons");
default:
return ModularBackend::getFeatureState(f);
}
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 96219c28de..b13b42e5bf 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -112,6 +112,7 @@ private:
int _dpad_scale;
int _joystick_scale;
int _fingersDown;
+ bool _swap_menu_and_back;
void clipMouse(Common::Point &p);
void scaleMouse(Common::Point &p, int x, int y, bool deductDrawRect = true, bool touchpadMode = false);
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 465c6a1531..84a95ffa3c 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -99,23 +99,38 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
// special case. we'll only get it's up event
case JKEYCODE_BACK:
- e.kbd.keycode = Common::KEYCODE_ESCAPE;
- e.kbd.ascii = Common::ASCII_ESCAPE;
-
- lockMutex(_event_queue_lock);
- e.type = Common::EVENT_KEYDOWN;
- _event_queue.push(e);
- e.type = Common::EVENT_KEYUP;
- _event_queue.push(e);
- unlockMutex(_event_queue_lock);
+ if (_swap_menu_and_back) {
+ e.type = Common::EVENT_MAINMENU;
+ pushEvent(e);
+ } else {
+ e.kbd.keycode = Common::KEYCODE_ESCAPE;
+ e.kbd.ascii = Common::ASCII_ESCAPE;
+ lockMutex(_event_queue_lock);
+ e.type = Common::EVENT_KEYDOWN;
+ _event_queue.push(e);
+ e.type = Common::EVENT_KEYUP;
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+ }
return;
// special case. we'll only get it's up event
case JKEYCODE_MENU:
- e.type = Common::EVENT_MAINMENU;
+ if (_swap_menu_and_back) {
+ e.kbd.keycode = Common::KEYCODE_ESCAPE;
+ e.kbd.ascii = Common::ASCII_ESCAPE;
- pushEvent(e);
+ lockMutex(_event_queue_lock);
+ e.type = Common::EVENT_KEYDOWN;
+ _event_queue.push(e);
+ e.type = Common::EVENT_KEYUP;
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+ } else {
+ e.type = Common::EVENT_MAINMENU;
+ pushEvent(e);
+ }
return;