[Scummvm-git-logs] scummvm master -> 38beac8d9598be3f6ff8abde58d02eef0ac81560
bluegr
bluegr at gmail.com
Wed Oct 23 06:41:35 CEST 2019
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
94a53ccb0f ANDROID: Add swap menu and back buttons option
38beac8d95 ANDROID: Simplify handling of menu/back button events
Commit: 94a53ccb0f1dc2d67124b382f26d51582aa4f394
https://github.com/scummvm/scummvm/commit/94a53ccb0f1dc2d67124b382f26d51582aa4f394
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2019-10-23T07:41:31+03:00
Commit Message:
ANDROID: Add swap menu and back buttons option
Changed paths:
backends/platform/android/android.cpp
backends/platform/android/android.h
backends/platform/android/events.cpp
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 7d5bce9..c1f8a6c 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 96219c2..b13b42e 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 465c6a1..84a95ff 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;
Commit: 38beac8d9598be3f6ff8abde58d02eef0ac81560
https://github.com/scummvm/scummvm/commit/38beac8d9598be3f6ff8abde58d02eef0ac81560
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2019-10-23T07:41:31+03:00
Commit Message:
ANDROID: Simplify handling of menu/back button events
Changed paths:
backends/platform/android/android.h
backends/platform/android/events.cpp
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index b13b42e..bd6f015 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -119,6 +119,7 @@ private:
public:
virtual void pushEvent(const Common::Event &event);
+ virtual void pushKeyPressEvent(Common::Event &event);
virtual bool pollEvent(Common::Event &event);
virtual uint32 getMillis(bool skipRecord = false);
virtual void delayMillis(uint msecs);
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 84a95ff..da35fb0 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -105,13 +105,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
} 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);
+ pushKeyPressEvent(e);
}
return;
@@ -120,13 +114,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
if (_swap_menu_and_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);
+ pushKeyPressEvent(e);
} else {
e.type = Common::EVENT_MAINMENU;
pushEvent(e);
@@ -746,4 +734,13 @@ void OSystem_Android::pushEvent(const Common::Event &event) {
unlockMutex(_event_queue_lock);
}
+void OSystem_Android::pushKeyPressEvent(Common::Event &event) {
+ lockMutex(_event_queue_lock);
+ event.type = Common::EVENT_KEYDOWN;
+ _event_queue.push(event);
+ event.type = Common::EVENT_KEYUP;
+ _event_queue.push(event);
+ unlockMutex(_event_queue_lock);
+}
+
#endif
More information about the Scummvm-git-logs
mailing list