summaryrefslogtreecommitdiff
path: root/src/inputmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inputmanager.cpp')
-rw-r--r--src/inputmanager.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp
index 283b07d6c..fcb40d4ea 100644
--- a/src/inputmanager.cpp
+++ b/src/inputmanager.cpp
@@ -590,15 +590,16 @@ bool InputManager::invokeKey(const KeyData *key, int keyNum)
return false;
}
-void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, int type)
+void InputManager::updateKeyActionMap(KeyToActionMap &actionMap,
+ KeyToIdMap &idMap, int type)
{
actionMap.clear();
for (size_t i = 0; i < Input::KEY_TOTAL; i ++)
{
+ KeyFunction &key = mKey[i];
if (keyData[i].action)
{
- KeyFunction &key = mKey[i];
for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++)
{
const KeyItem &ki = key.values[i2];
@@ -606,6 +607,15 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, int type)
actionMap[ki.value].push_back(i);
}
}
+ if (keyData[i].configField && (keyData[i].grp & Input::GRP_GUI))
+ {
+ for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++)
+ {
+ const KeyItem &ki = key.values[i2];
+ if (ki.type == type && ki.value != -1)
+ idMap[ki.value] = i;
+ }
+ }
}
keySorter.keys = &keyData[0];
@@ -657,3 +667,15 @@ int InputManager::getKeyIndex(int value, int grp, int type) const
}
return Input::KEY_NO_VALUE;
}
+
+int InputManager::getActionByKey(const SDL_Event &event)
+{
+ // for now support only keyboard events
+ if (event.type == SDL_KEYDOWN)
+ {
+ int idx = keyboard.getActionId(event);
+ if (idx >= 0 && checkKey(&keyData[idx]))
+ return idx;
+ }
+ return -1;
+}