aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorTarek Soliman2011-10-21 10:33:56 -0500
committerTarek Soliman2011-10-27 10:46:22 -0500
commitac85d134b31f770f27d085c0fe4c307e278c1875 (patch)
treeb35c55891e09f1a77187f2e3db394620f1721d76 /backends
parent913b36ab830dc19fece710a0b1a883d1cc48f3cf (diff)
downloadscummvm-rg350-ac85d134b31f770f27d085c0fe4c307e278c1875.tar.gz
scummvm-rg350-ac85d134b31f770f27d085c0fe4c307e278c1875.tar.bz2
scummvm-rg350-ac85d134b31f770f27d085c0fe4c307e278c1875.zip
KEYMAPPER: Make global keymap that is always active
Keymapper now has a global keymap outside the active keymap stack. That global keymap is always checked after the active stack has been checked.
Diffstat (limited to 'backends')
-rw-r--r--backends/keymapper/keymapper.cpp6
-rw-r--r--backends/keymapper/keymapper.h4
-rw-r--r--backends/keymapper/remap-dialog.cpp20
3 files changed, 29 insertions, 1 deletions
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 29f495cd53..f9d6e7a60f 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -54,7 +54,7 @@ Keymap *Keymapper::Domain::getKeymap(const String& name) {
}
Keymapper::Keymapper(EventManager *evtMgr)
- : _eventMan(evtMgr), _enabled(true), _hardwareKeys(0) {
+ : _eventMan(evtMgr), _enabled(true), _hardwareKeys(0), _globalKeymap(0) {
ConfigManager::Domain *confDom = ConfMan.getDomain(ConfigManager::kKeymapperDomain);
_globalDomain.setConfigDomain(confDom);
@@ -199,6 +199,10 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) {
break;
}
+ // fallback to the global keymap
+ if (!action && _globalKeymap)
+ action = _globalKeymap->getMappedAction(key);
+
if (action)
_keysDown[key] = action;
} else {
diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h
index fcb444aa64..347b9e0ec0 100644
--- a/backends/keymapper/keymapper.h
+++ b/backends/keymapper/keymapper.h
@@ -171,6 +171,9 @@ public:
Domain& getGameDomain() { return _gameDomain; }
const Stack<MapRecord>& getActiveStack() const { return _activeMaps; }
+ void setGlobalKeymap(Keymap *keymap) { _globalKeymap = keymap; }
+ Keymap* getGlobalKeymap() const { return _globalKeymap; }
+
private:
void initKeymap(Domain &domain, Keymap *keymap);
@@ -190,6 +193,7 @@ private:
bool _enabled;
Stack<MapRecord> _activeMaps;
+ Keymap *_globalKeymap;
HashMap<KeyState, Action*> _keysDown;
};
diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp
index 94b0cbf66b..0882c69080 100644
--- a/backends/keymapper/remap-dialog.cpp
+++ b/backends/keymapper/remap-dialog.cpp
@@ -345,6 +345,26 @@ void RemapDialog::loadKeymap() {
}
}
+ // get the mapping out of the global keymap
+ if (_keymapper->getGlobalKeymap()) {
+ List<const HardwareKey*>::iterator keyIt = freeKeys.begin();
+ Keymap *globalKeymap = _keymapper->getGlobalKeymap();
+ while (keyIt != freeKeys.end()) {
+ Action *act = globalKeymap->getMappedAction((*keyIt)->key);
+
+ if (act) {
+ ActionInfo info = {act, true, act->description + " (" + globalKeymap->getName() + ")"};
+ _currentActions.push_back(info);
+ freeKeys.erase(keyIt++);
+ } else {
+ ++keyIt;
+ }
+ if (freeKeys.empty())
+ break;
+ }
+
+ }
+
} else if (_kmPopUp->getSelected() != -1) {
Keymap *km = _keymapTable[_kmPopUp->getSelectedTag()];