aboutsummaryrefslogtreecommitdiff
path: root/backends/keymapper/keymapper.cpp
diff options
context:
space:
mode:
authorStephen Kennedy2008-08-23 17:04:40 +0000
committerStephen Kennedy2008-08-23 17:04:40 +0000
commitbaae044e388bca79a593ce083037c5da777818ea (patch)
tree60f6ccad59f2182d5ad9d9bcb4eab9ff78d3237e /backends/keymapper/keymapper.cpp
parent648f6ed9341775457c301e9055afd40a37b02d6a (diff)
downloadscummvm-rg350-baae044e388bca79a593ce083037c5da777818ea.tar.gz
scummvm-rg350-baae044e388bca79a593ce083037c5da777818ea.tar.bz2
scummvm-rg350-baae044e388bca79a593ce083037c5da777818ea.zip
Proper fix for key repeat bug - r34094 caused different problems due to repeated key up events
svn-id: r34115
Diffstat (limited to 'backends/keymapper/keymapper.cpp')
-rw-r--r--backends/keymapper/keymapper.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 9f4b42658b..5c79d445cb 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -127,12 +127,6 @@ bool Keymapper::pushKeymap(const String& name, bool inherit) {
}
void Keymapper::pushKeymap(Keymap *newMap, bool inherit, bool global) {
- List<KeyState>::iterator it;
- for (it = _keysDown.begin(); it != _keysDown.end(); ++it) {
- Action *action = getAction(*it);
- if (action) executeAction(action, false);
- }
- _keysDown.clear();
MapRecord mr = {newMap, inherit, global};
_activeMaps.push(mr);
}
@@ -154,25 +148,29 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) {
if (!_enabled) return false;
if (_activeMaps.empty()) return false;
- Action *action = getAction(key);
+ Action *action = 0;
+ if (keyDown) {
+ // Search for key in active keymap stack
+ for (int i = _activeMaps.size() - 1; i >= 0; --i) {
+ MapRecord mr = _activeMaps[i];
+ action = mr.keymap->getMappedAction(key);
+ if (action || mr.inherit == false) break;
+ }
+ if (action) _keysDown[key] = action;
+ } else {
+ HashMap<KeyState, Action*>::iterator it = _keysDown.find(key);
+ if (it != _keysDown.end()) {
+ action = it->_value;
+ _keysDown.erase(key);
+ }
+ }
if (!action) return false;
-
- if (keyDown)
- _keysDown.push_back(key);
- else
- _keysDown.remove(key);
-
executeAction(action, keyDown);
return true;
}
Action *Keymapper::getAction(const KeyState& key) {
Action *action = 0;
- for (int i = _activeMaps.size() - 1; i >= 0; --i) {
- MapRecord mr = _activeMaps[i];
- action = mr.keymap->getMappedAction(key);
- if (action || mr.inherit == false) break;
- }
return action;
}