diff options
-rw-r--r-- | src/input/inputfunction.h | 1 | ||||
-rw-r--r-- | src/input/inputmanager.cpp | 27 | ||||
-rw-r--r-- | src/input/inputmanager.h | 4 |
3 files changed, 17 insertions, 15 deletions
diff --git a/src/input/inputfunction.h b/src/input/inputfunction.h index 21d1cd732..1907afdc3 100644 --- a/src/input/inputfunction.h +++ b/src/input/inputfunction.h @@ -31,7 +31,6 @@ const size_t inputFunctionSize = 3U; struct InputFunction final { - std::string keyStr; InputItem values[inputFunctionSize]; }; diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index e5d13f027..d3f14ac2c 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -85,13 +85,13 @@ InputManager::InputManager() : void InputManager::init() restrict2 { - for (unsigned int i = 0; - i < CAST_U32(InputAction::TOTAL); + for (size_t i = 0; + i < CAST_SIZE(InputAction::TOTAL); i ++) { InputFunction &kf = mKey[i]; - kf.keyStr.clear(); - for (unsigned int f = 0; f < inputFunctionSize; f ++) + mKeyStr[i].clear(); + for (size_t f = 0; f < inputFunctionSize; f ++) { InputItem &ki = kf.values[f]; ki.type = InputType::UNKNOWN; @@ -139,7 +139,7 @@ void InputManager::retrieve() restrict2 const size_t keyStrSize = keyStr.size(); if (keyStr.empty()) { - updateKeyString(kf); + updateKeyString(kf, i); continue; } @@ -177,7 +177,7 @@ void InputManager::retrieve() restrict2 } } } - updateKeyString(kf); + updateKeyString(kf, i); } } @@ -269,7 +269,7 @@ void InputManager::resetKey(const InputActionT i) restrict2 val0.value = kd.defaultValue1; val1.value = kd.defaultValue2; #endif - updateKeyString(key); + updateKeyString(key, CAST_SIZE(i)); } void InputManager::resetKeys() restrict2 @@ -417,7 +417,8 @@ std::string InputManager::getKeyStringLong(const InputActionT index) const return keyStr; } -void InputManager::updateKeyString(InputFunction &ki) const restrict2 +void InputManager::updateKeyString(const InputFunction &ki, + const size_t actionIdx) restrict2 { std::string keyStr; for (size_t i = 0; i < inputFunctionSize; i ++) @@ -454,18 +455,18 @@ void InputManager::updateKeyString(InputFunction &ki) const restrict2 if (keyStr.empty()) { // TRANSLATORS: unknown short key type. must be short - ki.keyStr = _("u key"); + mKeyStr[actionIdx] = _("u key"); } else { - ki.keyStr = keyStr; + mKeyStr[actionIdx] = keyStr; } } std::string InputManager::getKeyValueString(const InputActionT index) const restrict2 { - return mKey[CAST_SIZE(index)].keyStr; + return mKeyStr[CAST_SIZE(index)]; } std::string InputManager::getKeyValueByName(const std::string &restrict @@ -520,7 +521,7 @@ void InputManager::addActionKey(const InputActionT action, } key.values[idx] = InputItem(type, val); - updateKeyString(key); + updateKeyString(key, CAST_SIZE(action)); } void InputManager::setNewKey(const SDL_Event &event, @@ -548,7 +549,7 @@ void InputManager::unassignKey() restrict2 val.type = InputType::UNKNOWN; val.value = -1; } - updateKeyString(key); + updateKeyString(key, CAST_SIZE(mNewKeyIndex)); update(); } diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h index 177bb2ae2..26e858185 100644 --- a/src/input/inputmanager.h +++ b/src/input/inputmanager.h @@ -160,7 +160,8 @@ class InputManager final static bool isActionActive0(const InputActionT index) A_WARN_UNUSED; - void updateKeyString(InputFunction &ki) const restrict2; + void updateKeyString(const InputFunction &ki, + const size_t actionIdx) restrict2; /** Reference to setup window */ Setup_Input *mSetupInput A_NONNULLPOINTER; @@ -173,6 +174,7 @@ class InputManager final StringIntMap mChatMap; InputFunction mKey[CAST_SIZE(InputAction::TOTAL)]; + std::string mKeyStr[CAST_SIZE(InputAction::TOTAL)]; }; extern InputManager inputManager; |