Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/joy.cpl/joy.h | 3 +++ dlls/joy.cpl/joy.rc | 2 ++ dlls/joy.cpl/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+)
diff --git a/dlls/joy.cpl/joy.h b/dlls/joy.cpl/joy.h index ffba9cd1220..64df21963b9 100644 --- a/dlls/joy.cpl/joy.h +++ b/dlls/joy.cpl/joy.h @@ -42,6 +42,7 @@ struct Joystick { int num_axes; BOOL forcefeedback; BOOL is_xinput; + BOOL has_override; int num_effects; int cur_effect; int chosen_effect; @@ -87,6 +88,8 @@ struct JoystickData { #define IDC_XINPUTLIST 2002 #define IDC_BUTTONDISABLE 2010 #define IDC_BUTTONENABLE 2011 +#define IDC_BUTTONRESET 2012 +#define IDC_BUTTONOVERRIDE 2013
#define IDC_TESTSELECTCOMBO 2100 #define IDC_TESTGROUPXY 2101 diff --git a/dlls/joy.cpl/joy.rc b/dlls/joy.cpl/joy.rc index d425ea76440..77f121c5b1c 100644 --- a/dlls/joy.cpl/joy.rc +++ b/dlls/joy.cpl/joy.rc @@ -37,7 +37,9 @@ CAPTION "Joysticks" FONT 8, "Ms Shell Dlg" { PUSHBUTTON "&Disable", IDC_BUTTONDISABLE, 200, 20, 60, 15 + PUSHBUTTON "&Reset", IDC_BUTTONRESET, 200, 40, 60, 15 PUSHBUTTON "&Enable", IDC_BUTTONENABLE, 200, 190, 60, 15 + PUSHBUTTON "&Override", IDC_BUTTONOVERRIDE, 200, 100, 60, 15 LTEXT "Connected", IDC_STATIC, 10, 10, 100, 10 LISTBOX IDC_JOYSTICKLIST, 10, 20, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY LTEXT "Connected (xinput device)", IDC_STATIC, 10, 90, 100, 10 diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c index 91280f2c2c5..57c188a5df1 100644 --- a/dlls/joy.cpl/main.c +++ b/dlls/joy.cpl/main.c @@ -272,6 +272,21 @@ static void refresh_joystick_list(HWND hwnd, struct JoystickData *data) if (appkey) RegCloseKey(appkey); }
+static void override_joystick(WCHAR *joy_name, BOOL override) +{ + HKEY hkey, appkey; + + get_app_key(&hkey, &appkey); + + if (override) + set_config_key(hkey, appkey, joy_name, L"override", wcslen(L"override")); + else + set_config_key(hkey, appkey, joy_name, NULL, 0); + + if (hkey) RegCloseKey(hkey); + if (appkey) RegCloseKey(appkey); +} + /********************************************************************* * list_dlgproc [internal] * @@ -293,6 +308,8 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
EnableWindow(GetDlgItem(hwnd, IDC_BUTTONENABLE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_BUTTONDISABLE), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_BUTTONRESET), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_BUTTONOVERRIDE), FALSE);
/* Store the hwnd to be used with MapDialogRect for unit conversions */ data->graphics.hwnd = hwnd; @@ -332,11 +349,35 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM } break;
+ case IDC_BUTTONRESET: + { + if ((sel = SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_GETCURSEL, 0, 0)) >= 0) + { + SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_GETTEXT, sel, (LPARAM)instance_name); + override_joystick(instance_name, FALSE); + refresh_joystick_list(hwnd, data); + } + } + break; + + case IDC_BUTTONOVERRIDE: + { + if ((sel = SendDlgItemMessageW(hwnd, IDC_XINPUTLIST, LB_GETCURSEL, 0, 0)) >= 0) + { + SendDlgItemMessageW(hwnd, IDC_XINPUTLIST, LB_GETTEXT, sel, (LPARAM)instance_name); + override_joystick(instance_name, TRUE); + refresh_joystick_list(hwnd, data); + } + } + break; + case IDC_JOYSTICKLIST: SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_SETCURSEL, -1, 0); SendDlgItemMessageW(hwnd, IDC_XINPUTLIST, LB_SETCURSEL, -1, 0); EnableWindow(GetDlgItem(hwnd, IDC_BUTTONENABLE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_BUTTONDISABLE), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_BUTTONOVERRIDE), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_BUTTONRESET), TRUE); break;
case IDC_XINPUTLIST: @@ -344,6 +385,8 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_SETCURSEL, -1, 0); EnableWindow(GetDlgItem(hwnd, IDC_BUTTONENABLE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_BUTTONDISABLE), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_BUTTONOVERRIDE), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_BUTTONRESET), FALSE); break;
case IDC_DISABLEDLIST: @@ -351,6 +394,8 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM SendDlgItemMessageW(hwnd, IDC_XINPUTLIST, LB_SETCURSEL, -1, 0); EnableWindow(GetDlgItem(hwnd, IDC_BUTTONENABLE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_BUTTONDISABLE), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_BUTTONOVERRIDE), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_BUTTONRESET), FALSE); break; }