summaryrefslogtreecommitdiff
path: root/src/keyboardconfig.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-09 23:59:46 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-09 23:59:46 +0300
commit8f3be5cd0544af07c6cb65bef7a1f3ba1a3704bb (patch)
tree61182aa0154f8477581da0a8950397c65c8e59a6 /src/keyboardconfig.cpp
parent21ed1674f5ee382626e80a35dba9d97ec0bc1b92 (diff)
downloadplus-8f3be5cd0544af07c6cb65bef7a1f3ba1a3704bb.tar.gz
plus-8f3be5cd0544af07c6cb65bef7a1f3ba1a3704bb.tar.bz2
plus-8f3be5cd0544af07c6cb65bef7a1f3ba1a3704bb.tar.xz
plus-8f3be5cd0544af07c6cb65bef7a1f3ba1a3704bb.zip
Fix asigning keys unknown for SDL.
Allow full use of keys unknown for SDL (with press state also).
Diffstat (limited to 'src/keyboardconfig.cpp')
-rw-r--r--src/keyboardconfig.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 483b7d511..ae095f01d 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -39,13 +39,17 @@
KeyboardConfig::KeyboardConfig() :
mEnabled(true),
- mActiveKeys(nullptr)
+ mActiveKeys(nullptr),
+ mActiveKeys2(nullptr)
{
}
void KeyboardConfig::init()
{
mEnabled = true;
+ if (mActiveKeys2)
+ delete mActiveKeys2;
+ mActiveKeys2 = new Uint8[500];
}
int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) const
@@ -144,8 +148,16 @@ bool KeyboardConfig::isActionActive(int index) const
for (size_t i = 0; i < KeyFunctionSize; i ++)
{
const int value = inputManager.getKey(index).values[i].value;
- if (value >= 0 && mActiveKeys[value])
- return true;
+ if (value >= 0)
+ {
+ if (mActiveKeys[value])
+ return true;
+ }
+ else if (value < -1 && value > -500)
+ {
+ if (mActiveKeys2[-value])
+ return true;
+ }
}
return false;
}
@@ -154,3 +166,17 @@ void KeyboardConfig::update()
{
inputManager.updateKeyActionMap(mKeyToAction, INPUT_KEYBOARD);
}
+
+void KeyboardConfig::handleActicateKey(const SDL_Event &event)
+{
+ const int key = getKeyValueFromEvent(event);
+ if (key < -1 && key > -500)
+ mActiveKeys2[-key] = 1;
+}
+
+void KeyboardConfig::handleDeActicateKey(const SDL_Event &event)
+{
+ const int key = getKeyValueFromEvent(event);
+ if (key < -1 && key > -500)
+ mActiveKeys2[-key] = 0;
+}