diff --git a/source/glest_game/gui/gui.cpp b/source/glest_game/gui/gui.cpp index bb17642db..0dfcffb4e 100644 --- a/source/glest_game/gui/gui.cpp +++ b/source/glest_game/gui/gui.cpp @@ -309,17 +309,23 @@ void Gui::mouseDoubleClickLeftGraphics(int x, int y){ } void Gui::groupKey(int groupIndex){ + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] groupIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,groupIndex); + if(isKeyDown(vkControl)){ + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] groupIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,groupIndex); + selection.assignGroup(groupIndex); } else{ + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] groupIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,groupIndex); + selection.recallGroup(groupIndex); } } void Gui::hotKey(char key){ - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] key = [%c]\n",__FILE__,__FUNCTION__,key); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] key = [%c][%d]\n",__FILE__,__FUNCTION__,key,key); if(key=='G'){ centerCameraOnSelection(); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index f390026a8..3bc799c8c 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -200,10 +200,10 @@ void MainWindow::eventMouseWheel(int x, int y, int zDelta) { } void MainWindow::eventKeyDown(char key){ - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c][%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c][%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key); program->keyDown(key); - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(key == vkReturn) { SDL_keysym keystate = Window::getKeystate(); diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index 5bc4e4836..74bc5ab8a 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -820,7 +820,45 @@ void showCursor(bool b){ } bool isKeyDown(int virtualKey){ - return (GetKeyState(virtualKey) & 0x8000) != 0; + //return (GetKeyState(virtualKey) & 0x8000) != 0; + + char key = static_cast (virtualKey); + const Uint8* keystate = SDL_GetKeyState(0); + + // kinda hack and wrong... + if(key >= 0) { + return keystate[key]; + } + switch(key) { + case vkAdd: + return keystate[SDLK_PLUS] | keystate[SDLK_KP_PLUS]; + case vkSubtract: + return keystate[SDLK_MINUS] | keystate[SDLK_KP_MINUS]; + case vkAlt: + return keystate[SDLK_LALT] | keystate[SDLK_RALT]; + case vkControl: + return keystate[SDLK_LCTRL] | keystate[SDLK_RCTRL]; + case vkShift: + return keystate[SDLK_LSHIFT] | keystate[SDLK_RSHIFT]; + case vkEscape: + return keystate[SDLK_ESCAPE]; + case vkUp: + return keystate[SDLK_UP]; + case vkLeft: + return keystate[SDLK_LEFT]; + case vkRight: + return keystate[SDLK_RIGHT]; + case vkDown: + return keystate[SDLK_DOWN]; + case vkReturn: + return keystate[SDLK_RETURN] | keystate[SDLK_KP_ENTER]; + case vkBack: + return keystate[SDLK_BACKSPACE]; + default: + SystemFlags::OutputDebug(SystemFlags::debugSystem,"isKeyDown called with unknown key.\n"); + break; + } + return false; } // =====================================