aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorEugene Sandulenko2009-01-11 00:20:27 +0000
committerEugene Sandulenko2009-01-11 00:20:27 +0000
commit83972e2001e0654e057b5a4930cd2cbc05165786 (patch)
tree1137fef4016651c2ad56aa44024649c80d0a939f /backends/platform
parent326df55debb696f73c33450569af4a6d0c60b0fd (diff)
parentfe39d4f5075cc723945ca813142d02983069d0d5 (diff)
downloadscummvm-rg350-83972e2001e0654e057b5a4930cd2cbc05165786.tar.gz
scummvm-rg350-83972e2001e0654e057b5a4930cd2cbc05165786.tar.bz2
scummvm-rg350-83972e2001e0654e057b5a4930cd2cbc05165786.zip
Merge in Virtual Keybpard & KeyMapper branch,
- Merge is perfromed in order to not let rotting the code - Makefile modifications were avoided Stuff to resolve: - Circular dependency of common/vkeybd from graphics/ - Make it compilable (?) - Add some keyboards - Decide on the key bindings svn-id: r35813
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/sdl/events.cpp60
-rw-r--r--backends/platform/sdl/sdl.cpp5
-rw-r--r--backends/platform/sdl/sdl.h3
3 files changed, 68 insertions, 0 deletions
diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp
index fbb7beb95a..7eb86d6c24 100644
--- a/backends/platform/sdl/events.cpp
+++ b/backends/platform/sdl/events.cpp
@@ -24,6 +24,7 @@
*/
#include "backends/platform/sdl/sdl.h"
+#include "backends/keymapper/keymapper.h"
#include "common/util.h"
#include "common/events.h"
@@ -521,3 +522,62 @@ bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) {
return false;
}
+void OSystem_SDL::setupKeymapper() {
+#ifdef ENABLE_KEYMAPPER
+ using namespace Common;
+ Keymapper *mapper = getEventManager()->getKeymapper();
+
+ HardwareKeySet *keySet = new HardwareKeySet();
+ keySet->addHardwareKey(new HardwareKey( "a", KeyState(KEYCODE_a), "a", kActionKeyType ));
+ keySet->addHardwareKey(new HardwareKey( "s", KeyState(KEYCODE_s), "s", kActionKeyType ));
+ keySet->addHardwareKey(new HardwareKey( "d", KeyState(KEYCODE_d), "d", kActionKeyType ));
+ keySet->addHardwareKey(new HardwareKey( "f", KeyState(KEYCODE_f), "f", kActionKeyType ));
+ keySet->addHardwareKey(new HardwareKey( "n", KeyState(KEYCODE_n), "n (vk)", kTriggerLeftKeyType, kVirtualKeyboardActionType ));
+ 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");
+ Keymap *guiMap = new Keymap("gui");
+ Action *act;
+ Event evt ;
+
+ 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_F6, ASCII_F6, 0));
+
+ act = new Action(globalMap, "REMP", "Remap keys", kKeyRemapActionType);
+ act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));
+
+ mapper->addGlobalKeymap(globalMap);
+
+ 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_F6, ASCII_F6, 0));
+
+ act = new Action(guiMap, "REMP", "Remap keys", kKeyRemapActionType);
+ act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));
+
+ mapper->addGlobalKeymap(guiMap);
+
+ mapper->pushKeymap("global");
+#endif
+}
+
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index be239e4ea2..94f358db08 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -169,6 +169,11 @@ 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 1bfdca6b69..b6383d65f8 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -137,6 +137,9 @@ 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();
+
// Set function that generates samples
virtual void setupMixer();
static void mixCallback(void *s, byte *samples, int len);