From 249dfc84ae2cb68f7eb31b6db64eebacb4c68a08 Mon Sep 17 00:00:00 2001 From: robxnano <89391914+robxnano@users.noreply.github.com> Date: Fri, 30 Sep 2022 23:30:36 +0100 Subject: [PATCH] Revert "SDL2: Stop hotkey commands accepting both Alt and Super when swap_opt_cmd = true" The previous revert failed. This reverts commit e28a9fc3a9c1f5b114ec4d3b48ac04319e4e00dd. --- BasiliskII/src/SDL/video_sdl.cpp | 16 +++++------ BasiliskII/src/SDL/video_sdl2.cpp | 44 ++++++++++++++----------------- BasiliskII/src/Unix/video_x.cpp | 22 ++++++++-------- SheepShaver/src/Unix/video_x.cpp | 22 ++++++++-------- 4 files changed, 50 insertions(+), 54 deletions(-) diff --git a/BasiliskII/src/SDL/video_sdl.cpp b/BasiliskII/src/SDL/video_sdl.cpp index 57509fa6..55672763 100644 --- a/BasiliskII/src/SDL/video_sdl.cpp +++ b/BasiliskII/src/SDL/video_sdl.cpp @@ -120,8 +120,8 @@ static const bool use_vosf = false; // VOSF not possible #endif static bool ctrl_down = false; // Flag: Ctrl key pressed (for use with hotkeys) -static bool alt_down = false; // Flag: Alt/Opt key pressed (for use with hotkeys) -static bool super_down = false; // Flag: Super/Cmd/Win key pressed (for use with hotkeys) +static bool opt_down = false; // Flag: Opt/Alt key pressed (for use with hotkeys) +static bool cmd_down = false; // Flag: Cmd/Super/Win key pressed (for use with hotkeys) static bool caps_on = false; // Flag: Caps Lock on static bool quit_full_screen = false; // Flag: DGA close requested from redraw thread static bool emerg_quit = false; // Flag: Ctrl-Esc pressed, emergency quit requested from MacOS thread @@ -1638,8 +1638,8 @@ static bool is_hotkey_down(SDL_keysym const & ks) int hotkey = PrefsFindInt32("hotkey"); if (!hotkey) hotkey = 1; return (ctrl_down || (ks.mod & KMOD_CTRL) || !(hotkey & 1)) && - (alt_down || (ks.mod & KMOD_ALT) || !(hotkey & 2)) && - (super_down || (ks.mod & KMOD_META) || !(hotkey & 4)); + (opt_down || (ks.mod & KMOD_ALT) || !(hotkey & 2)) && + (cmd_down || (ks.mod & KMOD_META) || !(hotkey & 4)); } static int modify_opt_cmd(int code) { @@ -1875,10 +1875,10 @@ static void handle_events(void) if (code == 0x36) { ctrl_down = true; } else if (code == 0x3a) { - alt_down = true; + opt_down = true; code = modify_opt_cmd(code); } else if (code == 0x37) { - super_down = true; + cmd_down = true; code = modify_opt_cmd(code); } if (code == 0x39) { // Caps Lock pressed @@ -1909,10 +1909,10 @@ static void handle_events(void) if (code == 0x36) { ctrl_down = false; } else if (code == 0x3a) { - alt_down = false; + opt_down = false; code = modify_opt_cmd(code); } else if (code == 0x37) { - super_down = false; + cmd_down = false; code = modify_opt_cmd(code); } if (code == 0x39) { // Caps Lock released diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index 65ffdaec..b1ca31b8 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -128,9 +128,9 @@ static bool use_vosf = false; // Flag: VOSF enabled static const bool use_vosf = false; // VOSF not possible #endif -static bool ctrl_down = false; // Flag: Ctrl key pressed (for use with hotkeys) -static bool alt_down = false; // Flag: Alt/Opt key pressed (for use with hotkeys) -static bool super_down = false; // Flag: Super/Cmd/Win key pressed (for use with hotkeys) +static bool ctrl_down = false; // Flag: Ctrl key pressed +static bool opt_down = false; // Flag: Opt key pressed +static bool cmd_down = false; // Flag: Cmd key pressed static bool quit_full_screen = false; // Flag: DGA close requested from redraw thread static bool emerg_quit = false; // Flag: Ctrl-Esc pressed, emergency quit requested from MacOS thread static bool emul_suspended = false; // Flag: Emulator suspended @@ -2053,8 +2053,8 @@ static bool is_hotkey_down(SDL_Keysym const & ks) int hotkey = PrefsFindInt32("hotkey"); if (!hotkey) hotkey = 1; return (ctrl_down || (ks.mod & KMOD_CTRL) || !(hotkey & 1)) && - (alt_down || (ks.mod & KMOD_ALT) || !(hotkey & 2)) && - (super_down || (ks.mod & KMOD_GUI) || !(hotkey & 4)); + (opt_down || (ks.mod & KMOD_ALT) || !(hotkey & 2)) && + (cmd_down || (ks.mod & KMOD_GUI) || !(hotkey & 4)); } static int modify_opt_cmd(int code) { @@ -2357,19 +2357,17 @@ static void handle_events(void) code = event2keycode(event.key, true); if (code >= 0) { if (!emul_suspended) { - if (code == 0x36) { - ctrl_down = true; - } else if (code == 0x3a) { - alt_down = true; - code = modify_opt_cmd(code); - } else if (code == 0x37) { - super_down = true; - code = modify_opt_cmd(code); - } - if (code == 0x39) { + code = modify_opt_cmd(code); + if (code == 0x39) (SDL_GetModState() & KMOD_CAPS ? ADBKeyDown : ADBKeyUp)(code); } else ADBKeyDown(code); + if (code == 0x36) + ctrl_down = true; + if (code == 0x3a) + opt_down = true; + if (code == 0x37) + cmd_down = true; } else { if (code == 0x31) @@ -2385,17 +2383,15 @@ static void handle_events(void) if (code == CODE_INVALID) code = event2keycode(event.key, false); if (code >= 0) { - if (code == 0x36) { - ctrl_down = false; - } else if (code == 0x3a) { - alt_down = false; - code = modify_opt_cmd(code); - } else if (code == 0x37) { - super_down = false; - code = modify_opt_cmd(code); - } + code = modify_opt_cmd(code); if (code != 0x39) ADBKeyUp(code); + if (code == 0x36) + ctrl_down = false; + if (code == 0x3a) + opt_down = false; + if (code == 0x37) + cmd_down = false; } break; } diff --git a/BasiliskII/src/Unix/video_x.cpp b/BasiliskII/src/Unix/video_x.cpp index 9f23b77b..0f27d8cd 100644 --- a/BasiliskII/src/Unix/video_x.cpp +++ b/BasiliskII/src/Unix/video_x.cpp @@ -114,9 +114,9 @@ static bool use_vosf = true; // Flag: VOSF enabled static const bool use_vosf = false; // VOSF not possible #endif -static bool ctrl_down = false; // Flag: Ctrl key pressed -static bool super_down = false; // Flag: Super key pressed -static bool alt_down = false; // Flag: Alt key pressed +static bool ctrl_down = false; // Flag: Ctrl key pressed (for use with hotkeys) +static bool opt_down = false; // Flag: Opt/Alt key pressed (for use with hotkeys) +static bool cmd_down = false; // Flag: Cmd/Super/Win key pressed (for use with hotkeys) static bool caps_on = false; // Flag: Caps Lock on static bool quit_full_screen = false; // Flag: DGA close requested from redraw thread static bool emerg_quit = false; // Flag: Ctrl-Esc pressed, emergency quit requested from MacOS thread @@ -234,8 +234,8 @@ static bool is_hotkey_down() int hotkey = PrefsFindInt32("hotkey"); if (!hotkey) hotkey = 1; return (ctrl_down || !(hotkey & 1)) && - (alt_down || !(hotkey & 2)) && - (super_down || !(hotkey & 4)); + (opt_down || !(hotkey & 2)) && + (cmd_down || !(hotkey & 4)); } static int modify_opt_cmd(int code) { @@ -1028,9 +1028,9 @@ void driver_dga::suspend(void) ADBKeyUp(0x36); ctrl_down = false; ADBKeyUp(0x37); - super_down = false; + cmd_down = false; ADBKeyUp(0x3a); - alt_down = false; + opt_down = false; // Lock frame buffer (this will stop the MacOS thread) LOCK_FRAME_BUFFER; @@ -2252,10 +2252,10 @@ static void handle_events(void) if (code == 0x36) { ctrl_down = true; } else if (code == 0x3a) { - alt_down = true; + opt_down = true; code = modify_opt_cmd(code); } else if (code == 0x37) { - super_down = true; + cmd_down = true; code = modify_opt_cmd(code); } } @@ -2289,10 +2289,10 @@ static void handle_events(void) if (code == 0x36) { ctrl_down = false; } else if (code == 0x3a) { - alt_down = false; + opt_down = false; code = modify_opt_cmd(code); } else if (code == 0x37) { - super_down = false; + cmd_down = false; code = modify_opt_cmd(code); } } diff --git a/SheepShaver/src/Unix/video_x.cpp b/SheepShaver/src/Unix/video_x.cpp index 09c344fb..c9afdfda 100644 --- a/SheepShaver/src/Unix/video_x.cpp +++ b/SheepShaver/src/Unix/video_x.cpp @@ -103,9 +103,9 @@ static const bool use_vosf = false; // VOSF not possible #endif static bool palette_changed = false; // Flag: Palette changed, redraw thread must update palette -static bool ctrl_down = false; // Flag: Ctrl key pressed -static bool super_down = false; // Flag: Super key pressed -static bool alt_down = false; // Flag: Alt key pressed +static bool ctrl_down = false; // Flag: Ctrl key pressed (for use with hotkeys) +static bool opt_down = false; // Flag: Opt/Alt key pressed (for use with hotkeys) +static bool cmd_down = false; // Flag: Cmd/Super/Win key pressed (for use with hotkeys) static bool caps_on = false; // Flag: Caps Lock on static bool quit_full_screen = false; // Flag: DGA close requested from redraw thread static volatile bool quit_full_screen_ack = false; // Acknowledge for quit_full_screen @@ -230,8 +230,8 @@ static bool is_hotkey_down() int hotkey = PrefsFindInt32("hotkey"); if (!hotkey) hotkey = 1; return (ctrl_down || !(hotkey & 1)) && - (alt_down || !(hotkey & 2)) && - (super_down || !(hotkey & 4)); + (opt_down || !(hotkey & 2)) && + (cmd_down || !(hotkey & 4)); } static int modify_opt_cmd(int code) { @@ -1758,9 +1758,9 @@ static void suspend_emul(void) ADBKeyUp(0x36); ctrl_down = false; ADBKeyUp(0x3a); - alt_down = false; + opt_down = false; ADBKeyUp(0x37); - super_down = false; + cmd_down = false; // Lock frame buffer (this will stop the MacOS thread) LOCK_FRAME_BUFFER; @@ -2102,10 +2102,10 @@ static void handle_events(void) if (code == 0x36) { ctrl_down = true; } else if (code == 0x3a) { - alt_down = true; + opt_down = true; code = modify_opt_cmd(code); } else if (code == 0x37) { - super_down = true; + cmd_down = true; code = modify_opt_cmd(code); } } @@ -2139,10 +2139,10 @@ static void handle_events(void) if (code == 0x36) { ctrl_down = false; } else if (code == 0x3a) { - alt_down = false; + opt_down = false; code = modify_opt_cmd(code); } else if (code == 0x37) { - super_down = false; + cmd_down = false; code = modify_opt_cmd(code); } }