Minor cosmetic code cleanup.

This commit is contained in:
Leon Styhre 2021-08-11 12:09:58 +02:00
parent d596c96181
commit 18949d375c
3 changed files with 17 additions and 17 deletions

View file

@ -844,17 +844,17 @@ void GuiMenu::openOtherOptions()
#endif
// Exit button configuration.
auto exit_button_config = std::make_shared<OptionListComponent<std::string>>
(mWindow, getHelpStyle(), "EXIT BUTTON COMBO", false);
auto exit_button_config = std::make_shared<OptionListComponent<std::string>>(
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() !=

View file

@ -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));

View file

@ -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__)