diff --git a/source/game/game/chat_manager.cpp b/source/game/game/chat_manager.cpp index 0b3244889..48f36fcc4 100644 --- a/source/game/game/chat_manager.cpp +++ b/source/game/game/chat_manager.cpp @@ -96,7 +96,7 @@ namespace Game { __FILE__, __FUNCTION__, __LINE__, key.keysym.sym, key.keysym.sym); - if (isKeyPressed(SDLK_ESCAPE, key, false) == true) { + if (isKey(SDLK_ESCAPE, key, false) == true) { text.clear(); textCharLength.clear(); editEnabled = false; @@ -186,7 +186,7 @@ namespace Game { //toggle team mode if (editEnabled == false && - isKeyPressed(configKeys.getSDLKey("ChatTeamMode"), key) == true) { + isKey(configKeys.getSDLKey("ChatTeamMode"), key) == true) { if (disableTeamMode == true) { if (!inMenu) { console->addLine(lang. @@ -214,7 +214,7 @@ namespace Game { } - if (isKeyPressed(SDLK_RETURN, key, false) == true) { + if (isKey(SDLK_RETURN, key, false) == true) { SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] key = [%c] [%d]\n", __FILE__, __FUNCTION__, __LINE__, @@ -298,7 +298,7 @@ namespace Game { switchOnEdit(); } } - } else if (isKeyPressed(SDLK_TAB, key, false) == true) { + } else if (isKey(SDLK_TAB, key, false) == true) { if (text.empty() == false) { // First find the prefix characters to auto-complete string @@ -475,7 +475,7 @@ namespace Game { appendText(autoCompleteResult, false, false); } } - } else if (isKeyPressed(SDLK_BACKSPACE, key, false) == true) { + } else if (isKey(SDLK_BACKSPACE, key, false) == true) { SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] key = [%c] [%d]\n", __FILE__, __FUNCTION__, __LINE__, diff --git a/source/game/game/game.cpp b/source/game/game/game.cpp index 36fcb1491..b1044194a 100644 --- a/source/game/game/game.cpp +++ b/source/game/game/game.cpp @@ -6190,12 +6190,11 @@ namespace Game { __LINE__, keyName.c_str(), idx, groupHotKey, groupHotKey); - //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("input.keysym.mod = %d groupHotKey = %d key = %d (%d) [%s] isgroup = %d\n",key.keysym.mod,groupHotKey,key.keysym.sym,key.keysym.unicode,keyName.c_str(),isKeyPressed(groupHotKey,key)); + //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("input.keysym.mod = %d groupHotKey = %d key = %d (%d) [%s] isgroup = %d\n",key.keysym.mod,groupHotKey,key.keysym.sym,key.keysym.unicode,keyName.c_str(),isKey(groupHotKey,key)); if (SystemFlags::VERBOSE_MODE_ENABLED) printf ("input.keysym.mod = %d groupHotKey = %d key = (%d) [%s] isgroup = %d\n", - key.keysym.mod, groupHotKey, key.keysym.sym, keyName.c_str(), - isKeyPressed(groupHotKey, key)); + key.keysym.mod, groupHotKey, key.keysym.sym, keyName.c_str(), isKey(groupHotKey, key)); //printf(" group key check %d scancode:%d sym:%d groupHotKey=%d \n",idx,key.keysym.scancode,key.keysym.sym,groupHotKey); if (key.keysym.sym == groupHotKey) { if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem). @@ -6276,24 +6275,24 @@ namespace Game { //printf("In game checking keypress for key [%d] camera left [%d]\n",key.keysym.sym,configKeys.getSDLKey("CameraModeLeft")); - if (isKeyPressed(configKeys.getSDLKey("RenderInGamePerformance"), key, false) == true) { + if (isKey(configKeys.getSDLKey("RenderInGamePerformance"), key, false) == true) { renderInGamePerformance = !renderInGamePerformance; Config::getInstance().setBool("PerformanceWarningEnabled", renderInGamePerformance, true); } //if(key == configKeys.getCharKey("RenderNetworkStatus")) { - else if (isKeyPressed(configKeys.getSDLKey("RenderNetworkStatus"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("RenderNetworkStatus"), key, false) == true) { renderNetworkStatus = !renderNetworkStatus; } //else if(key == configKeys.getCharKey("ShowFullConsole")) { - else if (isKeyPressed(configKeys.getSDLKey("ShowFullConsole"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("ShowFullConsole"), key, false) == true) { showFullConsole = true; - } else if (isKeyPressed(configKeys.getSDLKey("SetMarker"), key, setMarkerKeyAllowsModifier) == true) { + } else if (isKey(configKeys.getSDLKey("SetMarker"), key, setMarkerKeyAllowsModifier) == true) { setMarker = true; printf("%d\n", key.keysym.scancode); } - else if (isKeyPressed(configKeys.getSDLKey("TogglePhotoMode"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("TogglePhotoMode"), key, false) == true) { photoModeEnabled = !photoModeEnabled; if (photoModeEnabled == true && this->gameSettings.isNetworkGame() == false) { @@ -6304,7 +6303,7 @@ namespace Game { } //Toggle Healthbars - else if (isKeyPressed(configKeys.getSDLKey("ToggleHealthbars"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("ToggleHealthbars"), key, false) == true) { switch (healthbarMode) { case hbvUndefined: healthbarMode = hbvOff; @@ -6346,7 +6345,7 @@ namespace Game { } } //Toggle music - else if (isKeyPressed(configKeys.getSDLKey("ToggleMusic"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("ToggleMusic"), key, false) == true) { if (this->masterserverMode == false) { Config & config = Config::getInstance(); StrSound *gameMusic = @@ -6368,27 +6367,27 @@ namespace Game { } } //move camera left - else if (isKeyPressed(configKeys.getSDLKey("CameraModeLeft"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("CameraModeLeft"), key, false) == true) { gameCamera.setMoveX(-1); camLeftButtonDown = true; } //move camera right - else if (isKeyPressed(configKeys.getSDLKey("CameraModeRight"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("CameraModeRight"), key, false) == true) { gameCamera.setMoveX(1); camRightButtonDown = true; } //move camera up - else if (isKeyPressed(configKeys.getSDLKey("CameraModeUp"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("CameraModeUp"), key, false) == true) { gameCamera.setMoveZ(1); camUpButtonDown = true; } //move camera down - else if (isKeyPressed(configKeys.getSDLKey("CameraModeDown"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("CameraModeDown"), key, false) == true) { gameCamera.setMoveZ(-1); camDownButtonDown = true; } //change camera mode - else if (isKeyPressed(configKeys.getSDLKey("FreeCameraMode"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("FreeCameraMode"), key, false) == true) { if (gameCamera.getState() == GameCamera::sFree) { gameCamera.setState(GameCamera::sGame); string @@ -6413,14 +6412,14 @@ namespace Game { //else ignore! } //reset camera mode to normal - else if (isKeyPressed(configKeys.getSDLKey("ResetCameraMode"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("ResetCameraMode"), key, false) == true) { if (currentCameraFollowUnit != NULL) { currentCameraFollowUnit = NULL; } gameCamera.setState(GameCamera::sGame); } //pause - else if (isKeyPressed(configKeys.getSDLKey("PauseGame"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("PauseGame"), key, false) == true) { //printf("Toggle pause paused = %d\n",paused); //setPaused(!paused); @@ -6448,42 +6447,32 @@ namespace Game { commander.tryResumeGame(false, false); } } - } else if (isKeyPressed(configKeys.getSDLKey("ExtraTeamColorMarker"), key, false) == true) { + } else if (isKey(configKeys.getSDLKey("ExtraTeamColorMarker"), key, false) == true) { //printf("Toggle ExtraTeamColorMarker\n"); toggleTeamColorMarker(); } //switch display color - else if (isKeyPressed (configKeys.getSDLKey("ChangeFontColor"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("ChangeFontColor"), key, false) == true) { gui.switchToNextDisplayColor(); } //increment speed - else if (isKeyPressed(configKeys.getSDLKey("GameSpeedIncrease"), key, false) == true) { - bool - speedChangesAllowed = - !NetworkManager:: - getInstance().isNetworkGameWithConnectedClients(); - if (speedChangesAllowed) { + else if (isKey(configKeys.getSDLKey("GameSpeedIncrease"), key, false) == true) { + if (!NetworkManager::getInstance().isNetworkGameWithConnectedClients()) incSpeed(); - } } //decrement speed - else if (isKeyPressed(configKeys.getSDLKey("GameSpeedDecrease"), key, false) == true) { - bool - speedChangesAllowed = - !NetworkManager:: - getInstance().isNetworkGameWithConnectedClients(); - if (speedChangesAllowed) { - decSpeed(); - } - } else if (isKeyPressed(configKeys.getSDLKey("BookmarkAdd"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("GameSpeedDecrease"), key, false) == true) { + if (!NetworkManager::getInstance().isNetworkGameWithConnectedClients()) + decSpeed(); + } else if (isKey(configKeys.getSDLKey("BookmarkAdd"), key, false) == true) { startMarkCell(); - } else if (isKeyPressed(configKeys.getSDLKey("BookmarkRemove"), key, false) == true) { + } else if (isKey(configKeys.getSDLKey("BookmarkRemove"), key, false) == true) { isUnMarkCellEnabled = true; - } else if (isKeyPressed(configKeys.getSDLKey("CameraFollowSelectedUnit"), key, false) == true) { + } else if (isKey(configKeys.getSDLKey("CameraFollowSelectedUnit"), key, false) == true) { startCameraFollowUnit(); } //exit - else if (isKeyPressed(configKeys.getSDLKey("ExitKey"), key, false) == true) { + else if (isKey(configKeys.getSDLKey("ExitKey"), key, false) == true) { popupMenu.setEnabled(!popupMenu.getEnabled()); popupMenu.setVisible(popupMenu.getEnabled()); } @@ -6506,30 +6495,30 @@ namespace Game { (__FILE__).c_str(), __FUNCTION__, __LINE__, key); - gui.hotKey(key); + gui.hotKeyPressed(key); } else { //rotate camera leftt //if(key == configKeys.getCharKey("CameraRotateLeft")) { - if (isKeyPressed(configKeys.getSDLKey("CameraRotateLeft"), key) == true) { + if (isKey(configKeys.getSDLKey("CameraRotateLeft"), key) == true) { gameCamera.setRotate(-1); } //rotate camera right //else if(key == configKeys.getCharKey("CameraRotateRight")){ - else if (isKeyPressed(configKeys.getSDLKey("CameraRotateRight"), key) == true) { + else if (isKey(configKeys.getSDLKey("CameraRotateRight"), key) == true) { gameCamera.setRotate(1); } //camera up //else if(key == configKeys.getCharKey("CameraRotateUp")) { - else if (isKeyPressed(configKeys.getSDLKey("CameraRotateUp"), key) == true) { + else if (isKey(configKeys.getSDLKey("CameraRotateUp"), key) == true) { gameCamera.setMoveY(1); } //camera down - else if (isKeyPressed(configKeys.getSDLKey("CameraRotateDown"), key) == true) { + else if (isKey(configKeys.getSDLKey("CameraRotateDown"), key) == true) { gameCamera.setMoveY(-1); } } - if (isKeyPressed(configKeys.getSDLKey("SaveGame"), key) == true) { + if (isKey(configKeys.getSDLKey("SaveGame"), key) == true) { saveGame(); } } @@ -6578,12 +6567,22 @@ namespace Game { Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); + if (gameCamera.getState() != GameCamera::sFree) { + if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem). + enabled) + SystemFlags::OutputDebug(SystemFlags::debugSystem, + "In [%s::%s Line: %d] key = %d\n", + extractFileFromDirectoryPath + (__FILE__).c_str(), __FUNCTION__, + __LINE__, key); + + gui.hotKeyReleased(key); + } + //if(key == configKeys.getCharKey("ShowFullConsole")) { - if (isKeyPressed(configKeys.getSDLKey("ShowFullConsole"), key) - == true) { + if (isKey(configKeys.getSDLKey("ShowFullConsole"), key) == true) { showFullConsole = false; - } else if (isKeyPressed(configKeys.getSDLKey("SetMarker"), key) == - true + } else if (isKey(configKeys.getSDLKey("SetMarker"), key) == true #ifdef WIN32 || key.keysym.scancode == 5 #endif @@ -6592,54 +6591,42 @@ namespace Game { } //else if(key == configKeys.getCharKey("CameraRotateLeft") || // key == configKeys.getCharKey("CameraRotateRight")) { - else - if (isKeyPressed - (configKeys.getSDLKey("CameraRotateLeft"), key) == true - || isKeyPressed(configKeys.getSDLKey("CameraRotateRight"), - key) == true) { - gameCamera.setRotate(0); - } + else if (isKey(configKeys.getSDLKey("CameraRotateLeft"), key) == true + || isKey(configKeys.getSDLKey("CameraRotateRight"), key) == true) { + gameCamera.setRotate(0); + } //else if(key == configKeys.getCharKey("CameraRotateDown") || // key == configKeys.getCharKey("CameraRotateUp")) { - else - if (isKeyPressed - (configKeys.getSDLKey("CameraRotateDown"), key) == true - || isKeyPressed(configKeys.getSDLKey("CameraRotateUp"), - key) == true) { + else if (isKey(configKeys.getSDLKey("CameraRotateDown"), key) == true + || isKey(configKeys.getSDLKey("CameraRotateUp"), key) == true) { - gameCamera.setMoveY(0); - } + gameCamera.setMoveY(0); + } //else if(key == configKeys.getCharKey("CameraModeUp")){ - else if (isKeyPressed(configKeys.getSDLKey("CameraModeUp"), key) - == true) { - gameCamera.setMoveZ(0); - camUpButtonDown = false; - calcCameraMoveZ(); - } - //else if(key == configKeys.getCharKey("CameraModeDown")){ - else - if (isKeyPressed(configKeys.getSDLKey("CameraModeDown"), key) - == true) { - gameCamera.setMoveZ(0); - camDownButtonDown = false; - calcCameraMoveZ(); - } + else if (isKey(configKeys.getSDLKey("CameraModeUp"), key) + == true) { + gameCamera.setMoveZ(0); + camUpButtonDown = false; + calcCameraMoveZ(); + } + //else if(key == configKeys.getCharKey("CameraModeDown")){ + else if (isKey(configKeys.getSDLKey("CameraModeDown"), key) == true) { + gameCamera.setMoveZ(0); + camDownButtonDown = false; + calcCameraMoveZ(); + } //else if(key == configKeys.getCharKey("CameraModeLeft")){ - else - if (isKeyPressed(configKeys.getSDLKey("CameraModeLeft"), key) - == true) { - gameCamera.setMoveX(0); - camLeftButtonDown = false; - calcCameraMoveX(); - } + else if (isKey(configKeys.getSDLKey("CameraModeLeft"), key) == true) { + gameCamera.setMoveX(0); + camLeftButtonDown = false; + calcCameraMoveX(); + } //else if(key == configKeys.getCharKey("CameraModeRight")){ - else - if (isKeyPressed(configKeys.getSDLKey("CameraModeRight"), key) - == true) { - gameCamera.setMoveX(0); - camRightButtonDown = false; - calcCameraMoveX(); - } + else if (isKey(configKeys.getSDLKey("CameraModeRight"), key) == true) { + gameCamera.setMoveX(0); + camRightButtonDown = false; + calcCameraMoveX(); + } } } catch (const exception & ex) { char szBuf[8096] = ""; diff --git a/source/game/gui/gui.cpp b/source/game/gui/gui.cpp index b4d967951..23b012672 100644 --- a/source/game/gui/gui.cpp +++ b/source/game/gui/gui.cpp @@ -411,59 +411,52 @@ namespace Game { } } - void Gui::hotKey(SDL_KeyboardEvent key) { + void Gui::hotKeyPressed(SDL_KeyboardEvent key) { if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s] key = [%c][%d]\n", __FILE__, __FUNCTION__, key, key); Config &configKeys = Config::getInstance(std::pair(cfgMainKeys, cfgUserKeys)); - //if(key == configKeys.getCharKey("HotKeyCenterCameraOnSelection")) { - if (isKeyPressed(configKeys.getSDLKey("HotKeyCenterCameraOnSelection"), key) == true) { + if (isKey(configKeys.getSDLKey("HotKeyCenterCameraOnSelection"), key) == true) { centerCameraOnSelection(); - } - //else if(key == configKeys.getCharKey("HotKeySelectIdleHarvesterUnit")) { - else if (isKeyPressed(configKeys.getSDLKey("HotKeySelectIdleHarvesterUnit"), key) == true) { + } else if (isKey(configKeys.getSDLKey("HotKeySelectIdleHarvesterUnit"), key) == true) { selectInterestingUnit(iutIdleHarvester); - } - //else if(key == configKeys.getCharKey("HotKeySelectBuiltBuilding")) { - else if (isKeyPressed(configKeys.getSDLKey("HotKeySelectBuiltBuilding"), key) == true) { + } else if (isKey(configKeys.getSDLKey("HotKeySelectBuiltBuilding"), key) == true) { selectInterestingUnit(iutBuiltBuilding); - } - //else if(key == configKeys.getCharKey("HotKeyDumpWorldToLog")) { - else if (isKeyPressed(configKeys.getSDLKey("HotKeyDumpWorldToLog"), key) == true) { + } else if (isKey(configKeys.getSDLKey("HotKeyDumpWorldToLog"), key) == true) { std::string worldLog = world->DumpWorldToLog(); if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] worldLog dumped to [%s]\n", __FILE__, __FUNCTION__, __LINE__, worldLog.c_str()); - } - //else if(key == configKeys.getCharKey("HotKeyRotateUnitDuringPlacement")){ - else if (isKeyPressed(configKeys.getSDLKey("HotKeyRotateUnitDuringPlacement"), key) == true) { + } else if (isKey(configKeys.getSDLKey("HotKeyRotateUnitDuringPlacement"), key) == true) { // Here the user triggers a unit rotation while placing a unit if (isPlacingBuilding()) { if (getBuilding()->getRotationAllowed()) { ++selectedBuildingFacing; } } - } - //else if(key == configKeys.getCharKey("HotKeySelectDamagedUnit")) { - else if (isKeyPressed(configKeys.getSDLKey("HotKeySelectDamagedUnit"), key) == true) { + } else if (isKey(configKeys.getSDLKey("HotKeySelectDamagedUnit"), key) == true) { selectInterestingUnit(iutDamaged); - } - //else if(key == configKeys.getCharKey("HotKeySelectStoreUnit")) { - else if (isKeyPressed(configKeys.getSDLKey("HotKeySelectStoreUnit"), key) == true) { + } else if (isKey(configKeys.getSDLKey("HotKeySelectStoreUnit"), key) == true) { selectInterestingUnit(iutStore); - } - //else if(key == configKeys.getCharKey("HotKeySelectedUnitsAttack")) { - else if (isKeyPressed(configKeys.getSDLKey("HotKeySelectedUnitsAttack"), key) == true) { + } else if (isKey(configKeys.getSDLKey("HotKeySelectedUnitsAttack"), key) == true) { clickCommonCommand(ccAttack); - } - //else if(key == configKeys.getCharKey("HotKeySelectedUnitsAttack")) { - else if (isKeyPressed(configKeys.getSDLKey("HotKeySelectedUnitsMove"), key) == true) { + } else if (isKey(configKeys.getSDLKey("HotKeySelectedUnitsMove"), key) == true) { clickCommonCommand(ccMove); - } - //else if(key == configKeys.getCharKey("HotKeySelectedUnitsStop")) { - else if (isKeyPressed(configKeys.getSDLKey("HotKeySelectedUnitsStop"), key) == true) { + } else if (isKey(configKeys.getSDLKey("HotKeySelectedUnitsStop"), key) == true) { clickCommonCommand(ccStop); } } + void Gui::hotKeyReleased(SDL_KeyboardEvent key) { + if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s] key = [%c][%d]\n", __FILE__, __FUNCTION__, key, key); + + Config &configKeys = Config::getInstance(std::pair(cfgMainKeys, cfgUserKeys)); + + if (isKey(configKeys.getSDLKey("HotKeySelectedUnitsAttack"), key) == true) { + resetState(); + } else if (isKey(configKeys.getSDLKey("HotKeySelectedUnitsMove"), key) == true) { + resetState(); + } + } + void Gui::switchToNextDisplayColor() { display.switchColor(); } diff --git a/source/game/gui/gui.h b/source/game/gui/gui.h index 3ac77420a..00714f305 100644 --- a/source/game/gui/gui.h +++ b/source/game/gui/gui.h @@ -244,7 +244,8 @@ namespace Game { void mouseDoubleClickLeftGraphics(int x, int y); void mouseDoubleClickRightGraphics(int x, int y, bool prepared); void groupKey(int groupIndex); - void hotKey(SDL_KeyboardEvent key); + void hotKeyPressed(SDL_KeyboardEvent key); + void hotKeyReleased(SDL_KeyboardEvent key); //misc void switchToNextDisplayColor(); diff --git a/source/game/main/battle_end.cpp b/source/game/main/battle_end.cpp index d1ba5fac9..71a68c98b 100644 --- a/source/game/main/battle_end.cpp +++ b/source/game/main/battle_end.cpp @@ -892,7 +892,7 @@ namespace Game { BattleEnd::keyDown(SDL_KeyboardEvent key) { SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s %d]\n", __FILE__, __FUNCTION__, __LINE__); - if (isKeyPressed(SDLK_ESCAPE, key) == true) { + if (isKey(SDLK_ESCAPE, key) == true) { //program->setState(new MainMenu(program)); if (mainMessageBox.getEnabled()) { @@ -901,7 +901,7 @@ namespace Game { Lang & lang = Lang::getInstance(); showMessageBox(lang.getString("ExitToRootMenu"), "", true); } - } else if (isKeyPressed(SDLK_RETURN, key) + } else if (isKey(SDLK_RETURN, key) && mainMessageBox.getEnabled()) { SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d]\n", __FILE__, diff --git a/source/game/main/intro.cpp b/source/game/main/intro.cpp index 0f0147ebe..0efc8109e 100644 --- a/source/game/main/intro.cpp +++ b/source/game/main/intro.cpp @@ -942,9 +942,9 @@ namespace Game { if (keystate.mod & (KMOD_LALT | KMOD_RALT)) { //printf("ALT KEY #1\n"); - if (isKeyPressed(SDLK_RETURN, key) == true || - isKeyPressed(SDLK_RALT, key) == true || - isKeyPressed(SDLK_LALT, key) == true) { + if (isKey(SDLK_RETURN, key) == true || + isKey(SDLK_RALT, key) == true || + isKey(SDLK_LALT, key) == true) { return; } } diff --git a/source/game/main/main.cpp b/source/game/main/main.cpp index 0f4c08b1f..2ab7289b4 100644 --- a/source/game/main/main.cpp +++ b/source/game/main/main.cpp @@ -1544,8 +1544,7 @@ namespace Game { ("In [MainWindow::eventKeyDown] ERROR, program == NULL!"); } - if (popupMenu.getVisible() == true - && isKeyPressed(SDLK_ESCAPE, key) == true) { + if (popupMenu.getVisible() == true && isKey(SDLK_ESCAPE, key) == true) { this->popupMenu.setEnabled(false); this->popupMenu.setVisible(false); return; @@ -1559,7 +1558,7 @@ namespace Game { if (keystate.mod & (KMOD_LALT | KMOD_RALT)) { //if(key == vkReturn) { - if (isKeyPressed(SDLK_RETURN, key) == true) { + if (isKey(SDLK_RETURN, key) == true) { SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] ALT-ENTER pressed\n", __FILE__, __FUNCTION__, __LINE__); @@ -1598,7 +1597,7 @@ namespace Game { Config & configKeys = Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed(configKeys.getSDLKey("HotKeyShowDebug"), key) == + if (isKey(configKeys.getSDLKey("HotKeyShowDebug"), key) == true) { Renderer & renderer = Renderer::getInstance(); @@ -1612,7 +1611,7 @@ namespace Game { renderer.setShowDebugUI(!showDebugUI); } } else if ((keystate.mod & (KMOD_LCTRL | KMOD_RCTRL)) && - isKeyPressed(configKeys.getSDLKey("SwitchLanguage"), + isKey(configKeys.getSDLKey("SwitchLanguage"), key) == true) { if ((keystate.mod & (KMOD_LSHIFT | KMOD_RSHIFT))) { this->triggerLanguageToggle = true; @@ -1621,15 +1620,11 @@ namespace Game { showLanguages(); } } else - if (isKeyPressed - (configKeys.getSDLKey("ReloadINI"), key, - modifiersToCheck) == true) { + if (isKey(configKeys.getSDLKey("ReloadINI"), key, modifiersToCheck) == true) { Config & config = Config::getInstance(); config.reload(); } else - if (isKeyPressed - (configKeys.getSDLKey("Screenshot"), key, - modifiersToCheck) == true) { + if (isKey(configKeys.getSDLKey("Screenshot"), key, modifiersToCheck) == true) { if (SystemFlags::VERBOSE_MODE_ENABLED) printf("Screenshot key pressed\n"); @@ -1760,8 +1755,7 @@ namespace Game { Config & configKeys = Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed - (configKeys.getSDLKey("HotKeyToggleOSMouseEnabled"), c) == true) { + if (isKey(configKeys.getSDLKey("HotKeyToggleOSMouseEnabled"), c) == true) { SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d]\n", __FILE__, __FUNCTION__, __LINE__); diff --git a/source/game/main/program.cpp b/source/game/main/program.cpp index 90e9a8e5c..62f1a6a27 100644 --- a/source/game/main/program.cpp +++ b/source/game/main/program.cpp @@ -196,7 +196,7 @@ namespace Game { // if user pressed return we exit //if(c == 13) { - if (isKeyPressed(SDLK_RETURN, c) == true) { + if (isKey(SDLK_RETURN, c) == true) { program->exit(); userWantsExit = true; } @@ -455,8 +455,7 @@ namespace Game { //if(key == vkEscape || key == SDLK_ESCAPE || // ((key == vkReturn || key == SDLK_RETURN || key == SDLK_KP_ENTER) && !(keystate.mod & (KMOD_LALT | KMOD_RALT)))) { - if (isKeyPressed(SDLK_ESCAPE, key) == true - || ((isKeyPressed(SDLK_RETURN, key) == true) + if (isKey(SDLK_ESCAPE, key) == true || ((isKey(SDLK_RETURN, key) == true) && !(key.keysym.mod & (KMOD_LALT | KMOD_RALT)))) { if (SystemFlags:: getSystemSettingType(SystemFlags::debugSystem).enabled) diff --git a/source/game/menu/main_menu.cpp b/source/game/menu/main_menu.cpp index 3c80d34bc..9ccd1c791 100644 --- a/source/game/menu/main_menu.cpp +++ b/source/game/menu/main_menu.cpp @@ -541,8 +541,8 @@ namespace Game { bool MenuState::keyPressEditLabel(SDL_KeyboardEvent c, GraphicLabel ** activeInputLabelPtr) { - if (isKeyPressed(SDLK_ESCAPE, c, false) == true || - isKeyPressed(SDLK_RETURN, c, false) == true) { + if (isKey(SDLK_ESCAPE, c, false) == true || + isKey(SDLK_RETURN, c, false) == true) { GraphicLabel * activeInputLabel = *activeInputLabelPtr; setActiveInputLabel(NULL, activeInputLabelPtr); @@ -611,7 +611,7 @@ namespace Game { if (activeInputLabel != NULL) { string text = activeInputLabel->getText(); - if (isKeyPressed(SDLK_BACKSPACE, c) == true && text.length() > 0) { + if (isKey(SDLK_BACKSPACE, c) == true && text.length() > 0) { //printf("BSPACE text [%s]\n",text.c_str()); bool diff --git a/source/game/menu/menu_state_about.cpp b/source/game/menu/menu_state_about.cpp index c7510d8f2..b69e03aa2 100644 --- a/source/game/menu/menu_state_about.cpp +++ b/source/game/menu/menu_state_about.cpp @@ -369,7 +369,7 @@ namespace Game { Config & configKeys = Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) == true) { + if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { GraphicComponent::saveAllCustomProperties(containerName); } } diff --git a/source/game/menu/menu_state_connected_game.cpp b/source/game/menu/menu_state_connected_game.cpp index 2912561d7..0ef79420b 100644 --- a/source/game/menu/menu_state_connected_game.cpp +++ b/source/game/menu/menu_state_connected_game.cpp @@ -5953,11 +5953,9 @@ namespace Game { Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed(configKeys.getSDLKey("ShowFullConsole"), key) == - true) { + if (isKey(configKeys.getSDLKey("ShowFullConsole"), key) == true) { showFullConsole = true; - } else if (isKeyPressed(configKeys.getSDLKey("ToggleMusic"), key) == - true) { + } else if (isKey(configKeys.getSDLKey("ToggleMusic"), key) == true) { Config & config = Config::getInstance(); Lang & lang = Lang::getInstance(); @@ -5979,8 +5977,7 @@ namespace Game { } } //else if(key == configKeys.getCharKey("SaveGUILayout")) { - else if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) - == true) { + else if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { bool saved = GraphicComponent::saveAllCustomProperties(containerName); @@ -6049,8 +6046,7 @@ namespace Game { if (chatManager.getEditEnabled()) { //send key to the chat manager chatManager.keyUp(key); - } else if (isKeyPressed(configKeys.getSDLKey("ShowFullConsole"), key) - == true) { + } else if (isKey(configKeys.getSDLKey("ShowFullConsole"), key) == true) { showFullConsole = false; } } diff --git a/source/game/menu/menu_state_custom_game.cpp b/source/game/menu/menu_state_custom_game.cpp index e6b08f3b6..2e1ee76ed 100644 --- a/source/game/menu/menu_state_custom_game.cpp +++ b/source/game/menu/menu_state_custom_game.cpp @@ -5381,45 +5381,41 @@ namespace Game { ConfigType >(cfgMainKeys, cfgUserKeys)); //if(key == configKeys.getCharKey("ShowFullConsole")) { - if (isKeyPressed(configKeys.getSDLKey("ShowFullConsole"), key) - == true) { + if (isKey(configKeys.getSDLKey("ShowFullConsole"), key) == true) { showFullConsole = true; } //Toggle music //else if(key == configKeys.getCharKey("ToggleMusic")) { - else - if (isKeyPressed(configKeys.getSDLKey("ToggleMusic"), key) - == true) { - Config & config = Config::getInstance(); - Lang & lang = Lang::getInstance(); + else if (isKey(configKeys.getSDLKey("ToggleMusic"), key) == true) { + Config & config = Config::getInstance(); + Lang & lang = Lang::getInstance(); - float configVolume = (config.getInt("SoundVolumeMusic") / 100.f); - float currentVolume = - CoreData::getInstance().getMenuMusic()->getVolume(); - if (currentVolume > 0) { - CoreData::getInstance().getMenuMusic()->setVolume(0.f); - console.addLine(lang.getString("GameMusic") + " " + - lang.getString("Off")); - } else { - CoreData::getInstance(). - getMenuMusic()->setVolume(configVolume); - //If the config says zero, use the default music volume - //gameMusic->setVolume(configVolume ? configVolume : 0.9); - console.addLine(lang.getString("GameMusic")); - } + float configVolume = (config.getInt("SoundVolumeMusic") / 100.f); + float currentVolume = + CoreData::getInstance().getMenuMusic()->getVolume(); + if (currentVolume > 0) { + CoreData::getInstance().getMenuMusic()->setVolume(0.f); + console.addLine(lang.getString("GameMusic") + " " + + lang.getString("Off")); + } else { + CoreData::getInstance(). + getMenuMusic()->setVolume(configVolume); + //If the config says zero, use the default music volume + //gameMusic->setVolume(configVolume ? configVolume : 0.9); + console.addLine(lang.getString("GameMusic")); } + } //else if(key == configKeys.getCharKey("SaveGUILayout")) { - else - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) - == true) { - bool saved = - GraphicComponent::saveAllCustomProperties(containerName); - Lang & lang = Lang::getInstance(); - console.addLine(lang.getString("GUILayoutSaved") + " [" + - (saved ? lang. - getString("Yes") : lang.getString("No")) + - "]"); - } + else if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) + == true) { + bool saved = + GraphicComponent::saveAllCustomProperties(containerName); + Lang & lang = Lang::getInstance(); + console.addLine(lang.getString("GUILayoutSaved") + " [" + + (saved ? lang. + getString("Yes") : lang.getString("No")) + + "]"); + } } } } @@ -5477,11 +5473,9 @@ namespace Game { } } //else if(key == configKeys.getCharKey("ShowFullConsole")) { - else - if (isKeyPressed(configKeys.getSDLKey("ShowFullConsole"), key) - == true) { - showFullConsole = false; - } + else if (isKey(configKeys.getSDLKey("ShowFullConsole"), key) == true) { + showFullConsole = false; + } } } diff --git a/source/game/menu/menu_state_graphic_info.cpp b/source/game/menu/menu_state_graphic_info.cpp index f5d8eab8b..d058511a0 100644 --- a/source/game/menu/menu_state_graphic_info.cpp +++ b/source/game/menu/menu_state_graphic_info.cpp @@ -193,7 +193,7 @@ namespace Game { Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); //if(key == configKeys.getCharKey("SaveGUILayout")) { - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) == true) { + if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { GraphicComponent::saveAllCustomProperties(containerName); //Lang &lang= Lang::getInstance(); //console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang.getString("Yes") : lang.getString("No"))+ "]"); diff --git a/source/game/menu/menu_state_join_game.cpp b/source/game/menu/menu_state_join_game.cpp index 3795dab51..44197777d 100644 --- a/source/game/menu/menu_state_join_game.cpp +++ b/source/game/menu/menu_state_join_game.cpp @@ -764,7 +764,7 @@ namespace Game { ConfigType >(cfgMainKeys, cfgUserKeys)); string text = labelServerIp.getText(); - if (isKeyPressed(SDLK_BACKSPACE, key) == true && text.length() > 0) { + if (isKey(SDLK_BACKSPACE, key) == true && text.length() > 0) { if (SystemFlags:: getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, @@ -782,10 +782,8 @@ namespace Game { labelServerIp.setText(text); } //else if(key == configKeys.getCharKey("SaveGUILayout")) { - else if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) == - true) { - bool saved = - GraphicComponent::saveAllCustomProperties(containerName); + else if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { + bool saved = GraphicComponent::saveAllCustomProperties(containerName); Lang & lang = Lang::getInstance(); console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang. @@ -806,10 +804,8 @@ namespace Game { Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); //if(key == configKeys.getCharKey("SaveGUILayout")) { - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) == - true) { - bool saved = - GraphicComponent::saveAllCustomProperties(containerName); + if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { + bool saved = GraphicComponent::saveAllCustomProperties(containerName); Lang & lang = Lang::getInstance(); console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang. diff --git a/source/game/menu/menu_state_load_game.cpp b/source/game/menu/menu_state_load_game.cpp index 72b8b1714..f1161d9df 100644 --- a/source/game/menu/menu_state_load_game.cpp +++ b/source/game/menu/menu_state_load_game.cpp @@ -528,7 +528,7 @@ namespace Game { Config & configKeys = Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) == true) { + if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { GraphicComponent::saveAllCustomProperties(containerName); } } diff --git a/source/game/menu/menu_state_masterserver.cpp b/source/game/menu/menu_state_masterserver.cpp index c053a9f33..f41554a52 100644 --- a/source/game/menu/menu_state_masterserver.cpp +++ b/source/game/menu/menu_state_masterserver.cpp @@ -1563,7 +1563,7 @@ namespace Game { (__FILE__).c_str()) + "_" + intToStr(__LINE__)); //if (key == vkReturn && ircClient != NULL) { - if (isKeyPressed(SDLK_RETURN, key, false) == true + if (isKey(SDLK_RETURN, key, false) == true && ircClient != NULL) { ircClient->SendIRCCmdMessage(IRC_CHANNEL, chatManager.getText()); @@ -1573,7 +1573,7 @@ namespace Game { } if (chatManager.getEditEnabled() == false) { //if(key == configKeys.getCharKey("ToggleMusic")) { - if (isKeyPressed(configKeys.getSDLKey("ToggleMusic"), key) == true) { + if (isKey(configKeys.getSDLKey("ToggleMusic"), key) == true) { Config & config = Config::getInstance(); Lang & lang = Lang::getInstance(); @@ -1593,7 +1593,7 @@ namespace Game { } } //else if(key == configKeys.getCharKey("SaveGUILayout")) { - else if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) == + else if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { bool saved = GraphicComponent::saveAllCustomProperties(containerName); diff --git a/source/game/menu/menu_state_mods.cpp b/source/game/menu/menu_state_mods.cpp index 1cd7db142..2acd6076c 100644 --- a/source/game/menu/menu_state_mods.cpp +++ b/source/game/menu/menu_state_mods.cpp @@ -3257,8 +3257,7 @@ namespace Game { Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); //if(key == configKeys.getCharKey("ShowFullConsole")) { - if (isKeyPressed(configKeys.getSDLKey("ShowFullConsole"), key) == - true) { + if (isKey(configKeys.getSDLKey("ShowFullConsole"), key) == true) { showFullConsole = true; } } @@ -3271,8 +3270,7 @@ namespace Game { Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); //if(key== configKeys.getCharKey("ShowFullConsole")) { - if (isKeyPressed(configKeys.getSDLKey("ShowFullConsole"), key) == - true) { + if (isKey(configKeys.getSDLKey("ShowFullConsole"), key) == true) { showFullConsole = false; } } diff --git a/source/game/menu/menu_state_new_game.cpp b/source/game/menu/menu_state_new_game.cpp index 829b8cfdd..b6b3e2607 100644 --- a/source/game/menu/menu_state_new_game.cpp +++ b/source/game/menu/menu_state_new_game.cpp @@ -169,7 +169,7 @@ namespace Game { Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); //if(key == configKeys.getCharKey("SaveGUILayout")) { - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) == true) { + if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { GraphicComponent::saveAllCustomProperties(containerName); //Lang &lang= Lang::getInstance(); //console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang.getString("Yes") : lang.getString("No"))+ "]"); diff --git a/source/game/menu/menu_state_options.cpp b/source/game/menu/menu_state_options.cpp index e947fbbab..b7598a7ae 100644 --- a/source/game/menu/menu_state_options.cpp +++ b/source/game/menu/menu_state_options.cpp @@ -1154,7 +1154,7 @@ namespace Game { Config & configKeys = Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), c) == true) { + if (isKey(configKeys.getSDLKey("SaveGUILayout"), c) == true) { GraphicComponent::saveAllCustomProperties(containerName); //Lang &lang= Lang::getInstance(); //console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang.getString("Yes") : lang.getString("No"))+ "]"); diff --git a/source/game/menu/menu_state_options_graphics.cpp b/source/game/menu/menu_state_options_graphics.cpp index 6a02ca5ec..9b60f2e39 100644 --- a/source/game/menu/menu_state_options_graphics.cpp +++ b/source/game/menu/menu_state_options_graphics.cpp @@ -889,7 +889,7 @@ namespace Game { Config & configKeys = Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), c) == true) { + if (isKey(configKeys.getSDLKey("SaveGUILayout"), c) == true) { GraphicComponent::saveAllCustomProperties(containerName); //Lang &lang= Lang::getInstance(); //console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang.getString("Yes") : lang.getString("No"))+ "]"); diff --git a/source/game/menu/menu_state_options_network.cpp b/source/game/menu/menu_state_options_network.cpp index 1d6979301..bea8a4022 100644 --- a/source/game/menu/menu_state_options_network.cpp +++ b/source/game/menu/menu_state_options_network.cpp @@ -509,7 +509,7 @@ namespace Game { Config & configKeys = Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), c) == true) { + if (isKey(configKeys.getSDLKey("SaveGUILayout"), c) == true) { GraphicComponent::saveAllCustomProperties(containerName); //Lang &lang= Lang::getInstance(); //console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang.getString("Yes") : lang.getString("No"))+ "]"); diff --git a/source/game/menu/menu_state_options_sound.cpp b/source/game/menu/menu_state_options_sound.cpp index b118ee9cc..398bd4aaf 100644 --- a/source/game/menu/menu_state_options_sound.cpp +++ b/source/game/menu/menu_state_options_sound.cpp @@ -405,7 +405,7 @@ namespace Game { Config & configKeys = Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), c) == true) { + if (isKey(configKeys.getSDLKey("SaveGUILayout"), c) == true) { GraphicComponent::saveAllCustomProperties(containerName); //Lang &lang= Lang::getInstance(); //console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang.getString("Yes") : lang.getString("No"))+ "]"); diff --git a/source/game/menu/menu_state_root.cpp b/source/game/menu/menu_state_root.cpp index f60c6afe4..d4de24d81 100644 --- a/source/game/menu/menu_state_root.cpp +++ b/source/game/menu/menu_state_root.cpp @@ -904,13 +904,13 @@ namespace Game { //exit //if(key == configKeys.getCharKey("ExitKey")) { //printf("Check Root menu exit key!\n"); - if (isKeyPressed(configKeys.getSDLKey("ExitKey"), key) == true) { + if (isKey(configKeys.getSDLKey("ExitKey"), key) == true) { Lang & lang = Lang::getInstance(); showMessageBox(lang.getString("ExitGameQuestion"), "", true); } //else if(mainMessageBox.getEnabled() == true && key == vkReturn) { else if (mainMessageBox.getEnabled() == true - && isKeyPressed(SDLK_RETURN, key) == true) { + && isKey(SDLK_RETURN, key) == true) { //SDL_keysym keystate = Window::getKeystate(); SDL_keysym keystate = key.keysym; if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem). @@ -928,8 +928,7 @@ namespace Game { } } //else if(key == configKeys.getCharKey("SaveGUILayout")) { - else if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) == - true) { + else if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { GraphicComponent::saveAllCustomProperties(containerName); //Lang &lang= Lang::getInstance(); //console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang.getString("Yes") : lang.getString("No"))+ "]"); diff --git a/source/game/menu/menu_state_scenario.cpp b/source/game/menu/menu_state_scenario.cpp index 8742463a6..ce7c40068 100644 --- a/source/game/menu/menu_state_scenario.cpp +++ b/source/game/menu/menu_state_scenario.cpp @@ -614,7 +614,7 @@ namespace Game { Config & configKeys = Config::getInstance(std::pair < ConfigType, ConfigType >(cfgMainKeys, cfgUserKeys)); - if (isKeyPressed(configKeys.getSDLKey("SaveGUILayout"), key) == true) { + if (isKey(configKeys.getSDLKey("SaveGUILayout"), key) == true) { GraphicComponent::saveAllCustomProperties(containerName); } } diff --git a/source/shared_lib/include/platform/sdl/window.h b/source/shared_lib/include/platform/sdl/window.h index 66a3f39c5..c62306a33 100644 --- a/source/shared_lib/include/platform/sdl/window.h +++ b/source/shared_lib/include/platform/sdl/window.h @@ -313,8 +313,8 @@ namespace Shared { static wchar_t convertStringtoSDLKey(const string &value); }; - bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input, vector modifiersToCheck); - bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input, bool modifiersAllowed = true); + bool isKey(SDL_Keycode compareKey, SDL_KeyboardEvent input, vector modifiersToCheck); + bool isKey(SDL_Keycode compareKey, SDL_KeyboardEvent input, bool modifiersAllowed = true); SDL_Keycode extractKeyPressed(SDL_KeyboardEvent input); //bool isAllowedInputTextKey(SDL_Keycode key); diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 882cff0ca..adeff2efa 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -800,7 +800,7 @@ namespace Shared { return result; } - bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input, bool modifiersAllowed) { + bool isKey(SDL_Keycode compareKey, SDL_KeyboardEvent input, bool modifiersAllowed) { vector modifiersToCheck; if (modifiersAllowed == false) { modifiersToCheck.push_back(KMOD_LCTRL); @@ -809,10 +809,11 @@ namespace Shared { modifiersToCheck.push_back(KMOD_RALT); } - bool result = isKeyPressed(compareKey, input, modifiersToCheck); + bool result = isKey(compareKey, input, modifiersToCheck); return result; } - bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input, vector modifiersToCheck) { + + bool isKey(SDL_Keycode compareKey, SDL_KeyboardEvent input, vector modifiersToCheck) { //Uint16 c = SDLK_UNKNOWN; SDL_Keycode c = SDLK_UNKNOWN; //if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) { @@ -820,7 +821,7 @@ namespace Shared { c = input.keysym.sym; } - //printf("START isKeyPressed input = %d compare = %d mod = %d\n",c,compareKey,input.keysym.mod); + //printf("START isKey input = %d compare = %d mod = %d\n",c,compareKey,input.keysym.mod); // if(compareKey == SDLK_QUESTION && (c == SDLK_SLASH && (input.keysym.mod & (KMOD_SHIFT)))) {