From 212e808b9d2e8e7249a997a0ea20029b26de146b Mon Sep 17 00:00:00 2001 From: user7182 <96945402+user7182@users.noreply.github.com> Date: Tue, 5 Apr 2022 08:19:17 -0400 Subject: [PATCH] user_io: Keyboard emulation mode key combo added. (#578) A key combo, Meta (Win) + Scroll Lock was added to allow cores using PS/2 to access the Scroll Lock. Num Lock (EMU_SWITCH_2) was previously excluded, this has been re-enabled when using the Meta key modifier. Meta+Scroll Lock previously took a screenshot. This is no longer possible, when that key combo is used for keyboard emuation mode. A screenshot must be taken with either: Meta+Print Screen or Alt+Scroll Lock. --- user_io.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/user_io.cpp b/user_io.cpp index 81499bb..af940a7 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -3547,7 +3547,10 @@ void user_io_kbd(uint16_t key, int press) if(is_menu()) spi_uio_cmd(UIO_KEYBOARD); //ping the Menu core to wakeup // Win+PrnScr or Alt/Win+ScrLk - screen shot - if ((key == KEY_SYSRQ && (get_key_mod() & (RGUI | LGUI))) || (key == KEY_SCROLLLOCK && (get_key_mod() & (LALT | RALT | RGUI | LGUI)))) + bool key_WinPrnScr = (key == KEY_SYSRQ && (get_key_mod() & (RGUI | LGUI))); + // Excluding scroll lock for PS/2 so Win+ScrLk can be used to change the emu mode. + bool key_AltWinScrLk = (key == KEY_SCROLLLOCK && (get_key_mod() & (LALT | RALT | RGUI | LGUI))) && !use_ps2ctl; + if (key_WinPrnScr || key_AltWinScrLk) { int shift = (get_key_mod() & LSHIFT); if (press == 1) @@ -3616,7 +3619,14 @@ void user_io_kbd(uint16_t key, int press) } else { - if (((code & EMU_SWITCH_1) || ((code & EMU_SWITCH_2) && !use_ps2ctl && !is_archie())) && !is_menu()) + // When ps2ctl is set then the RGUI or LGUI key must be held in addition + // to the EMU_SWITCH_1 or EMU_SWITCH_2. This allows for cores such as AO486 + // to pass through the Scroll Lock and Num Lock keys. + bool ps2ctl_modifier = (get_key_mod() & (RGUI | LGUI)) || !use_ps2ctl; + bool key_EMU_SWITCH_1 = (code & EMU_SWITCH_1) && ps2ctl_modifier; + bool key_EMU_SWITCH_2 = (code & EMU_SWITCH_2) && ps2ctl_modifier && !is_archie(); + + if (( key_EMU_SWITCH_1 || key_EMU_SWITCH_2 ) && !is_menu()) { if (press == 1) {