diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-07 14:47:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-07 14:47:20 +0300 |
commit | f8fcfcfef1e5a8cbda66328664f41b3f9aa2a773 (patch) | |
tree | fce3dc2882525b56f7fb4f5219c58aad716ccda1 /src/keyboardconfig.cpp | |
parent | 008a29a3fbcf282d1bed8ce4a9bdfb665defd943 (diff) | |
download | manaverse-f8fcfcfef1e5a8cbda66328664f41b3f9aa2a773.tar.gz manaverse-f8fcfcfef1e5a8cbda66328664f41b3f9aa2a773.tar.bz2 manaverse-f8fcfcfef1e5a8cbda66328664f41b3f9aa2a773.tar.xz manaverse-f8fcfcfef1e5a8cbda66328664f41b3f9aa2a773.zip |
Fix key repeat time calculation.
Add configurabale auto repeat time.
Diffstat (limited to 'src/keyboardconfig.cpp')
-rw-r--r-- | src/keyboardconfig.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 1bdc8f7ff..7287ed3ad 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -37,7 +37,8 @@ extern volatile int tick_time; KeyboardConfig::KeyboardConfig() : mEnabled(true), mActiveKeys(nullptr), - mActiveKeys2(nullptr) + mActiveKeys2(nullptr), + mRepeatTime(0) { } @@ -47,6 +48,7 @@ void KeyboardConfig::init() if (mActiveKeys2) delete mActiveKeys2; mActiveKeys2 = new uint8_t[500]; + mRepeatTime = config.getIntValue("repeateInterval2") * 10; } void KeyboardConfig::deinit() @@ -210,10 +212,13 @@ void KeyboardConfig::handleRepeat(const int time) if (mActiveKeys2 && mActiveKeys2[-key]) repeat = true; } - if (repeat && abs(keyTime - time) > 10) + if (repeat) { - keyTime = time; - inputManager.triggerAction(getActionVectorByKey(key)); + if (time > keyTime && abs(time - keyTime) > mRepeatTime) + { + keyTime = time; + inputManager.triggerAction(getActionVectorByKey(key)); + } } } } |