summaryrefslogtreecommitdiff
path: root/src/keyboardconfig.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-10 02:51:44 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-10 02:56:05 +0300
commit2556c72eea6a7d28d543d991e5d5c519726028f0 (patch)
tree111cf3f26eaf3a5734ec1e22d3985897feb6cd04 /src/keyboardconfig.cpp
parent8f3be5cd0544af07c6cb65bef7a1f3ba1a3704bb (diff)
downloadManaVerse-2556c72eea6a7d28d543d991e5d5c519726028f0.tar.gz
ManaVerse-2556c72eea6a7d28d543d991e5d5c519726028f0.tar.bz2
ManaVerse-2556c72eea6a7d28d543d991e5d5c519726028f0.tar.xz
ManaVerse-2556c72eea6a7d28d543d991e5d5c519726028f0.zip
Add joystick key assign ability in keyboard dialog.
Diffstat (limited to 'src/keyboardconfig.cpp')
-rw-r--r--src/keyboardconfig.cpp30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index ae095f01d..bcc10d553 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -23,7 +23,6 @@
#include "keyboardconfig.h"
#include "configuration.h"
-#include "inputevent.h"
#include "inputmanager.h"
#include "keyboarddata.h"
#include "logger.h"
@@ -114,30 +113,13 @@ SDLKey KeyboardConfig::getKeyFromEvent(const SDL_Event &event) const
return event.key.keysym.sym;
}
-bool KeyboardConfig::triggerAction(const SDL_Event &event)
+KeysVector *KeyboardConfig::getActionVector(const SDL_Event &event)
{
const int i = getKeyValueFromEvent(event);
// logger->log("key triggerAction: %d", i);
if (i != 0 && i < SDLK_LAST && mKeyToAction.find(i) != mKeyToAction.end())
- {
- const KeysVector &ptrs = mKeyToAction[i];
-// logger->log("ptrs: %d", (int)ptrs.size());
- KeysVectorCIter it = ptrs.begin();
- KeysVectorCIter it_end = ptrs.end();
-
- int mask = inputManager.getInputConditionMask();
-
- for (; it != it_end; ++ it)
- {
- const int keyNum = *it;
- if (keyNum < 0 || keyNum >= Input::KEY_TOTAL)
- continue;
-
- if (inputManager.invokeKey(&keyData[keyNum], keyNum, mask))
- return true;
- }
- }
- return false;
+ return &mKeyToAction[i];
+ return nullptr;
}
bool KeyboardConfig::isActionActive(int index) const
@@ -145,9 +127,13 @@ bool KeyboardConfig::isActionActive(int index) const
if (!mActiveKeys)
return false;
+ const KeyFunction &key = inputManager.getKey(index);
for (size_t i = 0; i < KeyFunctionSize; i ++)
{
- const int value = inputManager.getKey(index).values[i].value;
+ if (key.values[i].type != INPUT_KEYBOARD)
+ continue;
+
+ const int value = key.values[i].value;
if (value >= 0)
{
if (mActiveKeys[value])