summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-07 14:47:20 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-07 14:47:20 +0300
commitf8fcfcfef1e5a8cbda66328664f41b3f9aa2a773 (patch)
treefce3dc2882525b56f7fb4f5219c58aad716ccda1 /src
parent008a29a3fbcf282d1bed8ce4a9bdfb665defd943 (diff)
downloadmv-f8fcfcfef1e5a8cbda66328664f41b3f9aa2a773.tar.gz
mv-f8fcfcfef1e5a8cbda66328664f41b3f9aa2a773.tar.bz2
mv-f8fcfcfef1e5a8cbda66328664f41b3f9aa2a773.tar.xz
mv-f8fcfcfef1e5a8cbda66328664f41b3f9aa2a773.zip
Fix key repeat time calculation.
Add configurabale auto repeat time.
Diffstat (limited to 'src')
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/setup_other.cpp2
-rw-r--r--src/joystick.cpp10
-rw-r--r--src/keyboardconfig.cpp13
-rw-r--r--src/keyboardconfig.h2
5 files changed, 21 insertions, 7 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 7c56d8ccf..57d7c1988 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -273,6 +273,7 @@ DefaultsData* getConfigDefaults()
AddDEF("audioChannels", 2);
AddDEF("repeateDelay", SDL_DEFAULT_REPEAT_DELAY);
AddDEF("repeateInterval", SDL_DEFAULT_REPEAT_INTERVAL);
+ AddDEF("repeateInterval2", SDL_DEFAULT_REPEAT_DELAY);
AddDEF("compresstextures", 0);
AddDEF("rectangulartextures", true);
AddDEF("networksleep", 0);
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index 2d6febe60..86e4f63bf 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -211,6 +211,8 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
new SetupItemIntTextField(_("Repeat interval"), "",
"repeateInterval", this, "repeateIntervalEvent", 0, 10000);
+ new SetupItemIntTextField(_("Custom repeat interval"), "",
+ "repeateInterval2", this, "repeateInterval2Event", 0, 10000);
new SetupItemLabel(_("Windows"), "", this);
diff --git a/src/joystick.cpp b/src/joystick.cpp
index 1e5d5e5f9..0c78621d3 100644
--- a/src/joystick.cpp
+++ b/src/joystick.cpp
@@ -345,10 +345,14 @@ void Joystick::handleRepeat(const int time)
if (mActiveButtons[key])
repeat = true;
}
- if (repeat && abs(keyTime - time) > 10)
+ if (repeat)
{
- keyTime = time;
- inputManager.triggerAction(getActionVectorByKey(key));
+ if (time > keyTime && abs(time - keyTime)
+ > SDL_DEFAULT_REPEAT_DELAY * 10)
+ {
+ keyTime = time;
+ inputManager.triggerAction(getActionVectorByKey(key));
+ }
}
}
}
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));
+ }
}
}
}
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index cbadbbd33..afc8b043c 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -109,6 +109,8 @@ class KeyboardConfig final
uint8_t *mActiveKeys2; /**< Stores a list of all the keys */
+ unsigned int mRepeatTime;
+
KeyToActionMap mKeyToAction;
KeyToIdMap mKeyToId;