diff options
Diffstat (limited to 'base/main.cpp')
-rw-r--r-- | base/main.cpp | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/base/main.cpp b/base/main.cpp index 61a05154c1..391d911ae8 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -203,6 +203,9 @@ static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const warning(_("Engine does not support debug level '%s'"), token.c_str()); } + // Initialize any game-specific keymaps + engine->initKeymap(); + // Inform backend that the engine is about to be run system.engineInit(); @@ -212,6 +215,9 @@ static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const // Inform backend that the engine finished system.engineDone(); + // Clean up any game-specific keymaps + engine->deinitKeymap(); + // Free up memory delete engine; @@ -253,42 +259,52 @@ static void setupGraphics(OSystem &system) { } static void setupKeymapper(OSystem &system) { - #ifdef ENABLE_KEYMAPPER using namespace Common; Keymapper *mapper = system.getEventManager()->getKeymapper(); - Keymap *globalMap = new Keymap("global"); - Action *act; - HardwareKeySet *keySet; - keySet = system.getHardwareKeySet(); + HardwareInputSet *inputSet = system.getHardwareInputSet(); // Query backend for hardware keys and register them - mapper->registerHardwareKeySet(keySet); + mapper->registerHardwareInputSet(inputSet); // Now create the global keymap - act = new Action(globalMap, "MENU", _("Menu"), kGenericActionType, kSelectKeyType); - act->addKeyEvent(KeyState(KEYCODE_F5, ASCII_F5, 0)); + Keymap *primaryGlobalKeymap = new Keymap(kGlobalKeymapName); + Action *act; + act = new Action(primaryGlobalKeymap, "MENU", _("Menu")); + act->addEvent(EVENT_MAINMENU); - act = new Action(globalMap, "SKCT", _("Skip"), kGenericActionType, kActionKeyType); + act = new Action(primaryGlobalKeymap, "SKCT", _("Skip")); act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0)); - act = new Action(globalMap, "PAUS", _("Pause"), kGenericActionType, kStartKeyType); + act = new Action(primaryGlobalKeymap, "PAUS", _("Pause")); act->addKeyEvent(KeyState(KEYCODE_SPACE, ' ', 0)); - act = new Action(globalMap, "SKLI", _("Skip line"), kGenericActionType, kActionKeyType); + act = new Action(primaryGlobalKeymap, "SKLI", _("Skip line")); act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0)); - act = new Action(globalMap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType); - act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0)); +#ifdef ENABLE_VKEYBD + act = new Action(primaryGlobalKeymap, "VIRT", _("Display keyboard")); + act->addEvent(EVENT_VIRTUAL_KEYBOARD); +#endif + + act = new Action(primaryGlobalKeymap, "REMP", _("Remap keys")); + act->addEvent(EVENT_KEYMAPPER_REMAP); - act = new Action(globalMap, "REMP", _("Remap keys"), kKeyRemapActionType); - act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0)); + act = new Action(primaryGlobalKeymap, "FULS", _("Toggle FullScreen")); + act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT)); - mapper->addGlobalKeymap(globalMap); + mapper->addGlobalKeymap(primaryGlobalKeymap); + mapper->pushKeymap(kGlobalKeymapName, true); - mapper->pushKeymap("global", true); + // Get the platform-specific global keymap (if it exists) + Keymap *platformGlobalKeymap = system.getGlobalKeymap(); + if (platformGlobalKeymap) { + String platformGlobalKeymapName = platformGlobalKeymap->getName(); + mapper->addGlobalKeymap(platformGlobalKeymap); + mapper->pushKeymap(platformGlobalKeymapName, true); + } #endif } |