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 /backends/platform | |
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 'backends/platform')
-rw-r--r-- | backends/platform/sdl/events.cpp | 51 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 5 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.h | 3 |
3 files changed, 6 insertions, 53 deletions
diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp index e4f7188b23..7b0349536b 100644 --- a/backends/platform/sdl/events.cpp +++ b/backends/platform/sdl/events.cpp @@ -50,8 +50,7 @@ -static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) -{ +static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) { if (key >= SDLK_F1 && key <= SDLK_F9) { return key - SDLK_F1 + Common::ASCII_F1; } else if (key >= SDLK_KP0 && key <= SDLK_KP9) { @@ -522,10 +521,9 @@ bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) { return false; } -void OSystem_SDL::setupKeymapper() { +Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { #ifdef ENABLE_KEYMAPPER using namespace Common; - Keymapper *mapper = getEventManager()->getKeymapper(); HardwareKeySet *keySet = new HardwareKeySet(); keySet->addHardwareKey(new HardwareKey( "a", KeyState(KEYCODE_a), "a", kActionKeyType )); @@ -536,49 +534,10 @@ void OSystem_SDL::setupKeymapper() { keySet->addHardwareKey(new HardwareKey( "m", KeyState(KEYCODE_m), "m (remap)", kTriggerRightKeyType, kKeyRemapActionType )); keySet->addHardwareKey(new HardwareKey( "[", KeyState(KEYCODE_LEFTBRACKET), "[ (select)", kSelectKeyType )); keySet->addHardwareKey(new HardwareKey( "]", KeyState(KEYCODE_RIGHTBRACKET), "] (start)", kStartKeyType )); - mapper->registerHardwareKeySet(keySet); - Keymap *globalMap = new Keymap("global"); - Action *act; + return keySet; - 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); - - - 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); - - mapper->pushKeymap("global"); +#else + return 0; #endif } - diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index c4e376fe54..d4f634e62f 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -170,11 +170,6 @@ void OSystem_SDL::initBackend() { setupMixer(); } - // Setup the keymapper with backend's set of keys - // NOTE: must be done before creating TimerManager - // to avoid race conditions in creating EventManager - setupKeymapper(); - // Create and hook up the timer manager, if none exists yet (we check for // this to allow subclasses to provide their own). if (_timer == 0) { diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 48662dfa58..95efaae258 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -136,8 +136,7 @@ public: // Returns true if an event was retrieved. virtual bool pollEvent(Common::Event &event); // overloaded by CE backend - // Sets up the keymapper with the backends hardware key set - virtual void setupKeymapper(); + Common::HardwareKeySet *getHardwareKeySet(); // Set function that generates samples virtual void setupMixer(); |