]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
$0D<>$0C key swap hack
authorToni Wilen <twilen@winuae.net>
Fri, 10 Mar 2023 18:17:28 +0000 (20:17 +0200)
committerToni Wilen <twilen@winuae.net>
Fri, 10 Mar 2023 18:17:28 +0000 (20:17 +0200)
include/keybuf.h
keybuf.cpp
od-win32/resources/resource.h
od-win32/resources/winuae.rc
od-win32/win32.cpp
od-win32/win32gui.cpp

index d411ec0235ac5633eb314866cb2249970eec887a..b9b70f123f05f232a7db341b54ba4dd714d381a6 100644 (file)
@@ -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 */
index a9ba38eb575fa0400c7e03aa4cd6f09920830aa4..fd7d497258cc89b590a0d48556d1806ca3502e08 100644 (file)
@@ -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) {
index 5e0641099b89e0e66f62237f3dafc3506fa3dd68..6ac534c6e00b6ff8531374a52aad4692b4c6be80 100644 (file)
 #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
 #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
index f3405b375678092f6c561223cf80d3782b56ce62..6fcc129cdaf9ff806785c224886a0a1b5c693745 100644 (file)
@@ -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
index e7aba9be979db17d891c32b68ccb177fb0e73f55..ab094cc82fa6eeae318e107ceaaa5eba7ec03c79 100644 (file)
@@ -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)) {
index fe931a179a17f0be088820a36a55be75e1bef7d4..555e9123704a2a92aa6398cf7f44c74dd4b84b22 100644 (file)
@@ -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 memoryboardtypegetmemoryboardselect(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))
                        {