From 18949d375c79329ac2b6adf6d0249430402c5908 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 11 Aug 2021 12:09:58 +0200 Subject: [PATCH] Minor cosmetic code cleanup. --- es-app/src/guis/GuiMenu.cpp | 14 +++++++------- es-core/src/InputManager.cpp | 18 +++++++++--------- es-core/src/Settings.cpp | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 82bbcf9a2..3cd80dc9f 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -844,23 +844,23 @@ void GuiMenu::openOtherOptions() #endif // Exit button configuration. - auto exit_button_config = std::make_shared> - (mWindow, getHelpStyle(), "EXIT BUTTON COMBO", false); + auto exit_button_config = std::make_shared>( + mWindow, getHelpStyle(), "EXIT BUTTON COMBO", false); std::string selectedExitButtonCombo = Settings::getInstance()->getString("ExitButtonCombo"); exit_button_config->add("F4", "F4", selectedExitButtonCombo == "F4"); exit_button_config->add("Alt + F4", "AltF4", selectedExitButtonCombo == "AltF4"); - #if defined(_WIN64) || defined(__unix__) +#if defined(_WIN64) || defined(__unix__) exit_button_config->add("Alt + Q", "AltQ", selectedExitButtonCombo == "AltQ"); - #endif - #if defined(__APPLE__) +#endif +#if defined(__APPLE__) exit_button_config->add("\u2318 + Q", "CmdQ", selectedExitButtonCombo == "CmdQ"); - #endif +#endif s->addWithLabel("EXIT BUTTON COMBO", exit_button_config); s->addSaveFunc([exit_button_config, s] { if (exit_button_config->getSelected() != Settings::getInstance()->getString("ExitButtonCombo")) { Settings::getInstance()->setString("ExitButtonCombo", - exit_button_config->getSelected()); + exit_button_config->getSelected()); s->setNeedsSaving(); } }); diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index 6b5d1bccc..8a0999efc 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -29,8 +29,8 @@ int SDL_USER_CECBUTTONDOWN = -1; int SDL_USER_CECBUTTONUP = -1; // Save button states for combo-button exit support and predefine exit option-function map. -static bool altDown = false; -static bool lguiDown = false; +static bool sAltDown = false; +static bool sLguiDown = false; InputManager* InputManager::sInstance = nullptr; @@ -433,9 +433,9 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window) // Save button states for alt and command. if (event.key.keysym.sym == SDLK_LALT) - altDown = true; + sAltDown = true; if (event.key.keysym.sym == SDLK_LGUI) - lguiDown = true; + sLguiDown = true; if (event.key.keysym.sym == SDLK_BACKSPACE && SDL_IsTextInputActive()) window->textInput("\b"); @@ -447,11 +447,11 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window) bool exitState; std::string exitOption = Settings::getInstance()->getString("ExitButtonCombo"); if (exitOption == "AltF4") - exitState = event.key.keysym.sym == SDLK_F4 && altDown; + exitState = event.key.keysym.sym == SDLK_F4 && sAltDown; else if (exitOption == "CmdQ") - exitState = event.key.keysym.sym == SDLK_q && lguiDown; + exitState = event.key.keysym.sym == SDLK_q && sLguiDown; else if (exitOption == "AltQ") - exitState = event.key.keysym.sym == SDLK_q && altDown; + exitState = event.key.keysym.sym == SDLK_q && sAltDown; else exitState = event.key.keysym.sym == SDLK_F4; if (exitState) { @@ -469,9 +469,9 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window) // Release button states. if (event.key.keysym.sym == SDLK_LALT) - altDown = false; + sAltDown = false; if (event.key.keysym.sym == SDLK_LGUI) - lguiDown = false; + sLguiDown = false; window->input(getInputConfigByDevice(DEVICE_KEYBOARD), Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 0, false)); diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 5b7b3b8e4..1d1822a54 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -225,6 +225,7 @@ void Settings::setDefaults() mStringMap["VideoPlayer"] = { "ffmpeg", "ffmpeg" }; #endif #endif + mStringMap["ExitButtonCombo"] = { "F4", "F4" }; mStringMap["SaveGamelistsMode"] = { "always", "always" }; #if defined(_WIN64) mBoolMap["HideTaskbar"] = { false, false }; @@ -247,7 +248,6 @@ void Settings::setDefaults() mBoolMap["DisableComposition"] = { true, true }; #endif mBoolMap["DisplayGPUStatistics"] = { false, false }; - mStringMap["ExitButtonCombo"] = { "F4", "F4" }; // macOS requires root privileges to reboot and power off so it doesn't make much // sense to enable this setting and menu entry for that operating system. #if !defined(__APPLE__)