diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-05-09 21:16:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-05-09 21:17:31 +0300 |
commit | aab80ddc8f56d6a383182ce5c241e9d94ca27bab (patch) | |
tree | 9e81b97354b666820ab6e2bb9575dc1127a486a8 /src/inputmanager.cpp | |
parent | 0af9ff98876426c096d2b4b8a4f17172af92b8d0 (diff) | |
download | manaverse-aab80ddc8f56d6a383182ce5c241e9d94ca27bab.tar.gz manaverse-aab80ddc8f56d6a383182ce5c241e9d94ca27bab.tar.bz2 manaverse-aab80ddc8f56d6a383182ce5c241e9d94ca27bab.tar.xz manaverse-aab80ddc8f56d6a383182ce5c241e9d94ca27bab.zip |
Add ability to auto repeat some keys presses.
Diffstat (limited to 'src/inputmanager.cpp')
-rw-r--r-- | src/inputmanager.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index 3a4ee1b9b..9f07d1fe9 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -526,6 +526,14 @@ bool InputManager::handleEvent(const SDL_Event &event) return false; } +void InputManager::handleRepeat() +{ + const int time = tick_time; + keyboard.handleRepeat(time); + if (joystick) + joystick->handleRepeat(time); +} + void InputManager::updateConditionMask() { mMask = 1; @@ -590,9 +598,12 @@ bool InputManager::invokeKey(const KeyData *key, int keyNum) } void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, - KeyToIdMap &idMap, int type) + KeyToIdMap &idMap, + KeyTimeMap &keyTimeMap, + int type) { actionMap.clear(); + keyTimeMap.clear(); for (size_t i = 0; i < Input::KEY_TOTAL; i ++) { @@ -615,6 +626,15 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, idMap[ki.value] = i; } } + if (keyData[i].configField && (keyData[i].grp & Input::GRP_REPEAT)) + { + for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) + { + const KeyItem &ki = key.values[i2]; + if (ki.type == type && ki.value != -1) + keyTimeMap[ki.value] = 0; + } + } } keySorter.keys = &keyData[0]; |