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