From baae044e388bca79a593ce083037c5da777818ea Mon Sep 17 00:00:00 2001 From: Stephen Kennedy Date: Sat, 23 Aug 2008 17:04:40 +0000 Subject: Proper fix for key repeat bug - r34094 caused different problems due to repeated key up events svn-id: r34115 --- backends/keymapper/keymapper.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'backends/keymapper/keymapper.cpp') 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::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::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; } -- cgit v1.2.3