diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-03-09 15:36:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-03-09 15:36:51 +0300 |
commit | 443813146a327504a07a507f43117d92296ca8a7 (patch) | |
tree | 073f9dcbc4b776675e299f5c5c9df1555cf73ee6 /src/keyboardconfig.cpp | |
parent | e11249023c8945fb817469b3b4362dcd8c2fd9f0 (diff) | |
download | mv-443813146a327504a07a507f43117d92296ca8a7.tar.gz mv-443813146a327504a07a507f43117d92296ca8a7.tar.bz2 mv-443813146a327504a07a507f43117d92296ca8a7.tar.xz mv-443813146a327504a07a507f43117d92296ca8a7.zip |
Move getting keys from game to keyboard config.
Diffstat (limited to 'src/keyboardconfig.cpp')
-rw-r--r-- | src/keyboardconfig.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index fc676dab0..eac641b5a 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -30,6 +30,8 @@ #include "utils/gettext.h" #include "utils/stringutils.h" +#include <SDL_events.h> + #include "debug.h" struct KeyData @@ -454,8 +456,9 @@ void KeyboardConfig::callbackNewKey() mSetupKey->newKeyCallback(mNewKeyIndex); } -int KeyboardConfig::getKeyIndex(int keyValue, int grp) const +int KeyboardConfig::getKeyIndex(const SDL_Event &event, int grp) const { + const int keyValue = event.key.keysym.sym; for (int i = 0; i < KEY_TOTAL; i++) { if (keyValue == mKey[i].value && @@ -468,8 +471,9 @@ int KeyboardConfig::getKeyIndex(int keyValue, int grp) const } -int KeyboardConfig::getKeyEmoteOffset(int keyValue) const +int KeyboardConfig::getKeyEmoteOffset(const SDL_Event &event) const { + const int keyValue = event.key.keysym.sym; for (int i = KEY_EMOTE_1; i <= KEY_EMOTE_48; i++) { if (keyValue == mKey[i].value) @@ -506,3 +510,18 @@ std::string KeyboardConfig::getKeyShortString(const std::string &key) const return "u key"; return key; } + +SDLKey KeyboardConfig::getKeyFromEvent(const SDL_Event &event) const +{ + return event.key.keysym.sym; +} + +void KeyboardConfig::setNewKey(const SDL_Event &event) +{ + mKey[mNewKeyIndex].value = event.key.keysym.sym; +} + +void KeyboardConfig::unassignKey() +{ + mKey[mNewKeyIndex].value = KEY_NO_VALUE; +} |