ANDROID: Add swap menu and back buttons option

This commit is contained in:
Cameron Cawley 2019-10-13 21:31:18 +01:00 committed by Filippos Karapetis
parent e620372d87
commit 94a53ccb0f
3 changed files with 42 additions and 12 deletions

View file

@ -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);
}