Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

KEYMAPPER: Move F7 and F8 handling to DefaultEventMapper

  • Loading branch information...
commit 3f6d549b0e891be33ef48926629d6e626009fc8f 1 parent cfe91c8
Tarek Soliman tsoliman authored
63 backends/events/default/default-events.cpp
View
@@ -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)
6 base/main.cpp
View
@@ -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));
22 common/EventMapper.cpp
View
@@ -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;
}
7 common/events.h
View
@@ -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
};
6 gui/gui-manager.cpp
View
@@ -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));
Please sign in to comment.
Something went wrong with that request. Please try again.