diff --git a/source/glest_game/menu/menu_state_keysetup.cpp b/source/glest_game/menu/menu_state_keysetup.cpp index 2a7894b67..306694fa0 100644 --- a/source/glest_game/menu/menu_state_keysetup.cpp +++ b/source/glest_game/menu/menu_state_keysetup.cpp @@ -339,7 +339,7 @@ void MenuStateKeysetup::showMessageBox(const string &text, const string &header, void MenuStateKeysetup::keyDown(SDL_KeyboardEvent key) { hotkeyChar = extractKeyPressed(key); - printf("\nkeyDown [%d]\n",hotkeyChar); + //printf("\nkeyDown [%d]\n",hotkeyChar); string keyName = ""; if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDLK_LAST) { @@ -369,7 +369,7 @@ void MenuStateKeysetup::keyDown(SDL_KeyboardEvent key) { char szBuf[1024] = ""; //sprintf(szBuf,"%s [%d][%d]",keyName.c_str(),key.keysym.sym,keysym); - sprintf(szBuf,"%s [%d][%d]",keyName.c_str(),key.keysym.sym,hotkeyChar); + sprintf(szBuf,"%s [%d][%d][%d]",keyName.c_str(),key.keysym.sym,hotkeyChar,key.keysym.unicode); labelTestValue.setText(szBuf); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] hotkeyChar [%d]\n",__FILE__,__FUNCTION__,__LINE__,hotkeyChar); diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index b037483d7..f9a96d584 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -40,6 +40,41 @@ using Shared::Util::Checksum; namespace Shared { namespace PlatformCommon { static const int IGNORE_CMD_RESULT_VALUE = -999999; + +// keycode constants (unfortunately designed after DirectInput and therefore not +// very specific) +// They also have to fit into a char. The positive numbers seem to be equal +// to ascii, for the rest we have to find sensefull mappings from SDL (which is +// alot more fine grained like left/right control instead of just control...) +const char vkAdd = -1; +const char vkSubtract = -2; +const char vkAlt = -3; +const char vkControl = -4; +const char vkShift = -5; +const char vkEscape = -6; +const char vkUp = -7; +const char vkLeft = -8; +const char vkRight = -9; +const char vkDown = -10; +const char vkReturn = -11; +const char vkBack = -12; +const char vkTab = -13; +const char vkF1 = -14; +const char vkF2 = -15; +const char vkF3 = -16; +const char vkF4 = -17; +const char vkF5 = -18; +const char vkF6 = -19; +const char vkF7 = -20; +const char vkF8 = -21; +const char vkF9 = -22; +const char vkF10 = -23; +const char vkF11 = -24; +const char vkF12 = -25; +const char vkDelete = -26; +const char vkPrint = -27; +const char vkPause = -29; + // ===================================================== // class PerformanceTimer // ===================================================== @@ -185,6 +220,7 @@ void sleep(int millis); bool isCursorShowing(); void showCursor(bool b); bool isKeyDown(int virtualKey); +//bool isKeyDown(SDLKey key); string getCommandLine(); #define SPACES " " diff --git a/source/shared_lib/include/platform/sdl/window.h b/source/shared_lib/include/platform/sdl/window.h index 1309e58b4..97ce7e5be 100644 --- a/source/shared_lib/include/platform/sdl/window.h +++ b/source/shared_lib/include/platform/sdl/window.h @@ -76,41 +76,6 @@ public: } }; - -// keycode constants (unfortunately designed after DirectInput and therefore not -// very specific) -// They also have to fit into a char. The positive numbers seem to be equal -// to ascii, for the rest we have to find sensefull mappings from SDL (which is -// alot more fine grained like left/right control instead of just control...) -const char vkAdd = -1; -const char vkSubtract = -2; -const char vkAlt = -3; -const char vkControl = -4; -const char vkShift = -5; -const char vkEscape = -6; -const char vkUp = -7; -const char vkLeft = -8; -const char vkRight = -9; -const char vkDown = -10; -const char vkReturn = -11; -const char vkBack = -12; -const char vkTab = -13; -const char vkF1 = -14; -const char vkF2 = -15; -const char vkF3 = -16; -const char vkF4 = -17; -const char vkF5 = -18; -const char vkF6 = -19; -const char vkF7 = -20; -const char vkF8 = -21; -const char vkF9 = -22; -const char vkF10 = -23; -const char vkF11 = -24; -const char vkF12 = -25; -const char vkDelete = -26; -const char vkPrint = -27; -const char vkPause = -29; - enum WindowStyle{ wsFullscreen, wsWindowedFixed, @@ -225,8 +190,8 @@ private: void handleMouseDown(SDL_Event event); static MouseButton getMouseButton(int sdlButton); - static char getKey(SDL_keysym keysym, bool skipSpecialKeys=false); - static char getNormalKey(SDL_keysym keysym,bool skipSpecialKeys=false); + //static char getKey(SDL_keysym keysym, bool skipSpecialKeys=false); + //static char getNormalKey(SDL_keysym keysym,bool skipSpecialKeys=false); static void toggleFullscreen(); }; diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 4db738040..49c66de9a 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -1596,6 +1596,21 @@ void showCursor(bool b) { SDL_ShowCursor(b == true ? SDL_ENABLE : SDL_DISABLE); } +//bool isKeyDown(SDLKey key) { +// const Uint8* keystate = SDL_GetKeyState(0); +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key); +// +// if(key >= 0) { +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keystate[key] = %d\n",__FILE__,__FUNCTION__,__LINE__,keystate[key]); +// +// return (keystate[key] != 0); +// } +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning false\n",__FILE__,__FUNCTION__,__LINE__); +// return false; +// +//} + bool isKeyDown(int virtualKey) { char key = static_cast (virtualKey); const Uint8* keystate = SDL_GetKeyState(0); @@ -1647,7 +1662,6 @@ bool isKeyDown(int virtualKey) { return false; } - string replaceAll(string& context, const string& from, const string& to) { size_t lookHere = 0; size_t foundHere = 0; diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index e9d4bbcbc..f40c858ce 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -577,6 +577,7 @@ MouseButton Window::getMouseButton(int sdlButton) { } } +/* char Window::getRawKey(SDL_keysym keysym) { char result = 0; // Because Control messes up unicode character @@ -941,6 +942,7 @@ char Window::getKey(SDL_keysym keysym,bool skipSpecialKeys) { return result; } +*/ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input) { Uint16 c = 0;