From e0fdb8e88dd31a4b7097a263fb6775115827d0b0 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 10 Mar 2023 20:17:28 +0200 Subject: [PATCH] $0D<>$0C key swap hack --- include/keybuf.h | 2 +- keybuf.cpp | 13 +++++++++++++ od-win32/resources/resource.h | 3 ++- od-win32/resources/winuae.rc | 1 + od-win32/win32.cpp | 2 ++ od-win32/win32gui.cpp | 10 +++++++++- 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/keybuf.h b/include/keybuf.h index d411ec02..b9b70f12 100644 --- a/include/keybuf.h +++ b/include/keybuf.h @@ -20,5 +20,5 @@ 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 a9ba38eb..fd7d4972 100644 --- a/keybuf.cpp +++ b/keybuf.cpp @@ -23,6 +23,8 @@ #include "custom.h" #include "savestate.h" +int key_swap_hack = false; + static int kpb_first, kpb_last; #define KEYBUF_SIZE 256 @@ -278,6 +280,17 @@ int record_key_direct (int kc) int kpb_next = kpb_first + 1; int kcd = (kc << 7) | (kc >> 1); + if (key_swap_hack) { + // $0D <> $0C + if ((kcd & 0x7f) == 0x0c) { + kcd = 0x0d | (kcd & 0x80); + kc = (kcd << 1) | (kcd >> 7); + } else if ((kcd & 0x7f) == 0x0d) { + kcd = 0x0c | (kcd & 0x80); + kc = (kcd << 1) | (kcd >> 7); + } + } + if (ignore_next_release) { ignore_next_release = false; if (kcd & 0x80) { diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index 5e064109..6ac534c6 100644 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -1324,6 +1324,7 @@ #define IDC_ROM_ADDRESS2 1863 #define IDC_CUSTOMROMFILE 1864 #define IDC_SCSIROMFILEPCMCIA 1865 +#define IDC_KEYBOARD_SWAPHACK 1865 #define IDC_SCSIROM24BITDMA 1866 #define ID__FLOPPYDRIVES 40004 #define ID_FLOPPYDRIVES_DF0 40005 @@ -1376,7 +1377,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 407 #define _APS_NEXT_COMMAND_VALUE 40050 -#define _APS_NEXT_CONTROL_VALUE 1865 +#define _APS_NEXT_CONTROL_VALUE 1866 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index f3405b37..6fcc129c 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -923,6 +923,7 @@ BEGIN PUSHBUTTON "Copy from:",IDC_INPUTCOPY,324,268,70,14 COMBOBOX IDC_INPUTCOPYFROM,324,286,70,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Swap 1<>2",IDC_INPUTSWAP,324,303,70,14 + CONTROL "Swap Backslash/F11",IDC_KEYBOARD_SWAPHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,209,303,87,10 END IDD_FILTER DIALOGEX 0, 0, 396, 316 diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index e7aba9be..ab094cc8 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -5716,6 +5716,8 @@ static void WIN32_HandleRegistryStuff (void) if (!regqueryint (NULL, _T("QuickStartMode"), &quickstart)) quickstart = 1; + regqueryint(NULL, _T("KeySwapBackslashF11"), &key_swap_hack); + tmp[0] = 0; size = sizeof(tmp) / sizeof(TCHAR); if (regquerystr(NULL, _T("FloppyBridge"), tmp, &size)) { diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index fe931a17..555e9123 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -98,6 +98,7 @@ #include "ini.h" #include "specialmonitors.h" #include "gayle.h" +#include "keybuf.h" #ifdef FLOPPYBRIDGE #include "floppybridge/floppybridge_abstract.h" #include "floppybridge/floppybridge_lib.h" @@ -6686,6 +6687,7 @@ static void resetregistry (void) regdelete(NULL, _T("ShownsupportedModes")); regdelete(NULL, _T("ArtImageCount")); regdelete(NULL, _T("ArtImageWidth")); + regdelete(NULL, _T("KeySwapBackslashF11")); } #include "zip.h" @@ -11899,7 +11901,7 @@ static INT_PTR CALLBACK BoardsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM return FALSE; } -static const struct memoryboardtype* getmemoryboardselect(HWND hDlg) +static const struct memoryboardtype *getmemoryboardselect(HWND hDlg) { int v = xSendDlgItemMessage(hDlg, IDC_MEMORYBOARDSELECT, CB_GETCURSEL, 0, 0L); if (v == CB_ERR) @@ -18140,6 +18142,7 @@ static void values_to_inputdlg (HWND hDlg) SetDlgItemInt (hDlg, IDC_INPUTSPEEDD, workprefs.input_joymouse_speed, FALSE); SetDlgItemInt (hDlg, IDC_INPUTSPEEDA, workprefs.input_joymouse_multiplier, FALSE); CheckDlgButton (hDlg, IDC_INPUTDEVICEDISABLE, (!input_total_devices || inputdevice_get_device_status (input_selected_device)) ? BST_CHECKED : BST_UNCHECKED); + setchecked(hDlg, IDC_KEYBOARD_SWAPHACK, key_swap_hack); } static int askinputcustom (HWND hDlg, TCHAR *custom, int maxlen, DWORD titleid) @@ -18290,6 +18293,7 @@ static void init_inputdlg (HWND hDlg) if (input_selected_device >= input_total_devices || input_selected_device < 0) input_selected_device = 0; InitializeListView (hDlg); + init_inputdlg_2 (hDlg); values_to_inputdlg (hDlg); } @@ -19688,6 +19692,10 @@ static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM case IDC_INPUTDEVICEDISABLE: inputdevice_set_device_status (input_selected_device, ischecked (hDlg, IDC_INPUTDEVICEDISABLE)); break; + case IDC_KEYBOARD_SWAPHACK: + key_swap_hack = ischecked(hDlg, IDC_KEYBOARD_SWAPHACK); + regsetint(NULL, _T("KeySwapBackslashF11"), key_swap_hack); + break; default: switch (LOWORD (wParam)) { -- 2.47.3