Making it easier for users to disable hidraw and get the old behavior back for Sony controllers (emulating XBox controllers instead).
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/joy.cpl/dinput.c | 23 +++++++++++++++++++++++ dlls/joy.cpl/joy.rc | 1 - dlls/joy.cpl/main.c | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/dlls/joy.cpl/dinput.c b/dlls/joy.cpl/dinput.c index f624e650147..8eefbbbe3f3 100644 --- a/dlls/joy.cpl/dinput.c +++ b/dlls/joy.cpl/dinput.c @@ -27,6 +27,8 @@ #include "wingdi.h"
#include "dinput.h" +#include "dbt.h" +#include "ddk/hidclass.h"
#include "wine/debug.h" #include "wine/list.h" @@ -64,6 +66,7 @@ static IDirectInputDevice8W *device_selected;
static HWND dialog_hwnd; static HANDLE state_event; +static HDEVNOTIFY devnotify;
static BOOL CALLBACK enum_effects( const DIEFFECTINFOW *info, void *context ) { @@ -748,6 +751,12 @@ static void update_device_views( HWND hwnd ) INT_PTR CALLBACK test_di_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { static HANDLE thread, thread_stop; + DEV_BROADCAST_DEVICEINTERFACE_W filter = + { + .dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE_W), + .dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE, + .dbcc_classguid = GUID_DEVINTERFACE_HID, + };
TRACE( "hwnd %p, msg %#x, wparam %#Ix, lparam %#Ix\n", hwnd, msg, wparam, lparam );
@@ -783,6 +792,7 @@ INT_PTR CALLBACK test_di_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM state_event = CreateEventW( NULL, FALSE, FALSE, NULL ); thread_stop = CreateEventW( NULL, FALSE, FALSE, NULL );
+ devnotify = RegisterDeviceNotificationW( hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE ); update_di_devices( hwnd );
SendDlgItemMessageW( hwnd, IDC_DI_DEVICES, CB_SETCURSEL, 0, 0 ); @@ -796,6 +806,7 @@ INT_PTR CALLBACK test_di_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM
case PSN_RESET: case PSN_KILLACTIVE: + UnregisterDeviceNotification( devnotify ); SetEvent( thread_stop ); /* wait for the input thread to stop, processing any WM_USER message from it */ while (MsgWaitForMultipleObjects( 1, &thread, FALSE, INFINITE, QS_ALLINPUT ) == 1) @@ -817,6 +828,18 @@ INT_PTR CALLBACK test_di_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM } return TRUE;
+ case WM_DEVICECHANGE: + update_di_devices( hwnd ); + + if (SendDlgItemMessageW( hwnd, IDC_DI_DEVICES, CB_GETCURSEL, 0, 0 ) >= 0) return TRUE; + + SendDlgItemMessageW( hwnd, IDC_DI_DEVICES, CB_SETCURSEL, 0, 0 ); + handle_di_devices_change( hwnd ); + + SendDlgItemMessageW( hwnd, IDC_DI_EFFECTS, LB_SETCURSEL, 0, 0 ); + handle_di_effects_change( hwnd ); + return TRUE; + case WM_USER: update_device_views( hwnd ); return TRUE; diff --git a/dlls/joy.cpl/joy.rc b/dlls/joy.cpl/joy.rc index 76d8bb401e4..a6ef90738ee 100644 --- a/dlls/joy.cpl/joy.rc +++ b/dlls/joy.cpl/joy.rc @@ -46,7 +46,6 @@ FONT 8, "Ms Shell Dlg" LISTBOX IDC_XINPUTLIST, 10, 100, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY LTEXT "Disabled", IDC_STATIC, 10, 180, 180, 10 LISTBOX IDC_DISABLEDLIST, 10, 190, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY - LTEXT "After disabling or enabling a device, the connected joysticks won't be updated here until you restart this applet.", IDC_STATIC, 10, 270, 200, 25 }
IDD_TEST_DI DIALOG 0, 0, 320, 300 diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c index 7d724be7280..3aea6e5c69c 100644 --- a/dlls/joy.cpl/main.c +++ b/dlls/joy.cpl/main.c @@ -30,6 +30,10 @@ #include <dinput.h> #include <cpl.h> #include "ole2.h" +#include "dbt.h" + +#include "initguid.h" +#include "ddk/hidclass.h"
#include "wine/debug.h" #include "wine/list.h" @@ -56,6 +60,7 @@ static CRITICAL_SECTION_DEBUG joy_cs_debug = static CRITICAL_SECTION joy_cs = { &joy_cs_debug, -1, 0, 0, 0, 0 };
static struct list devices = LIST_INIT( devices ); +static HDEVNOTIFY devnotify;
/********************************************************************* * DllMain @@ -247,6 +252,12 @@ static void override_joystick(WCHAR *joy_name, BOOL override) static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WCHAR instance_name[MAX_PATH] = {0}; + DEV_BROADCAST_DEVICEINTERFACE_W filter = + { + .dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE_W), + .dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE, + .dbcc_classguid = GUID_DEVINTERFACE_HID, + }; int sel;
TRACE("(%p, 0x%08x/%d, 0x%Ix)\n", hwnd, msg, msg, lparam); @@ -261,9 +272,14 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM EnableWindow(GetDlgItem(hwnd, IDC_BUTTONRESET), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_BUTTONOVERRIDE), FALSE);
+ devnotify = RegisterDeviceNotificationW( hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE ); return TRUE; }
+ case WM_DEVICECHANGE: + refresh_joystick_list( hwnd ); + return TRUE; + case WM_COMMAND:
switch (LOWORD(wparam))
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/joy.cpl/joy.rc | 18 ++-- dlls/joy.cpl/main.c | 191 +++++++++++++++++++--------------------- dlls/joy.cpl/resource.h | 15 ++-- 3 files changed, 108 insertions(+), 116 deletions(-)
diff --git a/dlls/joy.cpl/joy.rc b/dlls/joy.cpl/joy.rc index a6ef90738ee..2abae6d4272 100644 --- a/dlls/joy.cpl/joy.rc +++ b/dlls/joy.cpl/joy.rc @@ -36,16 +36,16 @@ STYLE WS_CAPTION | WS_CHILD | WS_DISABLED 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, 180, 10 - LISTBOX IDC_JOYSTICKLIST, 10, 20, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY - LTEXT "Connected (xinput device)", IDC_STATIC, 10, 90, 180, 10 - LISTBOX IDC_XINPUTLIST, 10, 100, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY + PUSHBUTTON "&Disable", IDC_BUTTON_DI_DISABLE, 200, 20, 60, 15 + PUSHBUTTON "&Reset", IDC_BUTTON_DI_RESET, 200, 40, 60, 15 + PUSHBUTTON "&Enable", IDC_BUTTON_ENABLE, 200, 190, 60, 15 + PUSHBUTTON "&Override", IDC_BUTTON_XI_OVERRIDE, 200, 100, 60, 15 + LTEXT "Connected (DirectInput devices)", IDC_STATIC, 10, 10, 180, 10 + LISTBOX IDC_DI_ENABLED_LIST, 10, 20, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY + LTEXT "Connected (XInput devices)", IDC_STATIC, 10, 90, 180, 10 + LISTBOX IDC_XI_ENABLED_LIST, 10, 100, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY LTEXT "Disabled", IDC_STATIC, 10, 180, 180, 10 - LISTBOX IDC_DISABLEDLIST, 10, 190, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY + LISTBOX IDC_DISABLED_LIST, 10, 190, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY }
IDD_TEST_DI DIALOG 0, 0, 320, 300 diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c index 3aea6e5c69c..ebd33208721 100644 --- a/dlls/joy.cpl/main.c +++ b/dlls/joy.cpl/main.c @@ -187,9 +187,9 @@ static void refresh_joystick_list( HWND hwnd ) IDirectInput8_EnumDevices( dinput, DI8DEVCLASS_GAMECTRL, enum_devices, dinput, DIEDFL_ATTACHEDONLY ); IDirectInput8_Release( dinput );
- SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_RESETCONTENT, 0, 0); - SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_RESETCONTENT, 0, 0); - SendDlgItemMessageW(hwnd, IDC_XINPUTLIST, LB_RESETCONTENT, 0, 0); + SendDlgItemMessageW(hwnd, IDC_DI_ENABLED_LIST, LB_RESETCONTENT, 0, 0); + SendDlgItemMessageW(hwnd, IDC_XI_ENABLED_LIST, LB_RESETCONTENT, 0, 0); + SendDlgItemMessageW(hwnd, IDC_DISABLED_LIST, LB_RESETCONTENT, 0, 0);
LIST_FOR_EACH_ENTRY( entry, &devices, struct device, entry ) { @@ -207,8 +207,8 @@ static void refresh_joystick_list( HWND hwnd ) if (FAILED(IDirectInputDevice8_GetDeviceInfo( entry->device, &info ))) continue; if (FAILED(IDirectInputDevice8_GetProperty( entry->device, DIPROP_GUIDANDPATH, &prop.diph ))) continue;
- if (wcsstr( prop.wszPath, L"&ig_" )) SendDlgItemMessageW( hwnd, IDC_XINPUTLIST, LB_ADDSTRING, 0, (LPARAM)info.tszInstanceName ); - else SendDlgItemMessageW( hwnd, IDC_JOYSTICKLIST, LB_ADDSTRING, 0, (LPARAM)info.tszInstanceName ); + if (wcsstr( prop.wszPath, L"&ig_" )) SendDlgItemMessageW( hwnd, IDC_XI_ENABLED_LIST, LB_ADDSTRING, 0, (LPARAM)info.tszInstanceName ); + else SendDlgItemMessageW( hwnd, IDC_DI_ENABLED_LIST, LB_ADDSTRING, 0, (LPARAM)info.tszInstanceName ); }
/* Search for disabled joysticks */ @@ -223,7 +223,7 @@ static void refresh_joystick_list( HWND hwnd ) status = RegEnumValueW(hkey, i, buf_name, &name_len, NULL, NULL, (BYTE*) buf_data, &data_len);
if (status == ERROR_SUCCESS && !wcscmp(L"disabled", buf_data)) - SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_ADDSTRING, 0, (LPARAM) buf_name); + SendDlgItemMessageW(hwnd, IDC_DISABLED_LIST, LB_ADDSTRING, 0, (LPARAM) buf_name); }
if (hkey) RegCloseKey(hkey); @@ -263,112 +263,103 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM TRACE("(%p, 0x%08x/%d, 0x%Ix)\n", hwnd, msg, msg, lparam); switch (msg) { - case WM_INITDIALOG: + case WM_INITDIALOG: + { + refresh_joystick_list( hwnd ); + + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_ENABLE ), FALSE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_DISABLE ), FALSE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_RESET ), FALSE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_XI_OVERRIDE ), FALSE ); + + devnotify = RegisterDeviceNotificationW( hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE ); + return TRUE; + } + + case WM_DEVICECHANGE: + refresh_joystick_list( hwnd ); + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wparam)) { - refresh_joystick_list( hwnd ); + case IDC_BUTTON_DI_DISABLE: + if ((sel = SendDlgItemMessageW( hwnd, IDC_DI_ENABLED_LIST, LB_GETCURSEL, 0, 0 )) >= 0) + SendDlgItemMessageW( hwnd, IDC_DI_ENABLED_LIST, LB_GETTEXT, sel, (LPARAM)instance_name ); + if ((sel = SendDlgItemMessageW( hwnd, IDC_XI_ENABLED_LIST, LB_GETCURSEL, 0, 0 )) >= 0) + SendDlgItemMessageW( hwnd, IDC_XI_ENABLED_LIST, LB_GETTEXT, sel, (LPARAM)instance_name );
- EnableWindow(GetDlgItem(hwnd, IDC_BUTTONENABLE), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_BUTTONDISABLE), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_BUTTONRESET), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_BUTTONOVERRIDE), FALSE); + if (instance_name[0]) + { + enable_joystick( instance_name, FALSE ); + refresh_joystick_list( hwnd ); + } + break;
- devnotify = RegisterDeviceNotificationW( hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE ); - return TRUE; - } + case IDC_BUTTON_ENABLE: + if ((sel = SendDlgItemMessageW( hwnd, IDC_DISABLED_LIST, LB_GETCURSEL, 0, 0 )) >= 0) + SendDlgItemMessageW( hwnd, IDC_DISABLED_LIST, LB_GETTEXT, sel, (LPARAM)instance_name );
- case WM_DEVICECHANGE: - refresh_joystick_list( hwnd ); - return TRUE; + if (instance_name[0]) + { + enable_joystick( instance_name, TRUE ); + refresh_joystick_list( hwnd ); + } + break;
- case WM_COMMAND: + case IDC_BUTTON_DI_RESET: + if ((sel = SendDlgItemMessageW( hwnd, IDC_DI_ENABLED_LIST, LB_GETCURSEL, 0, 0 )) >= 0) + { + SendDlgItemMessageW( hwnd, IDC_DI_ENABLED_LIST, LB_GETTEXT, sel, (LPARAM)instance_name ); + override_joystick( instance_name, FALSE ); + refresh_joystick_list( hwnd ); + } + break;
- switch (LOWORD(wparam)) + case IDC_BUTTON_XI_OVERRIDE: + if ((sel = SendDlgItemMessageW( hwnd, IDC_XI_ENABLED_LIST, LB_GETCURSEL, 0, 0 )) >= 0) { - case IDC_BUTTONDISABLE: - { - if ((sel = SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_GETCURSEL, 0, 0)) >= 0) - SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_GETTEXT, sel, (LPARAM)instance_name); - if ((sel = SendDlgItemMessageW(hwnd, IDC_XINPUTLIST, LB_GETCURSEL, 0, 0)) >= 0) - SendDlgItemMessageW(hwnd, IDC_XINPUTLIST, LB_GETTEXT, sel, (LPARAM)instance_name); - - if (instance_name[0]) - { - enable_joystick(instance_name, FALSE); - refresh_joystick_list( hwnd ); - } - } - break; - - case IDC_BUTTONENABLE: - { - if ((sel = SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_GETCURSEL, 0, 0)) >= 0) - SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_GETTEXT, sel, (LPARAM)instance_name); - - if (instance_name[0]) - { - enable_joystick(instance_name, TRUE); - refresh_joystick_list( hwnd ); - } - } - 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 ); - } - } - 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 ); - } - } - 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: - SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_SETCURSEL, -1, 0); - 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: - SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_SETCURSEL, -1, 0); - 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; + SendDlgItemMessageW( hwnd, IDC_XI_ENABLED_LIST, LB_GETTEXT, sel, (LPARAM)instance_name ); + override_joystick( instance_name, TRUE ); + refresh_joystick_list( hwnd ); } + break;
- return TRUE; + case IDC_DI_ENABLED_LIST: + SendDlgItemMessageW( hwnd, IDC_XI_ENABLED_LIST, LB_SETCURSEL, -1, 0 ); + SendDlgItemMessageW( hwnd, IDC_DISABLED_LIST, LB_SETCURSEL, -1, 0 ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_ENABLE ), FALSE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_DISABLE ), TRUE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_RESET ), TRUE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_XI_OVERRIDE ), FALSE ); + break;
- case WM_NOTIFY: - return TRUE; + case IDC_XI_ENABLED_LIST: + SendDlgItemMessageW( hwnd, IDC_DI_ENABLED_LIST, LB_SETCURSEL, -1, 0 ); + SendDlgItemMessageW( hwnd, IDC_DISABLED_LIST, LB_SETCURSEL, -1, 0 ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_ENABLE ), FALSE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_DISABLE ), TRUE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_RESET ), FALSE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_XI_OVERRIDE ), TRUE ); + break;
- default: + case IDC_DISABLED_LIST: + SendDlgItemMessageW( hwnd, IDC_DI_ENABLED_LIST, LB_SETCURSEL, -1, 0 ); + SendDlgItemMessageW( hwnd, IDC_XI_ENABLED_LIST, LB_SETCURSEL, -1, 0 ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_ENABLE ), TRUE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_DISABLE ), FALSE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_RESET ), FALSE ); + EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_XI_OVERRIDE ), FALSE ); break; + } + + return TRUE; + + case WM_NOTIFY: + return TRUE; + + default: + break; } return FALSE; } diff --git a/dlls/joy.cpl/resource.h b/dlls/joy.cpl/resource.h index a711617a607..44a756cea5f 100644 --- a/dlls/joy.cpl/resource.h +++ b/dlls/joy.cpl/resource.h @@ -38,13 +38,14 @@ #define IDD_TEST_DI 1001 #define IDD_TEST_XI 1002
-#define IDC_JOYSTICKLIST 2000 -#define IDC_DISABLEDLIST 2001 -#define IDC_XINPUTLIST 2002 -#define IDC_BUTTONDISABLE 2010 -#define IDC_BUTTONENABLE 2011 -#define IDC_BUTTONRESET 2012 -#define IDC_BUTTONOVERRIDE 2013 +#define IDC_DI_ENABLED_LIST 2000 +#define IDC_XI_ENABLED_LIST 2001 +#define IDC_DISABLED_LIST 2002 + +#define IDC_BUTTON_DI_DISABLE 2010 +#define IDC_BUTTON_DI_RESET 2011 +#define IDC_BUTTON_XI_OVERRIDE 2013 +#define IDC_BUTTON_ENABLE 2014
#define IDC_DI_DEVICES 2100 #define IDC_DI_AXES 2101
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/joy.cpl/joy.rc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/joy.cpl/joy.rc b/dlls/joy.cpl/joy.rc index 2abae6d4272..24ba8162532 100644 --- a/dlls/joy.cpl/joy.rc +++ b/dlls/joy.cpl/joy.rc @@ -38,14 +38,14 @@ FONT 8, "Ms Shell Dlg" { PUSHBUTTON "&Disable", IDC_BUTTON_DI_DISABLE, 200, 20, 60, 15 PUSHBUTTON "&Reset", IDC_BUTTON_DI_RESET, 200, 40, 60, 15 - PUSHBUTTON "&Enable", IDC_BUTTON_ENABLE, 200, 190, 60, 15 - PUSHBUTTON "&Override", IDC_BUTTON_XI_OVERRIDE, 200, 100, 60, 15 + PUSHBUTTON "&Override", IDC_BUTTON_XI_OVERRIDE, 200, 90, 60, 15 + PUSHBUTTON "&Enable", IDC_BUTTON_ENABLE, 200, 160, 60, 15 LTEXT "Connected (DirectInput devices)", IDC_STATIC, 10, 10, 180, 10 - LISTBOX IDC_DI_ENABLED_LIST, 10, 20, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY - LTEXT "Connected (XInput devices)", IDC_STATIC, 10, 90, 180, 10 - LISTBOX IDC_XI_ENABLED_LIST, 10, 100, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY - LTEXT "Disabled", IDC_STATIC, 10, 180, 180, 10 - LISTBOX IDC_DISABLED_LIST, 10, 190, 180, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY + LISTBOX IDC_DI_ENABLED_LIST, 10, 20, 180, 60, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY + LTEXT "Connected (XInput devices)", IDC_STATIC, 10, 80, 180, 10 + LISTBOX IDC_XI_ENABLED_LIST, 10, 90, 180, 60, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY + LTEXT "Disabled", IDC_STATIC, 10, 150, 180, 10 + LISTBOX IDC_DISABLED_LIST, 10, 160, 180, 60, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY }
IDD_TEST_DI DIALOG 0, 0, 320, 300
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/joy.cpl/joy.rc | 4 ++++ dlls/joy.cpl/main.c | 43 +++++++++++++++++++++++++++++++++++++++++ dlls/joy.cpl/resource.h | 3 +++ 3 files changed, 50 insertions(+)
diff --git a/dlls/joy.cpl/joy.rc b/dlls/joy.cpl/joy.rc index 24ba8162532..b9f244b6518 100644 --- a/dlls/joy.cpl/joy.rc +++ b/dlls/joy.cpl/joy.rc @@ -46,6 +46,10 @@ FONT 8, "Ms Shell Dlg" LISTBOX IDC_XI_ENABLED_LIST, 10, 90, 180, 60, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY LTEXT "Disabled", IDC_STATIC, 10, 150, 180, 10 LISTBOX IDC_DISABLED_LIST, 10, 160, 180, 60, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY + + GROUPBOX "Advanced settings (restart prefix required to take effect)", IDC_ADVANCED, 10, 220, 300, 70 + AUTOCHECKBOX "Enable SDL", IDC_ENABLE_SDL, 20, 235, 100, 10 + AUTOCHECKBOX "Disable hidraw", IDC_DISABLE_HIDRAW, 20, 245, 100, 10 }
IDD_TEST_DI DIALOG 0, 0, 320, 300 diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c index ebd33208721..041f35d866c 100644 --- a/dlls/joy.cpl/main.c +++ b/dlls/joy.cpl/main.c @@ -124,6 +124,13 @@ static BOOL get_app_key(HKEY *defkey, HKEY *appkey) return *defkey || *appkey; }
+static BOOL get_advanced_key(HKEY *key) +{ + /* Registry key can be found in HKLM\System\CurrentControlSet\Services\WineBus */ + return !RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"System\CurrentControlSet\Services\WineBus", 0, NULL, 0, + KEY_SET_VALUE | KEY_READ, NULL, key, NULL); +} + /****************************************************************************** * set_config_key [internal] * Writes a string value to a registry key, deletes the key if value == NULL @@ -172,6 +179,25 @@ static void enable_joystick(WCHAR *joy_name, BOOL enable) if (appkey) RegCloseKey(appkey); }
+static void set_advanced_option( const WCHAR *option, DWORD value ) +{ + HKEY hkey; + if (!get_advanced_key( &hkey )) return; + RegSetValueExW( hkey, option, 0, REG_DWORD, (BYTE *)&value, sizeof(value) ); + RegCloseKey( hkey ); +} + +static DWORD get_advanced_option( const WCHAR *option, DWORD default_value ) +{ + DWORD value, size; + HKEY hkey; + if (!get_advanced_key( &hkey )) return default_value; + if (RegGetValueW( hkey, NULL, option, RRF_RT_REG_DWORD, NULL, (BYTE *)&value, &size )) + value = default_value; + RegCloseKey( hkey ); + return value; +} + static void refresh_joystick_list( HWND hwnd ) { IDirectInput8W *dinput; @@ -265,6 +291,8 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM { case WM_INITDIALOG: { + BOOL enable_sdl, disable_hidraw; + refresh_joystick_list( hwnd );
EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_ENABLE ), FALSE ); @@ -272,6 +300,11 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_RESET ), FALSE ); EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_XI_OVERRIDE ), FALSE );
+ enable_sdl = get_advanced_option( L"Enable SDL", TRUE ); + SendMessageW( GetDlgItem( hwnd, IDC_ENABLE_SDL ), BM_SETCHECK, enable_sdl, 0 ); + disable_hidraw = get_advanced_option( L"DisableHidraw", FALSE ); + SendMessageW( GetDlgItem( hwnd, IDC_DISABLE_HIDRAW ), BM_SETCHECK, disable_hidraw, 0 ); + devnotify = RegisterDeviceNotificationW( hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE ); return TRUE; } @@ -351,6 +384,16 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_DI_RESET ), FALSE ); EnableWindow( GetDlgItem( hwnd, IDC_BUTTON_XI_OVERRIDE ), FALSE ); break; + + case IDC_ENABLE_SDL: + sel = SendMessageW( GetDlgItem( hwnd, IDC_ENABLE_SDL ), BM_GETCHECK, 0, 0 ); + set_advanced_option( L"Enable SDL", sel ); + break; + + case IDC_DISABLE_HIDRAW: + sel = SendMessageW( GetDlgItem( hwnd, IDC_DISABLE_HIDRAW ), BM_GETCHECK, 0, 0 ); + set_advanced_option( L"DisableHidraw", sel ); + break; }
return TRUE; diff --git a/dlls/joy.cpl/resource.h b/dlls/joy.cpl/resource.h index 44a756cea5f..d2c16a27288 100644 --- a/dlls/joy.cpl/resource.h +++ b/dlls/joy.cpl/resource.h @@ -41,6 +41,9 @@ #define IDC_DI_ENABLED_LIST 2000 #define IDC_XI_ENABLED_LIST 2001 #define IDC_DISABLED_LIST 2002 +#define IDC_ADVANCED 2003 +#define IDC_DISABLE_HIDRAW 2004 +#define IDC_ENABLE_SDL 2005
#define IDC_BUTTON_DI_DISABLE 2010 #define IDC_BUTTON_DI_RESET 2011