summaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-05 00:01:18 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-05 00:01:18 +0300
commit432896d05e39399b48d80f4e80b058f487f48112 (patch)
tree67a889f0e42cce933177a15afc371e224552fd39 /src/input
parent70e54365d660a52884af35487cfdf89d0d53ac9a (diff)
downloadplus-432896d05e39399b48d80f4e80b058f487f48112.tar.gz
plus-432896d05e39399b48d80f4e80b058f487f48112.tar.bz2
plus-432896d05e39399b48d80f4e80b058f487f48112.tar.xz
plus-432896d05e39399b48d80f4e80b058f487f48112.zip
Move keyStr from inputfunction into separate array in inputmanager.
Diffstat (limited to 'src/input')
-rw-r--r--src/input/inputfunction.h1
-rw-r--r--src/input/inputmanager.cpp27
-rw-r--r--src/input/inputmanager.h4
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;