Added third backslash/f11 option that matches pre-5.0 behavior.

This commit is contained in:
Toni Wilen 2023-12-04 19:11:45 +02:00
parent 106f6098da
commit 8f42fb8caf
5 changed files with 41 additions and 16 deletions

View 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) {

View 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) {

View 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

View 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;

View 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))