aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorEugene Sandulenko2009-05-10 22:05:04 +0000
committerEugene Sandulenko2009-05-10 22:05:04 +0000
commit665e472ef0bf9cd38c92ebe58975cbda74241a07 (patch)
tree38fb4c993d827b9250441b315ae2940e73298eeb /gui
parent7604301c30553828cae69ea69acf8fde057ac5c2 (diff)
downloadscummvm-rg350-665e472ef0bf9cd38c92ebe58975cbda74241a07.tar.gz
scummvm-rg350-665e472ef0bf9cd38c92ebe58975cbda74241a07.tar.bz2
scummvm-rg350-665e472ef0bf9cd38c92ebe58975cbda74241a07.zip
Keymapper:
- Introduced new OSystem method getHardwareKeySet() with default implementation - Moved global keymap creation to base/main.cpp - Moved GUI keymap creation to gui/GuiManager.cpp - Added various safeguard checks to various keymapper methods Now it is really possible to add keymapper to all backends. svn-id: r40439
Diffstat (limited to 'gui')
-rw-r--r--gui/GuiManager.cpp36
-rw-r--r--gui/GuiManager.h2
2 files changed, 38 insertions, 0 deletions
diff --git a/gui/GuiManager.cpp b/gui/GuiManager.cpp
index f3954c112d..6f31ff9658 100644
--- a/gui/GuiManager.cpp
+++ b/gui/GuiManager.cpp
@@ -79,6 +79,36 @@ GuiManager::~GuiManager() {
delete _theme;
}
+#ifdef ENABLE_KEYMAPPER
+void GuiManager::initKeymap() {
+ using namespace Common;
+
+ bool tmp;
+ Keymapper *mapper = _system->getEventManager()->getKeymapper();
+
+ // Do not try to recreate same keymap over again
+ if (mapper->getKeymap("gui", tmp) != 0)
+ return;
+
+ Action *act;
+ Keymap *guiMap = new Keymap("gui");
+
+ act = new Action(guiMap, "CLOS", "Close", kGenericActionType, kStartKeyType);
+ act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));
+
+ act = new Action(guiMap, "CLIK", "Mouse click");
+ act->addLeftClickEvent();
+
+ act = new Action(guiMap, "VIRT", "Display keyboard", kVirtualKeyboardActionType);
+ act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));
+
+ act = new Action(guiMap, "REMP", "Remap keys", kKeyRemapActionType);
+ act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0));
+
+ mapper->addGlobalKeymap(guiMap);
+}
+#endif
+
bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx) {
// If we are asked to reload the currently active theme, just do nothing
// FIXME: Actually, why? It might be desirable at times to force a theme reload...
@@ -213,6 +243,12 @@ void GuiManager::runLoop() {
const uint32 waitTime = 1000 / 45;
#ifdef ENABLE_KEYMAPPER
+ // Due to circular reference with event manager and GUI
+ // we cannot init keymap on the GUI creation. Thus, let's
+ // try to do it on every launch, checking whether the
+ // map is already existing
+ initKeymap();
+
eventMan->getKeymapper()->pushKeymap("gui");
#endif
diff --git a/gui/GuiManager.h b/gui/GuiManager.h
index 12c9a25f62..102d612699 100644
--- a/gui/GuiManager.h
+++ b/gui/GuiManager.h
@@ -124,6 +124,8 @@ protected:
bool _themeChange;
+ void initKeymap();
+
void saveState();
void restoreState();