summaryrefslogtreecommitdiff
path: root/src/keyboardconfig.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-08 21:05:01 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-08 21:05:01 +0300
commitbb258f09a0b50f6382be2ff36637191a8b103c3f (patch)
tree419eb77c8c1502968e89fddff7f1e7c167d86a11 /src/keyboardconfig.cpp
parent30ef016b0a14f36dc480284e2d775295b5501dd4 (diff)
downloadplus-bb258f09a0b50f6382be2ff36637191a8b103c3f.tar.gz
plus-bb258f09a0b50f6382be2ff36637191a8b103c3f.tar.bz2
plus-bb258f09a0b50f6382be2ff36637191a8b103c3f.tar.xz
plus-bb258f09a0b50f6382be2ff36637191a8b103c3f.zip
Move some more code from keyboardconfig to inputmanager.
Diffstat (limited to 'src/keyboardconfig.cpp')
-rw-r--r--src/keyboardconfig.cpp59
1 files changed, 7 insertions, 52 deletions
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index a56f2cfa6..4dfab8852 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -35,27 +35,11 @@
#include <SDL_events.h>
-#include <algorithm>
-
#include "debug.h"
-class KeyFunctor
-{
- public:
- bool operator() (int key1, int key2)
- {
- return keys[key1].priority >= keys[key2].priority;
- }
-
- const KeyData *keys;
-
-} keySorter;
-
void KeyboardConfig::init()
{
mEnabled = true;
-
- updateKeyActionMap();
}
int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) const
@@ -120,34 +104,6 @@ SDLKey KeyboardConfig::getKeyFromEvent(const SDL_Event &event) const
return event.key.keysym.sym;
}
-void KeyboardConfig::updateKeyActionMap()
-{
- mKeyToAction.clear();
-
- for (size_t i = 0; i < Input::KEY_TOTAL; i ++)
- {
- if (keyData[i].action)
- {
- KeyFunction &key = inputManager.getKey(i);
- for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++)
- {
- if (key.values[i2].type == INPUT_KEYBOARD)
- mKeyToAction[key.values[i2].value].push_back(i);
- }
- }
- }
-
- keySorter.keys = &keyData[0];
- KeyToActionMapIter it = mKeyToAction.begin();
- KeyToActionMapIter it_end = mKeyToAction.end();
- for (; it != it_end; ++ it)
- {
- KeysVector *keys = &it->second;
- if (keys->size() > 1)
- sort(keys->begin(), keys->end(), keySorter);
- }
-}
-
bool KeyboardConfig::triggerAction(const SDL_Event &event)
{
const int i = getKeyValueFromEvent(event);
@@ -167,14 +123,8 @@ bool KeyboardConfig::triggerAction(const SDL_Event &event)
if (keyNum < 0 || keyNum >= Input::KEY_TOTAL)
continue;
- if (inputManager.checkKey(&keyData[keyNum], mask))
- {
- InputEvent evt(keyNum, mask);
- if ((*(keyData[keyNum].action))(evt))
- {
- return true;
- }
- }
+ if (inputManager.invokeKey(&keyData[keyNum], keyNum, mask))
+ return true;
}
}
return false;
@@ -193,3 +143,8 @@ bool KeyboardConfig::isActionActive(int index) const
}
return false;
}
+
+void KeyboardConfig::update()
+{
+ inputManager.updateKeyActionMap(mKeyToAction, INPUT_KEYBOARD);
+}