summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/inputmanager.cpp18
-rw-r--r--src/inputmanager.h2
-rw-r--r--src/keyboardconfig.cpp15
3 files changed, 21 insertions, 14 deletions
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp
index 3f4904abe..181ba6490 100644
--- a/src/inputmanager.cpp
+++ b/src/inputmanager.cpp
@@ -605,3 +605,21 @@ bool InputManager::triggerAction(const KeysVector *ptrs)
}
return false;
}
+
+int InputManager::getKeyIndex(int value, int grp, int type) const
+{
+ for (size_t i = 0; i < Input::KEY_TOTAL; i++)
+ {
+ const KeyFunction &key = mKey[i];
+ for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++)
+ {
+ if (value == key.values[i2].value
+ && (grp & keyData[i].grp) != 0
+ && key.values[i2].type == type)
+ {
+ return i;
+ }
+ }
+ }
+ return Input::KEY_NO_VALUE;
+}
diff --git a/src/inputmanager.h b/src/inputmanager.h
index 9e2081f4e..b95233f2d 100644
--- a/src/inputmanager.h
+++ b/src/inputmanager.h
@@ -141,6 +141,8 @@ class InputManager
bool triggerAction(const KeysVector *ptrs);
+ int getKeyIndex(int value, int grp, int type) const;
+
protected:
Setup_Input *mSetupInput; /**< Reference to setup window */
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index bcc10d553..7ebe7c9b3 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -63,20 +63,7 @@ int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) const
int KeyboardConfig::getKeyIndex(const SDL_Event &event, int grp) const
{
const int keyValue = getKeyValueFromEvent(event);
- for (size_t i = 0; i < Input::KEY_TOTAL; i++)
- {
- KeyFunction &key = inputManager.getKey(i);
- for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++)
- {
- if (keyValue == key.values[i2].value
- && (grp & keyData[i].grp) != 0
- && key.values[i2].type == INPUT_KEYBOARD)
- {
- return i;
- }
- }
- }
- return Input::KEY_NO_VALUE;
+ return inputManager.getKeyIndex(keyValue, grp, INPUT_KEYBOARD);
}
void KeyboardConfig::refreshActiveKeys()