From 9cdda5c045bed4d3a8fe5fc841225f735624e341 Mon Sep 17 00:00:00 2001 From: lubomyr Date: Tue, 31 Jan 2017 22:44:50 +0200 Subject: ANDROIDSDL: implemented checkbox for show/hide on-screen control in Options menu --- backends/platform/androidsdl/androidsdl-sdl.cpp | 20 +++++++++++++++++++- backends/platform/androidsdl/androidsdl-sdl.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/androidsdl/androidsdl-sdl.cpp b/backends/platform/androidsdl/androidsdl-sdl.cpp index ab0c0524f1..1492214b58 100644 --- a/backends/platform/androidsdl/androidsdl-sdl.cpp +++ b/backends/platform/androidsdl/androidsdl-sdl.cpp @@ -28,6 +28,7 @@ #include "backends/events/androidsdl/androidsdl-events.h" #include "backends/graphics/androidsdl/androidsdl-graphics.h" #include +#include void OSystem_ANDROIDSDL::initBackend() { // Create the backend custom managers @@ -50,11 +51,25 @@ void OSystem_ANDROIDSDL::initBackend() { } else { touchpadMode(ConfMan.getBool("touchpad_mouse_mode")); } + + if (!ConfMan.hasKey("onscreen_control")) { + const bool enable = (SDL_ANDROID_GetScreenKeyboardShown() == 0) ? false : true; + ConfMan.setBool("onscreen_control", enable); + } else { + showOnScreenControl(ConfMan.getBool("onscreen_control")); + } // Call parent implementation of this method OSystem_POSIX::initBackend(); } +void OSystem_ANDROIDSDL::showOnScreenControl(bool enable) { + if (enable) + SDL_ANDROID_SetScreenKeyboardShown(1); + else + SDL_ANDROID_SetScreenKeyboardShown(0); +} + void OSystem_ANDROIDSDL::touchpadMode(bool enable) { if (enable) switchToRelativeMouseMode(); @@ -72,9 +87,12 @@ void OSystem_ANDROIDSDL::switchToRelativeMouseMode() { void OSystem_ANDROIDSDL::setFeatureState(Feature f, bool enable) { switch (f) { - case kFeatureTouchpadMode: + case kFeatureTouchpadMode: touchpadMode(enable); break; + case kFeatureOnScreenControl: + showOnScreenControl(enable); + break; } OSystem_POSIX::setFeatureState(f, enable); diff --git a/backends/platform/androidsdl/androidsdl-sdl.h b/backends/platform/androidsdl/androidsdl-sdl.h index 72d2a50093..7bc91247bc 100644 --- a/backends/platform/androidsdl/androidsdl-sdl.h +++ b/backends/platform/androidsdl/androidsdl-sdl.h @@ -32,6 +32,7 @@ public: void touchpadMode(bool enable); void switchToDirectMouseMode(); void switchToRelativeMouseMode(); + void showOnScreenControl(bool enable); #ifdef ENABLE_KEYMAPPER // FIXME: This just calls parent methods, is it needed? -- cgit v1.2.3