BACKENDS: Allow activating the system virtual keyboard using the keymapper

This commit is contained in:
Cameron Cawley 2021-08-27 21:39:19 +01:00 committed by Eugene Sandulenko
parent bdc9ad5783
commit 6dbb129f40
6 changed files with 12 additions and 22 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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() {

View File

@ -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,