diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-31 00:19:18 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-31 00:19:18 +0300 |
commit | 694e07d193e7c5758a7d672b45668651b034003d (patch) | |
tree | 20a4aec8dee2b3b5475db9f3667e797fb43c603b /src/input/keyboardconfig.cpp | |
parent | c9a84749b3b71d4df6cc3b9b488d60dc4a013a20 (diff) | |
download | manaplus-694e07d193e7c5758a7d672b45668651b034003d.tar.gz manaplus-694e07d193e7c5758a7d672b45668651b034003d.tar.bz2 manaplus-694e07d193e7c5758a7d672b45668651b034003d.tar.xz manaplus-694e07d193e7c5758a7d672b45668651b034003d.zip |
Convert InputAction enum into strong typed enum.
Diffstat (limited to 'src/input/keyboardconfig.cpp')
-rw-r--r-- | src/input/keyboardconfig.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp index 9229d4184..80ad2fcd9 100644 --- a/src/input/keyboardconfig.cpp +++ b/src/input/keyboardconfig.cpp @@ -73,7 +73,7 @@ int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) #endif } -int KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp) +InputActionT KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp) { const int keyValue = getKeyValueFromEvent(event); return inputManager.getKeyIndex(keyValue, grp, InputType::KEYBOARD); @@ -86,9 +86,9 @@ void KeyboardConfig::refreshActiveKeys() std::string KeyboardConfig::getKeyName(const int key) { - if (key == InputAction::NO_VALUE) + if (key == -1) return ""; - if (key >= 0) + if (key > -1) { #ifdef USE_SDL2 return SDL_GetKeyName(SDL_GetKeyFromScancode( @@ -99,7 +99,7 @@ std::string KeyboardConfig::getKeyName(const int key) } // TRANSLATORS: long key name, should be short - return strprintf(_("key_%d"), key); + return strprintf(_("key_%d"), static_cast<int>(key)); } std::string KeyboardConfig::getKeyShortString(const std::string &key) @@ -174,16 +174,16 @@ KeysVector *KeyboardConfig::getActionVectorByKey(const int i) return nullptr; } -int KeyboardConfig::getActionId(const SDL_Event &event) +InputActionT KeyboardConfig::getActionId(const SDL_Event &event) { const int i = getKeyValueFromEvent(event); // logger->log("getActionId: %d", i); if (i != 0 && i < SDLK_LAST && mKeyToId.find(i) != mKeyToId.end()) return mKeyToId[i]; - return -1; + return InputAction::NO_VALUE; } -bool KeyboardConfig::isActionActive(const int index) const +bool KeyboardConfig::isActionActive(const InputActionT index) const { if (!mActiveKeys) return false; |