SDL2: Stop hotkey commands accepting both Alt and Super when swap_opt_cmd = true

This commit is contained in:
robxnano 2022-09-07 13:23:57 +01:00
parent bfad0d3bba
commit e28a9fc3a9

View File

@ -129,8 +129,8 @@ static const bool use_vosf = false; // VOSF not possible
#endif
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 alt_down = false; // Flag: Alt/Opt key pressed (for use outside emulator)
static bool super_down = false; // Flag: Super/Cmd key pressed (for use outside emulator)
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)) &&
(opt_down || (ks.mod & KMOD_ALT) || !(hotkey & 2)) &&
(cmd_down || (ks.mod & KMOD_GUI) || !(hotkey & 4));
(alt_down || (ks.mod & KMOD_ALT) || !(hotkey & 2)) &&
(super_down || (ks.mod & KMOD_GUI) || !(hotkey & 4));
}
static int modify_opt_cmd(int code) {
@ -2357,17 +2357,17 @@ static void handle_events(void)
code = event2keycode(event.key, true);
if (code >= 0) {
if (!emul_suspended) {
if (code == 0x36)
ctrl_down = true;
if (code == 0x3a)
alt_down = true;
if (code == 0x37)
super_down = true;
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)
@ -2383,15 +2383,15 @@ static void handle_events(void)
if (code == CODE_INVALID)
code = event2keycode(event.key, false);
if (code >= 0) {
code = modify_opt_cmd(code);
if (code != 0x39)
ADBKeyUp(code);
if (code == 0x36)
ctrl_down = false;
if (code == 0x3a)
opt_down = false;
alt_down = false;
if (code == 0x37)
cmd_down = false;
super_down = false;
code = modify_opt_cmd(code);
if (code != 0x39)
ADBKeyUp(code);
}
break;
}