aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/keymapper/keymapper.cpp2
-rw-r--r--base/main.cpp31
-rw-r--r--common/system.h11
3 files changed, 32 insertions, 12 deletions
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 6d9ae21ef8..10cff9418b 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -145,6 +145,8 @@ Keymap *Keymapper::getKeymap(const String& name, bool *globalReturn) {
bool Keymapper::pushKeymap(const String& name, bool transparent) {
bool global;
+
+ assert(!name.empty());
Keymap *newMap = getKeymap(name, &global);
if (!newMap) {
diff --git a/base/main.cpp b/base/main.cpp
index 9bf67a3cdc..f3ff081d28 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -259,13 +259,11 @@ static void setupGraphics(OSystem &system) {
}
static void setupKeymapper(OSystem &system) {
-
#ifdef ENABLE_KEYMAPPER
using namespace Common;
Keymapper *mapper = system.getEventManager()->getKeymapper();
- Keymap *globalMap = new Keymap(kGlobalKeymapName);
- Action *act;
+
HardwareKeySet *keySet;
keySet = system.getHardwareKeySet();
@@ -274,30 +272,39 @@ static void setupKeymapper(OSystem &system) {
mapper->registerHardwareKeySet(keySet);
// Now create the global keymap
- act = new Action(globalMap, "MENU", _("Menu"), kGenericActionType, kSelectKeyType);
+ Keymap *primaryGlobalKeymap = new Keymap(kGlobalKeymapName);
+ Action *act;
+ act = new Action(primaryGlobalKeymap, "MENU", _("Menu"), kGenericActionType, kSelectKeyType);
act->addEvent(EVENT_MAINMENU);
- act = new Action(globalMap, "SKCT", _("Skip"), kGenericActionType, kActionKeyType);
+ act = new Action(primaryGlobalKeymap, "SKCT", _("Skip"), kGenericActionType, kActionKeyType);
act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));
- act = new Action(globalMap, "PAUS", _("Pause"), kGenericActionType, kStartKeyType);
+ act = new Action(primaryGlobalKeymap, "PAUS", _("Pause"), kGenericActionType, kStartKeyType);
act->addKeyEvent(KeyState(KEYCODE_SPACE, ' ', 0));
- act = new Action(globalMap, "SKLI", _("Skip line"), kGenericActionType, kActionKeyType);
+ act = new Action(primaryGlobalKeymap, "SKLI", _("Skip line"), kGenericActionType, kActionKeyType);
act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0));
- act = new Action(globalMap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType);
+ act = new Action(primaryGlobalKeymap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType);
act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));
- act = new Action(globalMap, "REMP", _("Remap keys"), kKeyRemapActionType);
+ act = new Action(primaryGlobalKeymap, "REMP", _("Remap keys"), kKeyRemapActionType);
act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0));
- act = new Action(globalMap, "FULS", _("Toggle FullScreen"), kKeyRemapActionType);
+ act = new Action(primaryGlobalKeymap, "FULS", _("Toggle FullScreen"), kKeyRemapActionType);
act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));
- mapper->addGlobalKeymap(globalMap);
-
+ mapper->addGlobalKeymap(primaryGlobalKeymap);
mapper->pushKeymap(kGlobalKeymapName, true);
+
+ // Get the platform-specific global keymap (if it exists)
+ Keymap *platformGlobalKeymap = system.getGlobalKeymap();
+ if (platformGlobalKeymap) {
+ String platformGlobalKeymapName = platformGlobalKeymap->getName();
+ mapper->addGlobalKeymap(platformGlobalKeymap);
+ mapper->pushKeymap(platformGlobalKeymapName, true);
+ }
#endif
}
diff --git a/common/system.h b/common/system.h
index 413fe326a7..2a651bba2b 100644
--- a/common/system.h
+++ b/common/system.h
@@ -52,6 +52,7 @@ class TimerManager;
class SeekableReadStream;
class WriteStream;
class HardwareKeySet;
+class Keymap;
}
class AudioCDManager;
@@ -941,6 +942,16 @@ public:
*/
virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; }
+ /**
+ * Return a platform-specific global keymap
+ *
+ * @return Keymap with actions appropriate for the platform
+ *
+ * The caller will use and delete the return object.
+ *
+ * See keymapper documentation for further reference.
+ */
+ virtual Common::Keymap *getGlobalKeymap() { return 0; }
//@}