From b40c18ef3a81e69ba1bcf7ef615932056a6942b3 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 23 Apr 2023 19:51:33 +0300 Subject: [PATCH] keyhack swap --- include/inputdevice.h | 2 ++ include/keybuf.h | 1 - keybuf.cpp | 4 ++-- od-win32/dinput.cpp | 9 +++++++++ od-win32/win32.cpp | 8 ++++++++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/inputdevice.h b/include/inputdevice.h index 27717880..338bc9c0 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -372,4 +372,6 @@ extern int inputdevice_testread_count (void); extern bool target_can_autoswitchdevice(void); +extern int key_swap_hack, key_swap_hack2; + #endif /* UAE_INPUTDEVICE_H */ diff --git a/include/keybuf.h b/include/keybuf.h index b9b70f12..ae247af2 100644 --- a/include/keybuf.h +++ b/include/keybuf.h @@ -20,5 +20,4 @@ extern void setcapslockstate (int); extern void keybuf_inject(const uae_char*); extern void keybuf_ignore_next_release(void); extern void keybuf_vsync(void); -extern int key_swap_hack; #endif /* UAE_KEYBUF_H */ diff --git a/keybuf.cpp b/keybuf.cpp index fd7d4972..e1dc10fe 100644 --- a/keybuf.cpp +++ b/keybuf.cpp @@ -23,7 +23,7 @@ #include "custom.h" #include "savestate.h" -int key_swap_hack = false; +int key_swap_hack2 = false; static int kpb_first, kpb_last; @@ -280,7 +280,7 @@ int record_key_direct (int kc) int kpb_next = kpb_first + 1; int kcd = (kc << 7) | (kc >> 1); - if (key_swap_hack) { + if (key_swap_hack2) { // $0D <> $0C if ((kcd & 0x7f) == 0x0c) { kcd = 0x0d | (kcd & 0x80); diff --git a/od-win32/dinput.cpp b/od-win32/dinput.cpp index 2d39a490..d6cdad7b 100644 --- a/od-win32/dinput.cpp +++ b/od-win32/dinput.cpp @@ -18,6 +18,7 @@ int no_rawinput = 0; int no_directinput = 0; int no_windowsmouse = 0; int winekeyboard = 0; +int key_swap_hack = 0; #define _WIN32_WINNT 0x501 /* enable RAWINPUT support */ @@ -2468,6 +2469,14 @@ static void handle_rawinput_2 (RAWINPUT *raw, LPARAM lParam) if (rp_isactive ()) return; #endif + if (key_swap_hack) { + if (scancode == DIK_F11) { + scancode = DIK_EQUALS; + } else if (scancode == DIK_EQUALS) { + scancode = DIK_F11; + } + } + // eat E1 extended keys if (rk->Flags & (RI_KEY_E1)) return; diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index d573c92d..14015ad0 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -6728,6 +6728,14 @@ static int parseargs(const TCHAR *argx, const TCHAR *np, const TCHAR *np2) rp_modem = 1; return 1; } + if (!_tcscmp(arg, _T("key_swap_hack"))) { + key_swap_hack = 1; + return 1; + } + if (!_tcscmp(arg, _T("key_swap_hack2"))) { + key_swap_hack2 = 1; + return 1; + } if (!np) return 0; -- 2.47.3