summaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/input')
-rw-r--r--src/input/inputmanager.cpp79
-rw-r--r--src/input/inputmanager.h2
2 files changed, 30 insertions, 51 deletions
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index 5d157f0fa..d611e4790 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -216,69 +216,46 @@ void InputManager::store() const
}
}
-void InputManager::resetKeys()
+void InputManager::resetKey(const int i)
{
- for (int i = 0; i < Input::KEY_TOTAL; i++)
+ KeyFunction &key = mKey[i];
+ for (size_t i2 = 1; i2 < KeyFunctionSize; i2 ++)
{
- KeyFunction &key = mKey[i];
- for (size_t i2 = 1; i2 < KeyFunctionSize; i2 ++)
- {
- KeyItem &ki2 = key.values[i2];
- ki2.type = INPUT_UNKNOWN;
- ki2.value = -1;
- }
- const KeyData &kd = keyData[i];
- KeyItem &val0 = key.values[0];
- val0.type = kd.defaultType1;
- KeyItem &val1 = key.values[1];
- val1.type = kd.defaultType2;
+ KeyItem &ki2 = key.values[i2];
+ ki2.type = INPUT_UNKNOWN;
+ ki2.value = -1;
+ }
+ const KeyData &kd = keyData[i];
+ KeyItem &val0 = key.values[0];
+ val0.type = kd.defaultType1;
+ KeyItem &val1 = key.values[1];
+ val1.type = kd.defaultType2;
#ifdef USE_SDL2
- if (kd.defaultType1 == INPUT_KEYBOARD)
- val0.value = SDL_GetScancodeFromKey(kd.defaultValue1);
- else
- val0.value = kd.defaultValue1;
- if (kd.defaultType2 == INPUT_KEYBOARD)
- val1.value = SDL_GetScancodeFromKey(kd.defaultValue2);
- else
- val1.value = kd.defaultValue2;
-#else
+ if (kd.defaultType1 == INPUT_KEYBOARD)
+ val0.value = SDL_GetScancodeFromKey(kd.defaultValue1);
+ else
val0.value = kd.defaultValue1;
+ if (kd.defaultType2 == INPUT_KEYBOARD)
+ val1.value = SDL_GetScancodeFromKey(kd.defaultValue2);
+ else
val1.value = kd.defaultValue2;
+#else
+ val0.value = kd.defaultValue1;
+ val1.value = kd.defaultValue2;
#endif
- }
+}
+
+void InputManager::resetKeys()
+{
+ for (int i = 0; i < Input::KEY_TOTAL; i++)
+ resetKey(i);
}
void InputManager::makeDefault(const int i)
{
if (i >= 0 && i < Input::KEY_TOTAL)
{
- KeyFunction &key = mKey[i];
- for (size_t i2 = 1; i2 < KeyFunctionSize; i2 ++)
- {
- KeyItem &ki2 = key.values[i2];
- ki2.type = INPUT_UNKNOWN;
- ki2.value = -1;
- }
- const KeyData &kd = keyData[i];
- KeyItem &val0 = key.values[0];
- val0.type = kd.defaultType1;
- KeyItem &val1 = key.values[1];
- val1.type = kd.defaultType2;
-
-#ifdef USE_SDL2
- if (kd.defaultType1 == INPUT_KEYBOARD)
- val0.value = SDL_GetScancodeFromKey(kd.defaultValue1);
- else
- val0.value = kd.defaultValue1;
- if (kd.defaultType2 == INPUT_KEYBOARD)
- val1.value = SDL_GetScancodeFromKey(kd.defaultValue2);
- else
- val1.value = kd.defaultValue2;
-#else
- val0.value = kd.defaultValue1;
- val1.value = kd.defaultValue2;
-#endif
-
+ resetKey(i);
update();
}
}
diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h
index fcd1252c0..bf9e04f34 100644
--- a/src/input/inputmanager.h
+++ b/src/input/inputmanager.h
@@ -181,6 +181,8 @@ class InputManager final
void executeAction(const int keyNum);
protected:
+ void resetKey(const int i);
+
static bool isActionActive0(const int index) A_WARN_UNUSED;
Setup_Input *mSetupInput; /**< Reference to setup window */