diff --git a/src/drivers/win/input.cpp b/src/drivers/win/input.cpp index 56d110f6..b629324b 100644 --- a/src/drivers/win/input.cpp +++ b/src/drivers/win/input.cpp @@ -23,6 +23,7 @@ #include "../../version.h" +#include "main.h" #include "common.h" #include "dinput.h" #include @@ -1205,14 +1206,15 @@ static INT_PTR CALLBACK DWBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM nstr = MakeButtString(bc); SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); free(nstr); - } + } { int newkey; int meta = GetKeyMeta(key); KeyboardUpdateState(); - if ((newkey = GetKeyPressed()) != 0) + newkey = GetKeyPressed(); + if ((newkey != 0) && (newkey != 0x80)) { key = newkey | meta; ClearExtraMeta(&key); @@ -1235,6 +1237,8 @@ static INT_PTR CALLBACK DWBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM nstr = MakeButtString(bc); bc->NumC--; SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); + /* workaround for enter and tab keys */ + SetFocus(GetDlgItem(hwndDlg, LBL_DWBDIALOG_TEXT)); free(nstr); } else if (NothingPressed() && key) @@ -1256,6 +1260,8 @@ static INT_PTR CALLBACK DWBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM nstr = MakeButtString(bc); SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); + /* workaround for enter and tab keys */ + SetFocus(GetDlgItem(hwndDlg, LBL_DWBDIALOG_TEXT)); free(nstr); key = 0; @@ -1273,6 +1279,7 @@ static INT_PTR CALLBACK DWBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM SetWindowText(hwndDlg, (char*)DWBText); //mbg merge 7/17/06 added cast BeginJoyWait(hwndDlg); KeyboardSetBackgroundAccess(true); + JoystickSetBackgroundAccess(true); SetTimer(hwndDlg,666,25,0); //Every 25ms. if (DWBButtons->NumC) { @@ -1280,8 +1287,8 @@ static INT_PTR CALLBACK DWBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); free(nstr); } - /* workaround for enter and tab keys */ - SetFocus(NULL); + /* actually using button instead of label because it's focusable */ + SetFocus(GetDlgItem(hwndDlg, LBL_DWBDIALOG_TEXT)); break; case WM_CLOSE: @@ -1293,21 +1300,19 @@ static INT_PTR CALLBACK DWBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM case BTN_CLEAR: { ButtConfig *bc = DWBButtons; - char *nstr; bc->NumC = 0; - nstr = MakeButtString(bc); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); + SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, "Press a key or a button"); } break; case BTN_CANCEL: memcpy(DWBButtons, &DWBButtonsBackup, sizeof(ButtConfig)); - goto gornk; - case BTN_CLOSE: + goto gornk; + case BTN_SAVE: /* using BTN_SAVE instead BTN_CLOSE to prevent close on enter key*/ gornk: KillTimer(hwndDlg,666); EndJoyWait(hAppWnd); - KeyboardSetBackgroundAccess(false); + KeyboardSetBackgroundAccess(EnableBackgroundInput != 0); + JoystickSetBackgroundAccess(EnableBackgroundInput != 0); EndDialog(hwndDlg, 0); break; } diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 810f7343..2b467b92 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -107,15 +107,15 @@ BEGIN PUSHBUTTON "Cancel",BTN_CANCEL,239,230,56,14 END -DWBDIALOG DIALOGEX 33, 99, 250, 56 +DWBDIALOG DIALOGEX 33, 99, 250, 53 STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "DWB!" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - LTEXT "Press a key or a button",LBL_DWBDIALOG_TEXT,7,9,237,8 - PUSHBUTTON "Clear",BTN_CLEAR,64,32,50,14 - PUSHBUTTON "Cancel",BTN_CANCEL,126,32,50,14 - PUSHBUTTON "OK",BTN_CLOSE,188,32,50,14 + PUSHBUTTON "Press a key or a button",LBL_DWBDIALOG_TEXT,7,5,235,20 + PUSHBUTTON "Clear",BTN_CLEAR,68,32,50,14 + PUSHBUTTON "Cancel",BTN_CANCEL,130,32,50,14 + PUSHBUTTON "OK",BTN_SAVE,192,32,50,14 END FKBDIALOG DIALOGEX 13, 72, 402, 194 diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index ea863c96..88156baa 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -914,6 +914,7 @@ #define IDC_BINARY 1317 #define IDC_GAME_GENIE_ADDR 1501 #define IDC_EDIT_SYMBOLIC_INIT 1502 +#define BTN_SAVE 1503 #define MENU_INESHEADEREDITOR 40001 #define MENU_INPUT_BARCODE 40004 #define ID_BOOKMARKS_IMPORT 40005