diff options
-rw-r--r-- | backends/events/default/default-events.cpp | 63 | ||||
-rw-r--r-- | base/main.cpp | 6 | ||||
-rw-r--r-- | common/EventMapper.cpp | 22 | ||||
-rw-r--r-- | common/events.h | 7 | ||||
-rw-r--r-- | gui/gui-manager.cpp | 6 |
5 files changed, 60 insertions, 44 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 3930038870..99d12c73dc 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -102,39 +102,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _currentKeyDown.flags = event.kbd.flags; _keyRepeatTime = time + kKeyRepeatInitialDelay; - // Global Main Menu - if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_F5) { - //do nothing - EventMapper handles this case for us - } -#ifdef ENABLE_VKEYBD - else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.hasFlags(0)) { - if (_vk->isDisplaying()) { - _vk->close(true); - } else { - if (g_engine) - g_engine->pauseEngine(true); - _vk->show(); - if (g_engine) - g_engine->pauseEngine(false); - result = false; - } - } -#endif -#ifdef ENABLE_KEYMAPPER - else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd.hasFlags(0)) { - if (!_remap) { - _remap = true; - Common::RemapDialog _remapDialog; - if (g_engine) - g_engine->pauseEngine(true); - _remapDialog.runModal(); - if (g_engine) - g_engine->pauseEngine(false); - _remap = false; - } - } -#endif - else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) { + if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) { // WORKAROUND: Some engines incorrectly attempt to use the // ascii value instead of the keycode to detect the backspace // key (a non-portable behavior). This fails at least on @@ -188,7 +156,34 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { else if (_shouldRTL) event.type = Common::EVENT_RTL; break; - +#ifdef ENABLE_VKEYBD + case Common::EVENT_VIRTUAL_KEYBOARD: + if (_vk->isDisplaying()) { + _vk->close(true); + } else { + if (g_engine) + g_engine->pauseEngine(true); + _vk->show(); + if (g_engine) + g_engine->pauseEngine(false); + result = false; + } + break; +#endif +#ifdef ENABLE_KEYMAPPER + case Common::EVENT_KEYMAPPER_REMAP: + if (!_remap) { + _remap = true; + Common::RemapDialog _remapDialog; + if (g_engine) + g_engine->pauseEngine(true); + _remapDialog.runModal(); + if (g_engine) + g_engine->pauseEngine(false); + _remap = false; + } + break; +#endif case Common::EVENT_RTL: if (ConfMan.getBool("confirm_exit")) { if (g_engine) diff --git a/base/main.cpp b/base/main.cpp index 81f9b91aa7..9e4a500da6 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -286,11 +286,13 @@ static void setupKeymapper(OSystem &system) { act = new Action(primaryGlobalKeymap, "SKLI", _("Skip line")); act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0)); +#ifdef ENABLE_VKEYBD act = new Action(primaryGlobalKeymap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType); - act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0)); + act->addEvent(EVENT_VIRTUAL_KEYBOARD); +#endif act = new Action(primaryGlobalKeymap, "REMP", _("Remap keys"), kKeyRemapActionType); - act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0)); + act->addEvent(EVENT_KEYMAPPER_REMAP); act = new Action(primaryGlobalKeymap, "FULS", _("Toggle FullScreen")); act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT)); diff --git a/common/EventMapper.cpp b/common/EventMapper.cpp index 6af27b8371..2808a7b5fd 100644 --- a/common/EventMapper.cpp +++ b/common/EventMapper.cpp @@ -27,13 +27,25 @@ namespace Common { List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) { List<Event> events; Event mappedEvent; - if (ev.type == EVENT_KEYDOWN && ev.kbd.hasFlags(KBD_CTRL) && ev.kbd.keycode == KEYCODE_F5) { - mappedEvent.type = EVENT_MAINMENU; + if (ev.type == EVENT_KEYDOWN) { + if (ev.kbd.hasFlags(KBD_CTRL) && ev.kbd.keycode == KEYCODE_F5) { + mappedEvent.type = EVENT_MAINMENU; + } +#ifdef ENABLE_VKEYBD + else if (ev.kbd.keycode == KEYCODE_F7 && ev.kbd.hasFlags(0)) { + mappedEvent.type = EVENT_VIRTUAL_KEYBOARD; + } +#endif +#ifdef ENABLE_KEYMAPPER + else if (ev.kbd.keycode == KEYCODE_F8 && ev.kbd.hasFlags(0)) { + mappedEvent.type = EVENT_KEYMAPPER_REMAP; + } +#endif } - else { - // just pass it through + + // if it didn't get mapped, just pass it through + if (mappedEvent.type == EVENT_INVALID) mappedEvent = ev; - } events.push_back(mappedEvent); return events; } diff --git a/common/events.h b/common/events.h index 5e539f072e..69cca9b54a 100644 --- a/common/events.h +++ b/common/events.h @@ -78,7 +78,12 @@ enum EventType { , // IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use // this, please talk to tsoliman and/or LordHoto. - EVENT_CUSTOM_BACKEND = 18 + EVENT_CUSTOM_BACKEND = 18, + EVENT_KEYMAPPER_REMAP = 19 +#endif +#ifdef ENABLE_VKEYBD + , + EVENT_VIRTUAL_KEYBOARD = 20 #endif }; diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 465af5448f..5f307380ea 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -118,11 +118,13 @@ void GuiManager::initKeymap() { act = new Action(guiMap, "CLIK", _("Mouse click"), kLeftClickActionType); act->addLeftClickEvent(); +#ifdef ENABLE_VKEYBD act = new Action(guiMap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType); - act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0)); + act->addEvent(EVENT_VIRTUAL_KEYBOARD); +#endif act = new Action(guiMap, "REMP", _("Remap keys"), kKeyRemapActionType); - act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0)); + act->addEvent(EVENT_KEYMAPPER_REMAP); act = new Action(guiMap, "FULS", _("Toggle FullScreen")); act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT)); |