From aab80ddc8f56d6a383182ce5c241e9d94ca27bab Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 9 May 2012 21:16:31 +0300 Subject: Add ability to auto repeat some keys presses. --- src/inputmanager.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/inputmanager.cpp') 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]; -- cgit v1.2.3-70-g09d2