From 8fa916c55de6aee00a0bfa14f70b7ed9df68388f Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 12 Mar 2020 16:29:03 -0700 Subject: [PATCH] Make the toggle fullscreen conditional more readable Each check has been put in its own variable, so the final conditional is more readable, and the ifdef is no longer right smack in the middle of an if-statement. Also the control flow has been changed (the "else" has been removed from the shortcut-checking conditional) so I could put the variables closer to the actual conditional itself. I don't think it affects anything, though. --- desktop_version/src/KeyPoll.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/KeyPoll.cpp b/desktop_version/src/KeyPoll.cpp index f97db4a7..d68c00b9 100644 --- a/desktop_version/src/KeyPoll.cpp +++ b/desktop_version/src/KeyPoll.cpp @@ -77,17 +77,21 @@ void KeyPoll::Poll() if (evt.type == SDL_KEYDOWN) { keymap[evt.key.keysym.sym] = true; + if (evt.key.keysym.sym == SDLK_BACKSPACE) { pressedbackspace = true; } - else if (((evt.key.keysym.sym == SDLK_RETURN || evt.key.keysym.sym == SDLK_f) && + #ifdef __APPLE__ /* OSX prefers the command keys over the alt keys. -flibit */ - (keymap[SDLK_LGUI] || keymap[SDLK_RGUI]) + bool altpressed = keymap[SDLK_LGUI] || keymap[SDLK_RGUI]; #else - (keymap[SDLK_LALT] || keymap[SDLK_RALT]) + bool altpressed = keymap[SDLK_LALT] || keymap[SDLK_RALT]; #endif - ) || evt.key.keysym.sym == SDLK_F11) + bool returnpressed = evt.key.keysym.sym == SDLK_RETURN; + bool fpressed = evt.key.keysym.sym == SDLK_f; + bool f11pressed = evt.key.keysym.sym == SDLK_F11; + if ((altpressed && (returnpressed || fpressed)) || f11pressed) { toggleFullscreen = true; }