diff options
Diffstat (limited to 'gui/gui-manager.cpp')
-rw-r--r-- | gui/gui-manager.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 212d68430c..98840e6daf 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -107,11 +107,11 @@ void GuiManager::initKeymap() { Keymapper *mapper = _system->getEventManager()->getKeymapper(); // Do not try to recreate same keymap over again - if (mapper->getKeymap("gui", tmp) != 0) + if (mapper->getKeymap(kGuiKeymapName, tmp) != 0) return; Action *act; - Keymap *guiMap = new Keymap("gui"); + Keymap *guiMap = new Keymap(kGuiKeymapName); act = new Action(guiMap, "CLOS", _("Close"), kGenericActionType, kStartKeyType); act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0)); @@ -127,6 +127,22 @@ void GuiManager::initKeymap() { mapper->addGlobalKeymap(guiMap); } + +void GuiManager::pushKeymap() { + _system->getEventManager()->getKeymapper()->pushKeymap(Common::kGuiKeymapName); +} + +void GuiManager::popKeymap() { + Common::Keymapper *keymapper = _system->getEventManager()->getKeymapper(); + if (!keymapper->getActiveStack().empty()) { + Common::Keymapper::MapRecord topKeymap = keymapper->getActiveStack().top(); + // TODO: Don't use the keymap name as a way to discriminate GUI maps + if(topKeymap.keymap->getName().equals(Common::kGuiKeymapName)) + keymapper->popKeymap(); + else + warning("An attempt to pop non-gui keymap %s was blocked", topKeymap.keymap->getName().c_str()); + } +} #endif bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx, bool forced) { @@ -276,8 +292,7 @@ void GuiManager::runLoop() { // try to do it on every launch, checking whether the // map is already existing initKeymap(); - - eventMan->getKeymapper()->pushKeymap("gui"); + pushKeymap(); #endif bool tooltipCheck = false; @@ -392,7 +407,7 @@ void GuiManager::runLoop() { } #ifdef ENABLE_KEYMAPPER - eventMan->getKeymapper()->popKeymap(); + popKeymap(); #endif if (didSaveState) { |