From e23682615d52fb528cad55e5846042420fd0ced3 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 12 Mar 2020 16:00:18 -0700 Subject: [PATCH] Allow using F11 and (on macOS) RCmd+Enter/F to toggle fullscreen This patch allows the use of pressing F11 to toggle fullscreen, as well as allowing the use of Right Command when using the Command+Enter/F shortcut on macOS. Apparently Alt+Enter isn't the only shortcut to toggle fullscreen, Alt+F also works, which I didn't know before. I'm adding F11 as a shortcut because it's a far more natural shortcut to toggle fullscreen than this Alt+Enter or Alt+F business, which seems to be a relic mimicking some other games and some Microsoft stuff? I'm also adding RCommand+Enter/F because I see no reason not to. If you can use RAlt on non-macOS, why can't you use RCommand on macOS, too? I also cleaned up the formatting relating to the shortcut code, and made sure the closing parenthesis was outside the ifdef so my text editor wouldn't highlight the parenthesis inside the non-macOS ifdef-branch as a dangling closing parenthesis, because it assumes the one in the branch above is the actual closing parenthesis and doesn't parse macros. --- desktop_version/src/KeyPoll.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/desktop_version/src/KeyPoll.cpp b/desktop_version/src/KeyPoll.cpp index a9cccbe7..f97db4a7 100644 --- a/desktop_version/src/KeyPoll.cpp +++ b/desktop_version/src/KeyPoll.cpp @@ -81,14 +81,13 @@ void KeyPoll::Poll() { pressedbackspace = true; } - else if ( ( evt.key.keysym.sym == SDLK_RETURN || - evt.key.keysym.sym == SDLK_f ) && -#ifdef __APPLE__ /* OSX prefers the command key over the alt keys. -flibit */ - keymap[SDLK_LGUI] ) + 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]) #else - ( keymap[SDLK_LALT] || - keymap[SDLK_RALT] ) ) + (keymap[SDLK_LALT] || keymap[SDLK_RALT]) #endif + ) || evt.key.keysym.sym == SDLK_F11) { toggleFullscreen = true; }