From 6dbb129f4007a75e54caa478dac11e1b995c7331 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Fri, 27 Aug 2021 21:39:19 +0100 Subject: [PATCH] BACKENDS: Allow activating the system virtual keyboard using the keymapper --- backends/events/default/default-events.cpp | 16 ++++++++++++---- backends/events/dinguxsdl/dinguxsdl-events.cpp | 2 -- backends/events/gph/gph-events.cpp | 10 ---------- .../events/samsungtvsdl/samsungtvsdl-events.cpp | 2 -- backends/keymapper/keymapper.cpp | 2 -- common/events.h | 2 -- 6 files changed, 12 insertions(+), 22 deletions(-) diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 75ea590f6a2..b1d09414f39 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -155,8 +155,9 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { else if (_shouldReturnToLauncher) event.type = Common::EVENT_RETURN_TO_LAUNCHER; break; -#ifdef ENABLE_VKEYBD + case Common::EVENT_VIRTUAL_KEYBOARD: +#ifdef ENABLE_VKEYBD if (!_vk) break; @@ -169,8 +170,17 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _vk->show(); forwardEvent = false; } - break; +#else + // TODO: Support switching between virtual keyboards at runtime + if (g_system->hasFeature(OSystem::kFeatureVirtualKeyboard)) { + if (g_system->getFeatureState(OSystem::kFeatureVirtualKeyboard)) + g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); + else + g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); + } #endif + break; + case Common::EVENT_RETURN_TO_LAUNCHER: if (ConfMan.getBool("confirm_exit")) { if (_confirmExitDialogActive) { @@ -330,13 +340,11 @@ Common::Keymap *DefaultEventManager::getGlobalKeymap() { act->setEvent(EVENT_MAINMENU); globalKeymap->addAction(act); -#ifdef ENABLE_VKEYBD act = new Action("VIRT", _("Display keyboard")); act->addDefaultInputMapping("C+F7"); act->addDefaultInputMapping("JOY_BACK"); act->setEvent(EVENT_VIRTUAL_KEYBOARD); globalKeymap->addAction(act); -#endif act = new Action("MUTE", _("Toggle mute")); act->addDefaultInputMapping("C+u"); diff --git a/backends/events/dinguxsdl/dinguxsdl-events.cpp b/backends/events/dinguxsdl/dinguxsdl-events.cpp index fa5f1d37dde..cf5f5b5ce72 100644 --- a/backends/events/dinguxsdl/dinguxsdl-events.cpp +++ b/backends/events/dinguxsdl/dinguxsdl-events.cpp @@ -174,12 +174,10 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { return true; } else if (ev.key.keysym.sym == BUT_SELECT) { // virtual keyboard -#ifdef ENABLE_VKEYBD if (ev.type == SDL_KEYDOWN) event.type = Common::EVENT_VIRTUAL_KEYBOARD; return true; -#endif } else if (ev.key.keysym.sym == BUT_START) { // F5, menu in some games ev.key.keysym.sym = SDLK_F5; diff --git a/backends/events/gph/gph-events.cpp b/backends/events/gph/gph-events.cpp index 674326501fb..32332db2f52 100644 --- a/backends/events/gph/gph-events.cpp +++ b/backends/events/gph/gph-events.cpp @@ -379,12 +379,7 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { case BUTTON_R: event.type = Common::EVENT_KEYDOWN; if (_buttonStateL == true) { -#ifdef ENABLE_VKEYBD event.type = Common::EVENT_VIRTUAL_KEYBOARD; -#else - event.kbd.keycode = Common::KEYCODE_0; - event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0); -#endif } else { event.kbd.keycode = Common::KEYCODE_RETURN; event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0); @@ -529,13 +524,8 @@ bool GPHEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { case BUTTON_R: event.type = Common::EVENT_KEYUP; if (_buttonStateL == true) { -#ifdef ENABLE_VKEYBD event.kbd.keycode = Common::KEYCODE_F7; event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0); -#else - event.kbd.keycode = Common::KEYCODE_0; - event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0); -#endif } else { event.kbd.keycode = Common::KEYCODE_RETURN; event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0); diff --git a/backends/events/samsungtvsdl/samsungtvsdl-events.cpp b/backends/events/samsungtvsdl/samsungtvsdl-events.cpp index 61499b566da..60ab4b8c880 100644 --- a/backends/events/samsungtvsdl/samsungtvsdl-events.cpp +++ b/backends/events/samsungtvsdl/samsungtvsdl-events.cpp @@ -38,10 +38,8 @@ bool SamsungTVSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.kbd.ascii = Common::ASCII_F5; return true; } else if (ev.key.keysym.sym == SDLK_F2 && ev.key.keysym.scancode == 21) { -#ifdef ENABLE_VKEYBD event.type = Common::EVENT_VIRTUAL_KEYBOARD; return true; -#endif } break; } diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index ab7137d4ea8..e27c620ca12 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -384,7 +384,6 @@ HardwareInput Keymapper::findHardwareInput(const Event &event) { void Keymapper::hardcodedEventMapping(Event ev) { // TODO: Either add support for long presses to the keymapper // or move this elsewhere as an event observer + source -#ifdef ENABLE_VKEYBD // Trigger virtual keyboard on long press of more than 1 second // of middle mouse button. const uint32 vkeybdTime = 1000; @@ -404,7 +403,6 @@ void Keymapper::hardcodedEventMapping(Event ev) { _delayedEventSource->scheduleEvent(vkeybdEvent, 100); } } -#endif } void Keymapper::resetInputState() { diff --git a/common/events.h b/common/events.h index d6e9c2caa60..69413e80e73 100644 --- a/common/events.h +++ b/common/events.h @@ -89,9 +89,7 @@ enum EventType { EVENT_CUSTOM_ENGINE_ACTION_START = 20, EVENT_CUSTOM_ENGINE_ACTION_END = 21, -#ifdef ENABLE_VKEYBD EVENT_VIRTUAL_KEYBOARD = 22, -#endif EVENT_DROP_FILE = 23,