From 5b2a6bb45f06a604b19e363468f2266c9ac3f12d Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 8 Mar 2011 02:07:35 +0000 Subject: [PATCH] - bugfix for esc key --- source/glest_game/global/config.cpp | 2 +- source/glest_game/menu/menu_state_keysetup.cpp | 18 ++++++++++++++---- source/glest_game/menu/menu_state_root.cpp | 1 + .../shared_lib/sources/platform/sdl/window.cpp | 5 ++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 70e389ec..64f1c5c5 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -265,7 +265,7 @@ const string Config::getString(const string &key,const char *defaultValueIfNotFo } SDLKey Config::translateSpecialStringToSDLKey(char c) const { - SDLKey result; + SDLKey result = SDLK_UNKNOWN; if(c < 0) { switch(c) { case vkAdd: diff --git a/source/glest_game/menu/menu_state_keysetup.cpp b/source/glest_game/menu/menu_state_keysetup.cpp index 2bec00c0..8645ccf3 100644 --- a/source/glest_game/menu/menu_state_keysetup.cpp +++ b/source/glest_game/menu/menu_state_keysetup.cpp @@ -363,8 +363,13 @@ void MenuStateKeysetup::keyUp(char key) { for(int i = 0; i < userProperties.size(); ++i) { string hotKeyName = userProperties[i].first; if(nameValuePair.first == hotKeyName) { - if(keysym > 255) { - userProperties[i].second = keyName; + if(keysym <= SDLK_ESCAPE || keysym > 255) { + if(keysym <= SDLK_ESCAPE) { + userProperties[i].second = intToStr(key); + } + else { + userProperties[i].second = keyName; + } } else { userProperties[i].second = ""; @@ -376,8 +381,13 @@ void MenuStateKeysetup::keyUp(char key) { } if(isNewUserKeyEntry == true) { pair newNameValuePair = nameValuePair; - if(keysym > 255) { - newNameValuePair.second = keyName; + if(keysym <= SDLK_ESCAPE || keysym > 255) { + if(keysym <= SDLK_ESCAPE) { + newNameValuePair.second = intToStr(key); + } + else { + newNameValuePair.second = keyName; + } } else { newNameValuePair.second = key; diff --git a/source/glest_game/menu/menu_state_root.cpp b/source/glest_game/menu/menu_state_root.cpp index b8058fe6..ed0a961c 100644 --- a/source/glest_game/menu/menu_state_root.cpp +++ b/source/glest_game/menu/menu_state_root.cpp @@ -201,6 +201,7 @@ void MenuStateRoot::update(){ void MenuStateRoot::keyDown(char key) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] key = [%d - %c]\n",__FILE__,__FUNCTION__,__LINE__,key,key); Config &configKeys = Config::getInstance(std::pair(cfgMainKeys,cfgUserKeys)); //exit diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 8b9fc236..f9f7a1c0 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -689,8 +689,11 @@ char Window::getNormalKey(SDL_keysym keysym,bool skipSpecialKeys) { if(keyName == "minus sign" || keyName == "minus") { return vkSubtract; } + //if(keyName == "escape") { + // return vkEscape; + //} if(keyName == "escape") { - return vkEscape; + return unicodeKey; } if(keyName == "tab") { return vkTab;