diff options
author | Eugene Sandulenko | 2009-05-10 22:05:04 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2009-05-10 22:05:04 +0000 |
commit | 665e472ef0bf9cd38c92ebe58975cbda74241a07 (patch) | |
tree | 38fb4c993d827b9250441b315ae2940e73298eeb /base | |
parent | 7604301c30553828cae69ea69acf8fde057ac5c2 (diff) | |
download | scummvm-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 'base')
-rw-r--r-- | base/main.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/base/main.cpp b/base/main.cpp index cdc8ddd73c..1c14e20f76 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -47,6 +47,8 @@ #include "gui/GuiManager.h" #include "gui/message.h" +#include "backends/keymapper/keymapper.h" + #if defined(_WIN32_WCE) #include "backends/platform/wince/CELauncherDialog.h" #elif defined(__DC__) @@ -234,6 +236,46 @@ static void setupGraphics(OSystem &system) { system.fillScreen(0); } +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(); + + // Query backend for hardware keys and register them + mapper->registerHardwareKeySet(keySet); + + // Now create the global keymap + act = new Action(globalMap, "MENU", "Menu", kGenericActionType, kSelectKeyType); + act->addKeyEvent(KeyState(KEYCODE_F5, ASCII_F5, 0)); + + act = new Action(globalMap, "SKCT", "Skip", kGenericActionType, kActionKeyType); + act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0)); + + act = new Action(globalMap, "PAUS", "Pause", kGenericActionType, kStartKeyType); + act->addKeyEvent(KeyState(KEYCODE_SPACE, ' ', 0)); + + act = new Action(globalMap, "SKLI", "Skip line", kGenericActionType, kActionKeyType); + act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0)); + + act = new Action(globalMap, "VIRT", "Display keyboard", kVirtualKeyboardActionType); + act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0)); + + act = new Action(globalMap, "REMP", "Remap keys", kKeyRemapActionType); + act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0)); + + mapper->addGlobalKeymap(globalMap); + + mapper->pushKeymap("global"); +#endif + +} extern "C" int scummvm_main(int argc, const char * const argv[]) { Common::String specialDebug; @@ -295,6 +337,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { // take place after the backend is initiated and the screen has been setup system.getEventManager()->init(); + // Now as the event manager is created, setup the keymapper + setupKeymapper(system); + // Unless a game was specified, show the launcher dialog if (0 == ConfMan.getActiveDomain()) launcherDialog(); |