mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 12:39:56 +00:00
ANDROID: Add swap menu and back buttons option
This commit is contained in:
parent
e620372d87
commit
94a53ccb0f
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user