From 443813146a327504a07a507f43117d92296ca8a7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Mar 2012 15:36:51 +0300 Subject: Move getting keys from game to keyboard config. --- src/keyboardconfig.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/keyboardconfig.cpp') 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 + #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; +} -- cgit v1.2.3-60-g2f50