]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Added third backslash/f11 option that matches pre-5.0 behavior.
authorToni Wilen <twilen@winuae.net>
Mon, 4 Dec 2023 17:11:45 +0000 (19:11 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 4 Dec 2023 17:11:45 +0000 (19:11 +0200)
keybuf.cpp
od-win32/dinput.cpp
od-win32/resources/winuae.rc
od-win32/win32.cpp
od-win32/win32gui.cpp

index e1dc10feae8ea81f37e1b2924f3f0c1735ebd6fc..8ae631847f6aa469b8a8babb15025d1c8ba2fe9e 100644 (file)
@@ -275,6 +275,21 @@ int record_key (int kc)
        return record_key_direct (kc);
 }
 
+static void keyswap(int *kcdp, int *kcp, uae_u8 k1, uae_u8 k2)
+{
+       int kcd = *kcdp;
+       int kc = *kcp;
+       if ((kcd & 0x7f) == k1) {
+               kcd = k2 | (kcd & 0x80);
+               kc = (kcd << 1) | (kcd >> 7);
+       } else if ((kcd & 0x7f) == k2) {
+               kcd = k1 | (kcd & 0x80);
+               kc = (kcd << 1) | (kcd >> 7);
+       }
+       *kcdp = kcd;
+       *kcp = kc;
+}
+
 int record_key_direct (int kc)
 {
        int kpb_next = kpb_first + 1;
@@ -282,13 +297,11 @@ int record_key_direct (int kc)
 
        if (key_swap_hack2) {
                // $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);
-               }
+               keyswap(&kcd, &kc, 0x0d, 0x0c);
+       }
+       if (key_swap_hack == 2) {
+               // $2B <> $0D
+               keyswap(&kcd, &kc, 0x2b, 0x0d);
        }
 
        if (ignore_next_release) {
index ceff6deb3e5a959e930b593437940bb8fcd007a7..1aff3ae1d4798752d51e906ef6bb38c0f52e2d32 100644 (file)
@@ -2463,7 +2463,7 @@ static void handle_rawinput_2 (RAWINPUT *raw, LPARAM lParam)
                if (rp_isactive ())
                        return;
 #endif
-               if (key_swap_hack) {
+               if (key_swap_hack == 1) {
                        if (scancode == DIK_F11) {
                                scancode = DIK_EQUALS;
                        } else if (scancode == DIK_EQUALS) {
index 58b3e17af084bd9bef3e02785f4dbf0a14d7abe6..c2189c3987dc4004d323e949435dfc63a200fe10 100644 (file)
@@ -929,7 +929,7 @@ BEGIN
     PUSHBUTTON      "Copy from:",IDC_INPUTCOPY,324,267,70,14
     COMBOBOX        IDC_INPUTCOPYFROM,324,285,70,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
     PUSHBUTTON      "Swap 1<>2",IDC_INPUTSWAP,324,302,70,14
-    CONTROL         "Swap Backslash/F11",IDC_KEYBOARD_SWAPHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,209,302,87,10
+    CONTROL         "Swap Backslash/F11",IDC_KEYBOARD_SWAPHACK,"Button", BS_AUTO3STATE | WS_TABSTOP,209,302,87,10
 END
 
 IDD_FILTER DIALOGEX 0, 0, 396, 316
index a12403d71b8d37d02e0f54160d13fd518b127224..1f4af36591c305c5b18e866eb659e6e51cdd1451 100644 (file)
@@ -6937,10 +6937,6 @@ 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;
@@ -7134,6 +7130,10 @@ static int parseargs(const TCHAR *argx, const TCHAR *np, const TCHAR *np2)
                }
                return 2;
        }
+       if (!_tcscmp(arg, _T("key_swap_hack"))) {
+               key_swap_hack = getval(np);
+               return 2;
+       }
 
 #endif
        return 0;
index bf3fa74f2e06413a0b72dee8b0e3326c5e337e4e..541d76812aaecc6e28eb35f07ad013d0ac720470 100644 (file)
@@ -18559,7 +18559,11 @@ 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);
+       if (key_swap_hack == 2) {
+               CheckDlgButton(hDlg, IDC_KEYBOARD_SWAPHACK, BST_INDETERMINATE);
+       } else {
+               setchecked(hDlg, IDC_KEYBOARD_SWAPHACK, key_swap_hack);
+       }
 }
 
 static int askinputcustom (HWND hDlg, TCHAR *custom, int maxlen, DWORD titleid)
@@ -20136,8 +20140,16 @@ static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                        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);
+                       {
+                               int v = IsDlgButtonChecked(hDlg, IDC_KEYBOARD_SWAPHACK);
+                               key_swap_hack = v == BST_INDETERMINATE ? 2 : v > 0;
+                               key_swap_hack++;
+                               if (key_swap_hack > 2) {
+                                       key_swap_hack = 0;
+                               }
+                               regsetint(NULL, _T("KeySwapBackslashF11"), key_swap_hack);
+                               values_to_inputdlg(hDlg);
+                       }
                        break;
                default:
                        switch (LOWORD (wParam))