Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57919 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57920
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dinput/tests/Makefile.in | 2 +- dlls/dinput/tests/hotplug.c | 62 ++++++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 16 deletions(-)
diff --git a/dlls/dinput/tests/Makefile.in b/dlls/dinput/tests/Makefile.in index c40300e619b..608b817e0f4 100644 --- a/dlls/dinput/tests/Makefile.in +++ b/dlls/dinput/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = dinput.dll -IMPORTS = dinput dinput8 ole32 version user32 advapi32 hid uuid crypt32 newdev setupapi wintrust winmm cfgmgr32 +IMPORTS = dinput dinput8 ole32 version user32 advapi32 hid uuid crypt32 newdev setupapi wintrust winmm
driver_bus_IMPORTS = winecrt0 ntoskrnl hal driver_bus_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c index 73a8bc8057c..ce44bae754c 100644 --- a/dlls/dinput/tests/hotplug.c +++ b/dlls/dinput/tests/hotplug.c @@ -471,6 +471,18 @@ static CALLBACK DWORD cm_notify_callback( HCMNOTIFICATION hnotify, void *ctx, CM return ERROR_SUCCESS; }
+static DWORD WINAPI cm_register_notification( PCM_NOTIFY_FILTER filter, void *ctx, PCM_NOTIFY_CALLBACK callback, HCMNOTIFICATION *notify ) +{ + struct cm_notify_callback_data *cb_data = ctx; + ReleaseSemaphore( cb_data->device_change_sem, cb_data->device_change_expect, NULL ); + return TRUE; +} + +static DWORD WINAPI cm_unregister_notification( HCMNOTIFICATION notify ) +{ + return TRUE; +} + static void test_RegisterDeviceNotification(void) { DEV_BROADCAST_DEVICEINTERFACE_A iface_filter_a = @@ -492,11 +504,13 @@ static void test_RegisterDeviceNotification(void) .lpfnWndProc = devnotify_wndproc, }; CM_NOTIFY_FILTER cm_iface_filter = - {.cbSize = sizeof(CM_NOTIFY_FILTER), - .Flags = 0, - .FilterType = CM_NOTIFY_FILTER_TYPE_DEVICEINTERFACE, - .Reserved = 0, - .u = {.DeviceInterface = {.ClassGuid = GUID_DEVINTERFACE_HID}}}; + { + .cbSize = sizeof(CM_NOTIFY_FILTER), + .Flags = 0, + .FilterType = CM_NOTIFY_FILTER_TYPE_DEVICEINTERFACE, + .Reserved = 0, + .u = {.DeviceInterface = {.ClassGuid = GUID_DEVINTERFACE_HID}} + }; CM_NOTIFY_FILTER cm_all_ifaces_filter = { .cbSize = sizeof(CM_NOTIFY_FILTER), @@ -513,12 +527,28 @@ static void test_RegisterDeviceNotification(void) }; char buffer[1024] = {0}; DEV_BROADCAST_HDR *header = (DEV_BROADCAST_HDR *)buffer; + + DWORD (WINAPI *pCM_Register_Notification)(PCM_NOTIFY_FILTER,PVOID,PCM_NOTIFY_CALLBACK,PHCMNOTIFICATION); + DWORD (WINAPI *pCM_Unregister_Notification)(HCMNOTIFICATION); + HMODULE cfgmgr32 = LoadLibraryW( L"cfgmgr32" ); struct cm_notify_callback_data cm_ctx = {0}; HANDLE hwnd, thread, stop_event; HDEVNOTIFY devnotify; DWORD i, ret; MSG msg;
+ if (cfgmgr32) + { + pCM_Register_Notification = (void *)GetProcAddress( cfgmgr32, "CM_Register_Notification" ); + pCM_Unregister_Notification = (void *)GetProcAddress( cfgmgr32, "CM_Unregister_Notification" ); + } + else + { + pCM_Register_Notification = cm_register_notification; + pCM_Unregister_Notification = cm_unregister_notification; + win_skip( "cfgmgr32 not found, skipping tests\n" ); + } + RegisterClassExW( &class );
hwnd = CreateWindowW( class.lpszClassName, NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL ); @@ -595,7 +625,7 @@ static void test_RegisterDeviceNotification(void) cm_ctx.device_change_expect = 2; cm_ctx.device_change_count = 0;
- ret = CM_Register_Notification( &cm_iface_filter, &cm_ctx, cm_notify_callback, &cm_ctx.hnotify ); + ret = pCM_Register_Notification( &cm_iface_filter, &cm_ctx, cm_notify_callback, &cm_ctx.hnotify ); ok( !ret, "CM_Register_Notification failed, error %lu\n", ret );
device_change_count = 0; @@ -634,7 +664,7 @@ static void test_RegisterDeviceNotification(void) CloseHandle( stop_event );
UnregisterDeviceNotification( devnotify ); - CM_Unregister_Notification( cm_ctx.hnotify ); + pCM_Unregister_Notification( cm_ctx.hnotify );
memcpy( buffer, &iface_filter_a, sizeof(iface_filter_a) ); strcpy( ((DEV_BROADCAST_DEVICEINTERFACE_A *)buffer)->dbcc_name, "device name" ); @@ -647,7 +677,7 @@ static void test_RegisterDeviceNotification(void) cm_ctx.device_change_expect = 2; cm_ctx.device_change_count = 0;
- ret = CM_Register_Notification( &cm_iface_filter, &cm_ctx, cm_notify_callback, &cm_ctx.hnotify ); + ret = pCM_Register_Notification( &cm_iface_filter, &cm_ctx, cm_notify_callback, &cm_ctx.hnotify ); ok( !ret, "CM_Register_Notification failed, error %lu\n", ret );
device_change_count = 0; @@ -686,7 +716,7 @@ static void test_RegisterDeviceNotification(void) CloseHandle( stop_event );
UnregisterDeviceNotification( devnotify ); - CM_Unregister_Notification( cm_ctx.hnotify ); + pCM_Unregister_Notification( cm_ctx.hnotify );
devnotify = RegisterDeviceNotificationA( hwnd, &iface_filter_a, DEVICE_NOTIFY_ALL_INTERFACE_CLASSES ); ok( !!devnotify, "RegisterDeviceNotificationA failed, error %lu\n", GetLastError() ); @@ -695,7 +725,7 @@ static void test_RegisterDeviceNotification(void) cm_ctx.device_change_all = TRUE; cm_ctx.device_change_expect = 4; cm_ctx.device_change_count = 0; - ret = CM_Register_Notification( &cm_all_ifaces_filter, &cm_ctx, cm_notify_callback, + ret = pCM_Register_Notification( &cm_all_ifaces_filter, &cm_ctx, cm_notify_callback, &cm_ctx.hnotify ); ok( !ret, "CM_Register_Notification failed, error %lu\n", ret );
@@ -735,7 +765,7 @@ static void test_RegisterDeviceNotification(void) CloseHandle( stop_event );
UnregisterDeviceNotification( devnotify ); - CM_Unregister_Notification( cm_ctx.hnotify ); + pCM_Unregister_Notification( cm_ctx.hnotify );
devnotify = RegisterDeviceNotificationA( hwnd, &iface_filter_a, DEVICE_NOTIFY_WINDOW_HANDLE ); ok( !!devnotify, "RegisterDeviceNotificationA failed, error %lu\n", GetLastError() ); @@ -745,7 +775,7 @@ static void test_RegisterDeviceNotification(void) cm_ctx.device_change_expect = 2 + ARRAY_SIZE(device_change_events); cm_ctx.device_change_count = 0; cm_iface_filter.Flags = 0; - ret = CM_Register_Notification( &cm_iface_filter, &cm_ctx, cm_notify_callback, &cm_ctx.hnotify ); + ret = pCM_Register_Notification( &cm_iface_filter, &cm_ctx, cm_notify_callback, &cm_ctx.hnotify ); ok( !ret, "CM_Register_Notification failed, error %lu\n", ret );
device_change_count = 0; @@ -790,7 +820,7 @@ static void test_RegisterDeviceNotification(void) ok( !!handle_devnotify, "RegisterDeviceNotificationA failed, error %lu\n", GetLastError() );
cm_handle_filter.u.DeviceHandle.hTarget = file; - ret = CM_Register_Notification( &cm_handle_filter, &cm_ctx, cm_notify_callback, &handle_cmnotify ); + ret = pCM_Register_Notification( &cm_handle_filter, &cm_ctx, cm_notify_callback, &handle_cmnotify ); ok( !ret, "CM_Register_Notification failed, error %lu\n", ret );
device_change_expect_handle = file; @@ -825,15 +855,17 @@ static void test_RegisterDeviceNotification(void) CloseHandle( stop_event );
if (handle_devnotify) UnregisterDeviceNotification( handle_devnotify ); - if (handle_cmnotify) CM_Unregister_Notification( handle_cmnotify ); + if (handle_cmnotify) pCM_Unregister_Notification( handle_cmnotify ); UnregisterDeviceNotification( devnotify ); - CM_Unregister_Notification( cm_ctx.hnotify ); + pCM_Unregister_Notification( cm_ctx.hnotify ); device_change_expect_event = NULL; handle_devnotify = 0; CloseHandle( cm_ctx.device_change_sem );
DestroyWindow( hwnd ); UnregisterClassW( class.lpszClassName, class.hInstance ); + + if (cfgmgr32) FreeLibrary( cfgmgr32 ); }
struct controller_handler
From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57920 --- dlls/dinput/tests/dinput.c | 145 ++++++++++++++++++++----------------- 1 file changed, 80 insertions(+), 65 deletions(-)
diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c index 88db7be9288..0585a3c53e6 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -925,8 +925,9 @@ static void test_EnumDevicesBySemantics(void) DIACTIONFORMATA action_format; const GUID ACTION_MAPPING_GUID = {0x1, 0x2, 0x3, {0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}}; struct enum_semantics_test data = {0, 0, FALSE, FALSE, &action_format, NULL}; + static const char *names[] = {NULL, "", "Ninja Brian", "Sh4d0w M4g3"}; IDirectInput8A *dinput; - int device_total = 0; + int i, device_total = 0; HRESULT hr;
hr = DirectInput8Create( instance, 0x800, &IID_IDirectInput8A, (void **)&dinput, NULL ); @@ -960,87 +961,101 @@ static void test_EnumDevicesBySemantics(void) data.keyboard = FALSE; data.mouse = FALSE; data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, - &data, DIEDBSFL_FORCEFEEDBACK ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%#lx\n", hr ); + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, &data, DIEDBSFL_FORCEFEEDBACK ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); ok( !data.keyboard, "Keyboard should not be enumerated when asking for forcefeedback\n" ); ok( !data.mouse, "Mouse should not be enumerated when asking for forcefeedback\n" );
- /* Enumerate available devices. That is devices not owned by any user. - Before setting the action map for all devices we still have them available. */ + /* Enumerate available devices. That is devices not owned by any user. Before setting the action map for all devices we still have them available. */ data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, - &data, DIEDBSFL_AVAILABLEDEVICES ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%#lx\n", hr ); - ok( data.device_count > 0, - "There should be devices available before action mapping available=%d\n", data.device_count ); - - /* Keep the device total */ + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, &data, DIEDBSFL_AVAILABLEDEVICES ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + ok( data.device_count > 0, "got device_count %d\n", data.device_count ); device_total = data.device_count;
- /* There should be no devices for any user. No device should be enumerated with DIEDBSFL_THISUSER. - MSDN defines that all unowned devices are also enumerated but this doesn't seem to be happening. */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics( dinput, "Sh4d0w M4g3", &action_format, - enum_semantics_callback, &data, DIEDBSFL_THISUSER ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%#lx\n", hr ); - ok( data.device_count == 0, "No devices should be assigned for this user assigned=%d\n", data.device_count ); + for (i = 0; i < ARRAY_SIZE(names); i++) + { + winetest_push_context( "%s", debugstr_a(names[i]) ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, 0 ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + ok( data.device_count == device_total, "got device_count %d\n", data.device_count ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, DIEDBSFL_THISUSER ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + ok( data.device_count == 0, "got device_count %d\n", data.device_count ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, DIEDBSFL_AVAILABLEDEVICES ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + ok( data.device_count == device_total, "got device_count %d\n", data.device_count ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, DIEDBSFL_THISUSER | DIEDBSFL_AVAILABLEDEVICES ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + ok( data.device_count == device_total, "got device_count %d\n", data.device_count ); + winetest_pop_context(); + }
- /* This enumeration builds and sets the action map for all devices with a NULL username */ - hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, set_action_map_callback, - &data, DIEDBSFL_ATTACHEDONLY ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%#lx\n", hr ); + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, set_action_map_callback, &data, DIEDBSFL_ATTACHEDONLY ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr );
- /* After a successful action mapping we should have no devices available */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, - &data, DIEDBSFL_AVAILABLEDEVICES ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%#lx\n", hr ); - ok( data.device_count == 0, "No device should be available after action mapping available=%d\n", - data.device_count ); + for (i = 0; i < ARRAY_SIZE(names); i++) + { + winetest_push_context( "%s", debugstr_a(names[i]) ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, 0 ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + ok( data.device_count == device_total, "got device_count %d\n", data.device_count ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, DIEDBSFL_THISUSER ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + if (!names[i] || !names[i][0]) ok( data.device_count == device_total, "got device_count %d\n", data.device_count ); + else ok( data.device_count == 0, "got device_count %d\n", data.device_count ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, DIEDBSFL_AVAILABLEDEVICES ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + ok( data.device_count == 0, "got device_count %d\n", data.device_count ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, DIEDBSFL_THISUSER | DIEDBSFL_AVAILABLEDEVICES ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + if (!names[i] || !names[i][0]) ok( data.device_count == device_total, "got device_count %d\n", data.device_count ); + else ok( data.device_count == 0, "got device_count %d\n", data.device_count ); + winetest_pop_context(); + }
- /* Now we'll give all the devices to a specific user */ data.username = "Sh4d0w M4g3"; - hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, set_action_map_callback, - &data, DIEDBSFL_ATTACHEDONLY ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%#lx\n", hr ); - - /* Testing with the default user, DIEDBSFL_THISUSER has no effect */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, - enum_semantics_callback, &data, DIEDBSFL_THISUSER ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%#lx\n", hr ); - ok( data.device_count == device_total, "THISUSER has no effect with NULL username owned=%d, expected=%d\n", - data.device_count, device_total ); - - /* Using an empty user string is the same as passing NULL, DIEDBSFL_THISUSER has no effect */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics( dinput, "", &action_format, enum_semantics_callback, &data, DIEDBSFL_THISUSER ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%#lx\n", hr ); - ok( data.device_count == device_total, "THISUSER has no effect with "" as username owned=%d, expected=%d\n", - data.device_count, device_total ); + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, set_action_map_callback, &data, DIEDBSFL_ATTACHEDONLY ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr );
- /* Testing with a user with no ownership of the devices */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics( dinput, "Ninja Brian", &action_format, - enum_semantics_callback, &data, DIEDBSFL_THISUSER ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%#lx\n", hr ); - ok( data.device_count == 0, "This user should own no devices owned=%d\n", data.device_count ); - - /* Sh4d0w M4g3 has ownership of all devices */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics( dinput, "Sh4d0w M4g3", &action_format, - enum_semantics_callback, &data, DIEDBSFL_THISUSER ); - ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%#lx\n", hr ); - ok( data.device_count == device_total, "This user should own %d devices owned=%d\n", - device_total, data.device_count ); + for (i = 0; i < ARRAY_SIZE(names); i++) + { + winetest_push_context( "%s", debugstr_a(names[i]) ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, 0 ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + ok( data.device_count == device_total, "got device_count %d\n", data.device_count ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, DIEDBSFL_THISUSER ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + if (!names[i] || !names[i][0] || !strcmp( names[i], data.username )) ok( data.device_count == device_total, "got device_count %d\n", data.device_count ); + else ok( data.device_count == 0, "got device_count %d\n", data.device_count ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, DIEDBSFL_AVAILABLEDEVICES ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + ok( data.device_count == 0, "got device_count %d\n", data.device_count ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, names[i], &action_format, enum_semantics_callback, &data, DIEDBSFL_THISUSER | DIEDBSFL_AVAILABLEDEVICES ); + ok( hr == S_OK, "EnumDevicesBySemantics returned %#lx\n", hr ); + if (!names[i] || !names[i][0] || !strcmp( names[i], data.username )) ok( data.device_count == device_total, "got device_count %d\n", data.device_count ); + else ok( data.device_count == 0, "got device_count %d\n", data.device_count ); + winetest_pop_context(); + }
/* The call fails with a zeroed GUID */ memset( &action_format.guidActionMap, 0, sizeof(GUID) ); data.device_count = 0; hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, NULL, 0 ); todo_wine - ok( FAILED(hr), "EnumDevicesBySemantics succeeded with invalid GUID hr=%#lx\n", hr ); + ok( hr == E_INVALIDARG, "EnumDevicesBySemantics returned %#lx\n", hr );
IDirectInput8_Release( dinput ); }
From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57920 --- dlls/dinput/dinput.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/dlls/dinput/dinput.c b/dlls/dinput/dinput.c index e53eea4e292..f851e17a244 100644 --- a/dlls/dinput/dinput.c +++ b/dlls/dinput/dinput.c @@ -466,13 +466,23 @@ static BOOL CALLBACK enum_device_by_semantics( const DIDEVICEINSTANCEW *instance
if (FAILED(hr = IDirectInputDevice8_GetProperty( device, DIPROP_USERNAME, &prop_username.diph ))) WARN( "Failed to get device capabilities, hr %#lx\n", hr ); - else if ((params->flags & DIEDBSFL_THISUSER) && *params->username && wcscmp( params->username, prop_username.wsz )) - goto done; - else if ((params->flags & DIEDBSFL_AVAILABLEDEVICES) && *prop_username.wsz) - goto done;
- IDirectInputDevice_AddRef( device ); - params->devices[params->device_count++] = device; + if ((params->flags & DIEDBSFL_AVAILABLEDEVICES) && !*prop_username.wsz) + { + params->devices[params->device_count++] = device; + return DIENUM_CONTINUE; + } + if ((params->flags & DIEDBSFL_THISUSER) && *prop_username.wsz && + (!*params->username || !wcscmp( params->username, prop_username.wsz ))) + { + params->devices[params->device_count++] = device; + return DIENUM_CONTINUE; + } + if (!params->flags) + { + params->devices[params->device_count++] = device; + return DIENUM_CONTINUE; + }
done: IDirectInputDevice8_Release( device );
From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57919 --- dlls/dinput/device.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 4166d18dd8c..d8e5aed8ead 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1802,7 +1802,7 @@ static HRESULT WINAPI dinput_device_WriteEffectToFile( IDirectInputDevice8W *ifa BOOL device_object_matches_semantic( const DIDEVICEINSTANCEW *instance, const DIOBJECTDATAFORMAT *object, DWORD semantic, BOOL exact ) { - DWORD value = semantic & 0xff, axis = (semantic >> 15) & 3, type; + DWORD value = semantic & 0xff, axis = (semantic >> 15) & 15, type;
switch (semantic & 0x700) { @@ -1814,17 +1814,20 @@ BOOL device_object_matches_semantic( const DIDEVICEINSTANCEW *instance, const DI }
if (!(DIDFT_GETTYPE( object->dwType ) & type)) return FALSE; - if ((semantic & 0xf0000000) == 0x80000000) + switch (semantic & 0xff000000) { - switch (semantic & 0x0f000000) - { - case 0x01000000: return (instance->dwDevType & 0xf) == DIDEVTYPE_KEYBOARD && object->dwOfs == value; - case 0x02000000: return (instance->dwDevType & 0xf) == DIDEVTYPE_MOUSE && object->dwOfs == value; - default: return FALSE; - } + case 0x81000000: return (instance->dwDevType & 0xf) == DIDEVTYPE_KEYBOARD && object->dwOfs == value; + case 0x82000000: return (instance->dwDevType & 0xf) == DIDEVTYPE_MOUSE && object->dwOfs == value; + case 0x83000000: return FALSE; + + default: + if ((instance->dwDevType & 0xf) == DIDEVTYPE_KEYBOARD) return FALSE; + if ((instance->dwDevType & 0xf) == DIDEVTYPE_MOUSE) return FALSE; + /* fallthrough */ + case 0xff000000: + if (axis && (axis - 1) != DIDFT_GETINSTANCE( object->dwType )) return FALSE; + return !exact || !value || value == DIDFT_GETINSTANCE( object->dwType ) + 1; } - if (axis && (axis - 1) != DIDFT_GETINSTANCE( object->dwType )) return FALSE; - return !exact || !value || value == DIDFT_GETINSTANCE( object->dwType ) + 1; }
static HRESULT WINAPI dinput_device_BuildActionMap( IDirectInputDevice8W *iface, DIACTIONFORMATW *format,
From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57919 --- dlls/dinput/device.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index d8e5aed8ead..6288eeb3c2a 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -415,16 +415,17 @@ static BOOL load_mapping_settings( struct dinput_device *This, LPDIACTIONFORMATW /* Try to read each action in the DIACTIONFORMAT from registry */ for (i = 0; i < lpdiaf->dwNumActions; i++) { + DIACTIONW *action = lpdiaf->rgoAction + i; DWORD id, size = sizeof(DWORD); WCHAR label[9];
swprintf( label, 9, L"%x", lpdiaf->rgoAction[i].dwSemantic );
- if (!RegQueryValueExW(hkey, label, 0, NULL, (LPBYTE) &id, &size)) + if (!action->dwHow && !RegQueryValueExW( hkey, label, 0, NULL, (BYTE *)&id, &size )) { - lpdiaf->rgoAction[i].dwObjID = id; - lpdiaf->rgoAction[i].guidInstance = didev.guidInstance; - lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT; + action->dwObjID = id; + action->guidInstance = didev.guidInstance; + action->dwHow = DIAH_DEFAULT; mapped += 1; } }
From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57919 --- dlls/dinput/config.c | 3 +++ dlls/dinput/device.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/config.c b/dlls/dinput/config.c index d7a416501f0..dd2edcd5869 100644 --- a/dlls/dinput/config.c +++ b/dlls/dinput/config.c @@ -307,6 +307,7 @@ static void assign_action(HWND dialog) lpdiaf->rgoAction[old_action].dwObjID = 0; lpdiaf->rgoAction[old_action].guidInstance = GUID_NULL; lpdiaf->rgoAction[old_action].dwHow = DIAH_UNMAPPED; + lpdiaf->rgoAction[old_action].dwFlags = 0; }
/* Find if action text is already set for other object and unset it */ @@ -321,6 +322,7 @@ static void assign_action(HWND dialog) lpdiaf->rgoAction[action].dwObjID = type; lpdiaf->rgoAction[action].guidInstance = device->ddi.guidInstance; lpdiaf->rgoAction[action].dwHow = DIAH_USERCONFIG; + lpdiaf->rgoAction[action].dwFlags |= DIA_APPMAPPED;
/* Set new action in the list */ lv_set_action(dialog, obj, action, lpdiaf); @@ -334,6 +336,7 @@ static void copy_actions(LPDIACTIONFORMATW to, LPDIACTIONFORMATW from) to->rgoAction[i].guidInstance = from->rgoAction[i].guidInstance; to->rgoAction[i].dwObjID = from->rgoAction[i].dwObjID; to->rgoAction[i].dwHow = from->rgoAction[i].dwHow; + to->rgoAction[i].dwFlags = from->rgoAction[i].dwFlags; to->rgoAction[i].lptszActionName = from->rgoAction[i].lptszActionName; } } diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 6288eeb3c2a..31240d03f65 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1867,11 +1867,14 @@ static HRESULT WINAPI dinput_device_BuildActionMap( IDirectInputDevice8W *iface, if (!action->dwSemantic) return DIERR_INVALIDPARAM; if (flags == DIDBAM_PRESERVE && !IsEqualCLSID( &action->guidInstance, &GUID_NULL ) && !IsEqualCLSID( &action->guidInstance, &impl->guid )) continue; - if (action->dwFlags & DIA_APPMAPPED) action->dwHow = DIAH_APPREQUESTED; - else action->dwHow = 0; - if (action->dwHow == DIAH_APPREQUESTED || action->dwHow == DIAH_USERCONFIG) continue; + if (action->dwFlags & DIA_APPMAPPED) + { + action->dwHow = DIAH_APPREQUESTED; + continue; + } if ((action->dwSemantic & 0xf0000000) == 0x80000000) action->dwFlags &= ~DIA_APPNOMAP; if (!(action->dwFlags & DIA_APPNOMAP)) action->guidInstance = GUID_NULL; + action->dwHow = 0; }
/* Unless asked the contrary by these flags, try to load a previous mapping */