Reducing verbosity and fixing typos and potentially interleaved lines.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/driver_hid.c | 16 +++++++++------- dlls/dinput8/tests/driver_hid.h | 11 +++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/dlls/dinput8/tests/driver_hid.c b/dlls/dinput8/tests/driver_hid.c index 45c9f3e14ab..d6f085e4f30 100644 --- a/dlls/dinput8/tests/driver_hid.c +++ b/dlls/dinput8/tests/driver_hid.c @@ -479,7 +479,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, TRUE ); winetest_push_context( "%s expect[%d]", expect.context, index ); - ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code ); + ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code ); ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId ); ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen ); ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len, @@ -503,7 +503,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, FALSE ); winetest_push_context( "%s expect[%d]", expect.context, index ); - ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code ); + ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code ); ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId ); ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen ); winetest_pop_context(); @@ -526,7 +526,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, TRUE ); winetest_push_context( "%s expect[%d]", expect.context, index ); - ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code ); + ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code ); ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId ); ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen ); ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len, @@ -550,7 +550,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, FALSE ); winetest_push_context( "%s expect[%d]", expect.context, index ); - ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code ); + ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code ); ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId ); ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen ); winetest_pop_context(); @@ -573,7 +573,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, TRUE ); winetest_push_context( "%s expect[%d]", expect.context, index ); - ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code ); + ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code ); ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId ); ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen ); ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len, @@ -586,12 +586,14 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) }
case IOCTL_HID_GET_STRING: - todo_wine - ok( 0, "unexpected IOCTL_HID_GET_STRING\n" ); + { + static unsigned int once; + if (!once++) todo_wine ok( 0, "unexpected IOCTL_HID_GET_STRING\n" ); memcpy( irp->UserBuffer, L"Wine Test", sizeof(L"Wine Test") ); irp->IoStatus.Information = sizeof(L"Wine Test"); ret = STATUS_SUCCESS; break; + }
default: ok( 0, "unexpected ioctl %#x\n", code ); diff --git a/dlls/dinput8/tests/driver_hid.h b/dlls/dinput8/tests/driver_hid.h index 4fec0e99e47..6c355760171 100644 --- a/dlls/dinput8/tests/driver_hid.h +++ b/dlls/dinput8/tests/driver_hid.h @@ -147,8 +147,15 @@ static inline void kvprintf( const char *format, va_list ap ) { struct tls_data *data = get_tls_data(); IO_STATUS_BLOCK io; - int len = vsnprintf( data->strings, sizeof(data->strings), format, ap ); - ZwWriteFile( okfile, NULL, NULL, NULL, &io, data->strings, len, NULL, NULL ); + int len = vsnprintf( data->str_pos, sizeof(data->strings) - (data->str_pos - data->strings), format, ap ); + data->str_pos += len; + + if (len && data->str_pos[-1] == '\n') + { + ZwWriteFile( okfile, NULL, NULL, NULL, &io, data->strings, + strlen( data->strings ), NULL, NULL ); + data->str_pos = data->strings; + } }
static inline void WINAPIV kprintf( const char *format, ... ) __WINE_PRINTF_ATTR( 1, 2 );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/hid.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 66e8c7c0b0d..73813aa6948 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -5699,7 +5699,8 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file, DWO hr = IDirectInputDevice8_Unacquire( device ); ok( hr == DI_OK, "Unacquire returned: %#x\n", hr ); set_hid_expect( file, NULL, 0 ); - hr = IDirectInputEffect_SetParameters( effect, &expect_desc, DIEP_DURATION | DIEP_NODOWNLOAD ); + hr = IDirectInputEffect_SetParameters( effect, &expect_desc, DIEP_DURATION ); + todo_wine ok( hr == DI_DOWNLOADSKIPPED, "SetParameters returned %#x\n", hr ); set_hid_expect( file, &expect_dc_reset, sizeof(expect_dc_reset) ); hr = IDirectInputDevice8_Acquire( device ); @@ -6150,6 +6151,20 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file, DWO ok( ref == 0, "Release returned %d\n", ref ); winetest_pop_context(); } + + set_hid_expect( file, &expect_dc_reset, sizeof(expect_dc_reset) ); + hr = IDirectInputDevice8_Unacquire( device ); + ok( hr == DI_OK, "Acquire returned: %#x\n", hr ); + set_hid_expect( file, NULL, 0 ); + hr = IDirectInputDevice8_CreateEffect( device, &GUID_Sine, &expect_desc, &effect, NULL ); + todo_wine + ok( hr == DI_OK, "CreateEffect returned %#x\n", hr ); + ref = IDirectInputEffect_Release( effect ); + ok( ref == 0, "Release returned %d\n", ref ); + set_hid_expect( file, &expect_dc_reset, sizeof(expect_dc_reset) ); + hr = IDirectInputDevice8_Acquire( device ); + ok( hr == DI_OK, "Acquire returned: %#x\n", hr ); + set_hid_expect( file, NULL, 0 ); }
static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DWORD version )
From: Ivo Ivanov logos128@gmail.com
When Download or Start failed because device is not acquired.
From: Ivo Ivanov logos128@gmail.com Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51922 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 7 ++++--- dlls/dinput8/tests/hid.c | 1 - 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index a5fbfb81332..67a43924e19 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2406,9 +2406,10 @@ static HRESULT WINAPI hid_joystick_effect_SetParameters( IDirectInputEffect *ifa impl->flags |= flags;
if (flags & DIEP_NODOWNLOAD) return DI_DOWNLOADSKIPPED; - if (flags & DIEP_START) return IDirectInputEffect_Start( iface, 1, 0 ); - if (FAILED(hr = IDirectInputEffect_Download( iface ))) return hr; - if (hr == DI_NOEFFECT) return DI_DOWNLOADSKIPPED; + if (flags & DIEP_START) hr = IDirectInputEffect_Start( iface, 1, 0 ); + else hr = IDirectInputEffect_Download( iface ); + if (hr == DIERR_NOTEXCLUSIVEACQUIRED) return DI_DOWNLOADSKIPPED; + if (FAILED(hr)) return hr; return DI_OK; }
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 73813aa6948..f80a5013f1b 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -5700,7 +5700,6 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file, DWO ok( hr == DI_OK, "Unacquire returned: %#x\n", hr ); set_hid_expect( file, NULL, 0 ); hr = IDirectInputEffect_SetParameters( effect, &expect_desc, DIEP_DURATION ); - todo_wine ok( hr == DI_DOWNLOADSKIPPED, "SetParameters returned %#x\n", hr ); set_hid_expect( file, &expect_dc_reset, sizeof(expect_dc_reset) ); hr = IDirectInputDevice8_Acquire( device );
From: Ivo Ivanov logos128@gmail.com
SetParameters returns DI_DOWNLOADSKIPPED if the device is not acquired exclusively.
This fixes Assetto Corsa Competizione and Assetto Corsa not having FFB due to calling CreateEffect before acquiring the device, which skips the effect download and returns DI_DOWNLOADSKIPPED.
In particular, ACC tries twice to create the effect, and each time they unacquire the device to turn off the autocenter, and then create the effect while still in unacquired state, which in turn returns DI_DOWNLOADSKIPPED, etc.
From: Ivo Ivanov logos128@gmail.com Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51922 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 2 +- dlls/dinput8/tests/hid.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index b423337c9ce..c58ffc7ac73 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1375,7 +1375,7 @@ static HRESULT WINAPI dinput_device_CreateEffect( IDirectInputDevice8W *iface, c if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) flags |= DIEP_NODOWNLOAD; hr = IDirectInputEffect_SetParameters( *out, params, flags ); if (FAILED(hr)) goto failed; - return hr; + return DI_OK;
failed: IDirectInputEffect_Release( *out ); diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index f80a5013f1b..bea4d40d3e6 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -6156,7 +6156,6 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file, DWO ok( hr == DI_OK, "Acquire returned: %#x\n", hr ); set_hid_expect( file, NULL, 0 ); hr = IDirectInputDevice8_CreateEffect( device, &GUID_Sine, &expect_desc, &effect, NULL ); - todo_wine ok( hr == DI_OK, "CreateEffect returned %#x\n", hr ); ref = IDirectInputEffect_Release( effect ); ok( ref == 0, "Release returned %d\n", ref );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/hid.c | 230 +++++++++++++++++---------------------- 1 file changed, 98 insertions(+), 132 deletions(-)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index bea4d40d3e6..7eba2f9f035 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3455,6 +3455,99 @@ static BOOL CALLBACK check_created_effect_objects( IDirectInputEffect *effect, v return DIENUM_CONTINUE; }
+static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, IDirectInputDevice8W **device ) +{ + DIPROPDWORD prop_dword = + { + .diph = + { + .dwSize = sizeof(DIPROPDWORD), + .dwHeaderSize = sizeof(DIPROPHEADER), + .dwHow = DIPH_DEVICE, + }, + }; + IDirectInput8W *di8; + IDirectInputW *di; + HRESULT hr; + ULONG ref; + + if (version >= 0x800) + { + hr = DirectInput8Create( instance, version, &IID_IDirectInput8W, (void **)&di8, NULL ); + if (FAILED(hr)) + { + win_skip( "DirectInput8Create returned %#x\n", hr ); + return hr; + } + + hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_ALL, find_test_device, devinst, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + if (!IsEqualGUID( &devinst->guidProduct, &expect_guid_product )) + { + win_skip( "device not found, skipping tests\n" ); + ref = IDirectInput8_Release( di8 ); + ok( ref == 0, "Release returned %d\n", ref ); + return DIERR_DEVICENOTREG; + } + + hr = IDirectInput8_CreateDevice( di8, &devinst->guidInstance, NULL, NULL ); + ok( hr == E_POINTER, "CreateDevice returned %#x\n", hr ); + hr = IDirectInput8_CreateDevice( di8, NULL, device, NULL ); + ok( hr == E_POINTER, "CreateDevice returned %#x\n", hr ); + hr = IDirectInput8_CreateDevice( di8, &GUID_NULL, device, NULL ); + ok( hr == DIERR_DEVICENOTREG, "CreateDevice returned %#x\n", hr ); + hr = IDirectInput8_CreateDevice( di8, &devinst->guidInstance, device, NULL ); + ok( hr == DI_OK, "CreateDevice returned %#x\n", hr ); + + prop_dword.dwData = 0xdeadbeef; + hr = IDirectInputDevice8_GetProperty( *device, DIPROP_VIDPID, &prop_dword.diph ); + ok( hr == DI_OK, "GetProperty DIPROP_VIDPID returned %#x\n", hr ); + /* Wine may get the wrong device here, because the test driver creates another instance of + hidclass.sys, and gets duplicate rawinput handles, which we use in the guidInstance */ + todo_wine_if( prop_dword.dwData != EXPECT_VIDPID ) + ok( prop_dword.dwData == EXPECT_VIDPID, "got %#x expected %#x\n", prop_dword.dwData, EXPECT_VIDPID ); + + ref = IDirectInputDevice8_Release( *device ); + ok( ref == 0, "Release returned %d\n", ref ); + + hr = IDirectInput8_CreateDevice( di8, &expect_guid_product, device, NULL ); + ok( hr == DI_OK, "CreateDevice returned %#x\n", hr ); + + ref = IDirectInput8_Release( di8 ); + todo_wine + ok( ref == 0, "Release returned %d\n", ref ); + } + else + { + hr = DirectInputCreateEx( instance, version, &IID_IDirectInput2W, (void **)&di, NULL ); + if (FAILED(hr)) + { + win_skip( "DirectInputCreateEx returned %#x\n", hr ); + return hr; + } + + hr = IDirectInput_EnumDevices( di, 0, find_test_device, devinst, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + if (!IsEqualGUID( &devinst->guidProduct, &expect_guid_product )) + { + win_skip( "device not found, skipping tests\n" ); + + ref = IDirectInput_Release( di ); + ok( ref == 0, "Release returned %d\n", ref ); + return DIERR_DEVICENOTREG; + } + + hr = IDirectInput_CreateDevice( di, &expect_guid_product, (IDirectInputDeviceW **)device, NULL ); + ok( hr == DI_OK, "CreateDevice returned %#x\n", hr ); + + ref = IDirectInput_Release( di ); + todo_wine + ok( ref == 0, "Release returned %d\n", ref ); + } + + return DI_OK; +} + static void test_simple_joystick(void) { #include "psh_hid_macros.h" @@ -3796,7 +3889,6 @@ static void test_simple_joystick(void) IDirectInputEffect *effect; DIEFFESCAPE escape = {0}; DIDEVCAPS caps = {0}; - IDirectInput8W *di; HANDLE event, file; char buffer[1024]; DIJOYSTATE2 state; @@ -3812,56 +3904,7 @@ static void test_simple_joystick(void)
cleanup_registry_keys(); if (!dinput_driver_start( report_desc, sizeof(report_desc), &hid_caps )) goto done; - - hr = DirectInput8Create( instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void **)&di, NULL ); - if (FAILED(hr)) - { - win_skip( "DirectInput8Create returned %#x\n", hr ); - goto done; - } - - hr = IDirectInput8_EnumDevices( di, DI8DEVCLASS_ALL, find_test_device, &devinst, DIEDFL_ALLDEVICES ); - ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); - if (!IsEqualGUID( &devinst.guidProduct, &expect_guid_product )) - { - win_skip( "device not found, skipping tests\n" ); - IDirectInput8_Release( di ); - goto done; - } - - check_member( devinst, expect_devinst, "%d", dwSize ); - check_member_guid( devinst, expect_devinst, guidProduct ); - check_member( devinst, expect_devinst, "%#x", dwDevType ); - todo_wine - check_member_wstr( devinst, expect_devinst, tszInstanceName ); - todo_wine - check_member_wstr( devinst, expect_devinst, tszProductName ); - check_member_guid( devinst, expect_devinst, guidFFDriver ); - check_member( devinst, expect_devinst, "%04x", wUsagePage ); - check_member( devinst, expect_devinst, "%04x", wUsage ); - - hr = IDirectInput8_CreateDevice( di, &devinst.guidInstance, NULL, NULL ); - ok( hr == E_POINTER, "CreateDevice returned %#x\n", hr ); - hr = IDirectInput8_CreateDevice( di, NULL, &device, NULL ); - ok( hr == E_POINTER, "CreateDevice returned %#x\n", hr ); - hr = IDirectInput8_CreateDevice( di, &GUID_NULL, &device, NULL ); - ok( hr == DIERR_DEVICENOTREG, "CreateDevice returned %#x\n", hr ); - hr = IDirectInput8_CreateDevice( di, &devinst.guidInstance, &device, NULL ); - ok( hr == DI_OK, "CreateDevice returned %#x\n", hr ); - - prop_dword.dwData = 0xdeadbeef; - hr = IDirectInputDevice8_GetProperty( device, DIPROP_VIDPID, &prop_dword.diph ); - ok( hr == DI_OK, "GetProperty DIPROP_VIDPID returned %#x\n", hr ); - /* Wine may get the wrong device here, because the test driver creates another instance of - hidclass.sys, and gets duplicate rawinput handles, which we use in the guidInstance */ - todo_wine_if( prop_dword.dwData != EXPECT_VIDPID ) - ok( prop_dword.dwData == EXPECT_VIDPID, "got %#x expected %#x\n", prop_dword.dwData, EXPECT_VIDPID ); - - ref = IDirectInputDevice8_Release( device ); - ok( ref == 0, "Release returned %d\n", ref ); - - hr = IDirectInput8_CreateDevice( di, &expect_guid_product, &device, NULL ); - ok( hr == DI_OK, "CreateDevice returned %#x\n", hr ); + if (FAILED(hr = create_dinput_device( DIRECTINPUT_VERSION, &devinst, &device ))) goto done;
hr = IDirectInputDevice8_Initialize( device, instance, 0x0700, &GUID_NULL ); todo_wine @@ -4981,9 +5024,6 @@ static void test_simple_joystick(void) CloseHandle( event ); CloseHandle( file );
- ref = IDirectInput8_Release( di ); - ok( ref == 0, "Release returned %d\n", ref ); - done: pnp_driver_stop(); cleanup_registry_keys(); @@ -5242,7 +5282,6 @@ static BOOL test_device_types(void) WCHAR cwd[MAX_PATH], tempdir[MAX_PATH]; IDirectInputDevice8W *device; BOOL success = TRUE; - IDirectInput8W *di; ULONG i, ref; HRESULT hr;
@@ -5261,27 +5300,12 @@ static BOOL test_device_types(void) goto done; }
- hr = DirectInput8Create( instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void **)&di, NULL ); - if (FAILED(hr)) + if (FAILED(hr = create_dinput_device( DIRECTINPUT_VERSION, &devinst, &device ))) { - win_skip( "DirectInput8Create returned %#x\n", hr ); success = FALSE; goto done; }
- hr = IDirectInput8_EnumDevices( di, DI8DEVCLASS_ALL, find_test_device, &devinst, DIEDFL_ALLDEVICES ); - ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); - if (!IsEqualGUID( &devinst.guidProduct, &expect_guid_product )) - { - win_skip( "device not found, skipping tests\n" ); - IDirectInput8_Release( di ); - success = FALSE; - goto done; - } - - hr = IDirectInput8_CreateDevice( di, &expect_guid_product, &device, NULL ); - ok( hr == DI_OK, "CreateDevice returned %#x\n", hr ); - hr = IDirectInputDevice8_GetDeviceInfo( device, &devinst ); ok( hr == DI_OK, "GetDeviceInfo returned %#x\n", hr ); check_member( devinst, expect_devinst[i], "%d", dwSize ); @@ -5314,9 +5338,6 @@ static BOOL test_device_types(void) ref = IDirectInputDevice8_Release( device ); ok( ref == 0, "Release returned %d\n", ref );
- ref = IDirectInput8_Release( di ); - ok( ref == 0, "Release returned %d\n", ref ); - done: pnp_driver_stop(); cleanup_registry_keys(); @@ -7477,17 +7498,15 @@ static void test_force_feedback_joystick( DWORD version ) .dwHow = DIPH_DEVICE, }, }; + DIDEVICEINSTANCEW devinst = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; WCHAR cwd[MAX_PATH], tempdir[MAX_PATH]; DIDEVICEOBJECTDATA objdata = {0}; - DIDEVICEINSTANCEW devinst = {0}; DIEFFECTINFOW effectinfo = {0}; IDirectInputDevice8W *device; DIEFFESCAPE escape = {0}; DIDEVCAPS caps = {0}; - IDirectInput8W *di8; - IDirectInputW *di; - ULONG res, ref; char buffer[1024]; + ULONG res, ref; HANDLE file; HRESULT hr; HWND hwnd; @@ -7500,60 +7519,7 @@ static void test_force_feedback_joystick( DWORD version )
cleanup_registry_keys(); if (!dinput_driver_start( report_descriptor, sizeof(report_descriptor), &hid_caps )) goto done; - - if (version >= 0x800) - { - hr = DirectInput8Create( instance, version, &IID_IDirectInput8W, (void **)&di8, NULL ); - if (FAILED(hr)) - { - win_skip( "DirectInput8Create returned %#x\n", hr ); - goto done; - } - - hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_ALL, find_test_device, &devinst, DIEDFL_ALLDEVICES ); - ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); - if (!IsEqualGUID( &devinst.guidProduct, &expect_guid_product )) - { - win_skip( "device not found, skipping tests\n" ); - ref = IDirectInput8_Release( di8 ); - ok( ref == 0, "Release returned %d\n", ref ); - goto done; - } - - hr = IDirectInput8_CreateDevice( di8, &expect_guid_product, &device, NULL ); - ok( hr == DI_OK, "CreateDevice returned %#x\n", hr ); - - ref = IDirectInput8_Release( di8 ); - todo_wine - ok( ref == 0, "Release returned %d\n", ref ); - } - else - { - hr = DirectInputCreateEx( instance, version, &IID_IDirectInput2W, (void **)&di, NULL ); - if (FAILED(hr)) - { - win_skip( "DirectInputCreateEx returned %#x\n", hr ); - goto done; - } - - hr = IDirectInput_EnumDevices( di, 0, find_test_device, &devinst, DIEDFL_ALLDEVICES ); - ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); - if (!IsEqualGUID( &devinst.guidProduct, &expect_guid_product )) - { - win_skip( "device not found, skipping tests\n" ); - - ref = IDirectInput_Release( di ); - ok( ref == 0, "Release returned %d\n", ref ); - goto done; - } - - hr = IDirectInput_CreateDevice( di, &expect_guid_product, (IDirectInputDeviceW **)&device, NULL ); - ok( hr == DI_OK, "CreateDevice returned %#x\n", hr ); - - ref = IDirectInput_Release( di ); - todo_wine - ok( ref == 0, "Release returned %d\n", ref ); - } + if (FAILED(hr = create_dinput_device( version, &devinst, &device ))) goto done;
hr = IDirectInputDevice8_GetDeviceInfo( device, &devinst ); ok( hr == DI_OK, "GetDeviceInfo returned %#x\n", hr );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/hid.c | 41 ++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 7eba2f9f035..74f07c65498 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -5037,7 +5037,7 @@ struct device_desc HIDP_CAPS hid_caps; };
-static BOOL test_device_types(void) +static BOOL test_device_types( DWORD version ) { #include "psh_hid_macros.h" static const unsigned char unknown_desc[] = @@ -5197,32 +5197,36 @@ static BOOL test_device_types(void) }, }, }; - static const DIDEVCAPS expect_caps[] = + const DIDEVCAPS expect_caps[] = { { .dwSize = sizeof(DIDEVCAPS), .dwFlags = DIDC_ATTACHED|DIDC_EMULATED, - .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPESUPPLEMENTAL_UNKNOWN << 8)|DI8DEVTYPE_SUPPLEMENTAL, + .dwDevType = version >= 0x800 ? DIDEVTYPE_HID|(DI8DEVTYPESUPPLEMENTAL_UNKNOWN << 8)|DI8DEVTYPE_SUPPLEMENTAL + : DIDEVTYPE_HID|(DIDEVTYPEJOYSTICK_UNKNOWN << 8)|DIDEVTYPE_JOYSTICK, .dwButtons = 6, }, { .dwSize = sizeof(DIDEVCAPS), .dwFlags = DIDC_ATTACHED|DIDC_EMULATED, - .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_LIMITED << 8)|DI8DEVTYPE_JOYSTICK, + .dwDevType = version >= 0x800 ? DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_LIMITED << 8)|DI8DEVTYPE_JOYSTICK + : DIDEVTYPE_HID|(DIDEVTYPEJOYSTICK_UNKNOWN << 8)|DIDEVTYPE_JOYSTICK, .dwAxes = 2, .dwButtons = 6, }, { .dwSize = sizeof(DIDEVCAPS), .dwFlags = DIDC_ATTACHED|DIDC_EMULATED, - .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEGAMEPAD_STANDARD << 8)|DI8DEVTYPE_GAMEPAD, + .dwDevType = version >= 0x800 ? DIDEVTYPE_HID|(DI8DEVTYPEGAMEPAD_STANDARD << 8)|DI8DEVTYPE_GAMEPAD + : DIDEVTYPE_HID|(DIDEVTYPEJOYSTICK_GAMEPAD << 8)|DIDEVTYPE_JOYSTICK, .dwAxes = 2, .dwButtons = 6, }, { .dwSize = sizeof(DIDEVCAPS), .dwFlags = DIDC_ATTACHED|DIDC_EMULATED, - .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_STANDARD << 8)|DI8DEVTYPE_JOYSTICK, + .dwDevType = version >= 0x800 ? DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_STANDARD << 8)|DI8DEVTYPE_JOYSTICK + : DIDEVTYPE_HID|(DIDEVTYPEJOYSTICK_UNKNOWN << 8)|DIDEVTYPE_JOYSTICK, .dwAxes = 3, .dwPOVs = 1, .dwButtons = 5, @@ -5235,7 +5239,8 @@ static BOOL test_device_types(void) .dwSize = sizeof(DIDEVICEINSTANCEW), .guidInstance = expect_guid_product, .guidProduct = expect_guid_product, - .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPESUPPLEMENTAL_UNKNOWN << 8)|DI8DEVTYPE_SUPPLEMENTAL, + .dwDevType = version >= 0x800 ? DIDEVTYPE_HID|(DI8DEVTYPESUPPLEMENTAL_UNKNOWN << 8)|DI8DEVTYPE_SUPPLEMENTAL + : DIDEVTYPE_HID|(DIDEVTYPEJOYSTICK_UNKNOWN << 8)|DIDEVTYPE_JOYSTICK, .tszInstanceName = L"Wine test root driver", .tszProductName = L"Wine test root driver", .guidFFDriver = GUID_NULL, @@ -5246,7 +5251,8 @@ static BOOL test_device_types(void) .dwSize = sizeof(DIDEVICEINSTANCEW), .guidInstance = expect_guid_product, .guidProduct = expect_guid_product, - .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_LIMITED << 8)|DI8DEVTYPE_JOYSTICK, + .dwDevType = version >= 0x800 ? DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_LIMITED << 8)|DI8DEVTYPE_JOYSTICK + : DIDEVTYPE_HID|(DIDEVTYPEJOYSTICK_UNKNOWN << 8)|DIDEVTYPE_JOYSTICK, .tszInstanceName = L"Wine test root driver", .tszProductName = L"Wine test root driver", .guidFFDriver = GUID_NULL, @@ -5257,7 +5263,8 @@ static BOOL test_device_types(void) .dwSize = sizeof(DIDEVICEINSTANCEW), .guidInstance = expect_guid_product, .guidProduct = expect_guid_product, - .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEGAMEPAD_STANDARD << 8)|DI8DEVTYPE_GAMEPAD, + .dwDevType = version >= 0x800 ? DIDEVTYPE_HID|(DI8DEVTYPEGAMEPAD_STANDARD << 8)|DI8DEVTYPE_GAMEPAD + : DIDEVTYPE_HID|(DIDEVTYPEJOYSTICK_GAMEPAD << 8)|DIDEVTYPE_JOYSTICK, .tszInstanceName = L"Wine test root driver", .tszProductName = L"Wine test root driver", .guidFFDriver = GUID_NULL, @@ -5268,7 +5275,8 @@ static BOOL test_device_types(void) .dwSize = sizeof(DIDEVICEINSTANCEW), .guidInstance = expect_guid_product, .guidProduct = expect_guid_product, - .dwDevType = DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_STANDARD << 8)|DI8DEVTYPE_JOYSTICK, + .dwDevType = version >= 0x800 ? DIDEVTYPE_HID|(DI8DEVTYPEJOYSTICK_STANDARD << 8)|DI8DEVTYPE_JOYSTICK + : DIDEVTYPE_HID|(DIDEVTYPEJOYSTICK_UNKNOWN << 8)|DIDEVTYPE_JOYSTICK, .tszInstanceName = L"Wine test root driver", .tszProductName = L"Wine test root driver", .guidFFDriver = GUID_NULL, @@ -5285,6 +5293,8 @@ static BOOL test_device_types(void) ULONG i, ref; HRESULT hr;
+ winetest_push_context( "version %#x", version ); + for (i = 0; i < ARRAY_SIZE(device_desc) && success; ++i) { winetest_push_context( "desc[%d]", i ); @@ -5300,7 +5310,7 @@ static BOOL test_device_types(void) goto done; }
- if (FAILED(hr = create_dinput_device( DIRECTINPUT_VERSION, &devinst, &device ))) + if (FAILED(hr = create_dinput_device( version, &devinst, &device ))) { success = FALSE; goto done; @@ -5312,6 +5322,7 @@ static BOOL test_device_types(void) todo_wine check_member_guid( devinst, expect_devinst[i], guidInstance ); check_member_guid( devinst, expect_devinst[i], guidProduct ); + todo_wine_if( version <= 0x700 && i == 3 ) check_member( devinst, expect_devinst[i], "%#x", dwDevType ); todo_wine check_member_wstr( devinst, expect_devinst[i], tszInstanceName ); @@ -5325,6 +5336,7 @@ static BOOL test_device_types(void) ok( hr == DI_OK, "GetCapabilities returned %#x\n", hr ); check_member( caps, expect_caps[i], "%d", dwSize ); check_member( caps, expect_caps[i], "%#x", dwFlags ); + todo_wine_if( version <= 0x700 && i == 3 ) check_member( caps, expect_caps[i], "%#x", dwDevType ); check_member( caps, expect_caps[i], "%d", dwAxes ); check_member( caps, expect_caps[i], "%d", dwButtons ); @@ -5345,6 +5357,8 @@ static BOOL test_device_types(void) winetest_pop_context(); }
+ winetest_pop_context(); + return success; }
@@ -7753,8 +7767,11 @@ START_TEST( hid ) test_hid_driver( 1, TRUE );
CoInitialize( NULL ); - if (test_device_types()) + if (test_device_types( 0x800 )) { + test_device_types( 0x500 ); + test_device_types( 0x700 ); + test_simple_joystick(); test_force_feedback_joystick( 0x500 ); test_force_feedback_joystick( 0x700 );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/hid.c | 111 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 74f07c65498..39981026acb 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3455,6 +3455,13 @@ static BOOL CALLBACK check_created_effect_objects( IDirectInputEffect *effect, v return DIENUM_CONTINUE; }
+static BOOL CALLBACK enum_device_count( const DIDEVICEINSTANCEW *devinst, void *context ) +{ + DWORD *count = context; + *count = *count + 1; + return DIENUM_CONTINUE; +} + static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, IDirectInputDevice8W **device ) { DIPROPDWORD prop_dword = @@ -3468,8 +3475,8 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, }; IDirectInput8W *di8; IDirectInputW *di; + ULONG ref, count; HRESULT hr; - ULONG ref;
if (version >= 0x800) { @@ -3490,6 +3497,57 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, return DIERR_DEVICENOTREG; }
+ hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_ALL, NULL, NULL, DIEDFL_ALLDEVICES ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); + hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_ALL, enum_device_count, &count, 0xdeadbeef ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); + hr = IDirectInput8_EnumDevices( di8, 0xdeadbeef, enum_device_count, &count, DIEDFL_ALLDEVICES ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); + + count = 0; + hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_ALL, enum_device_count, &count, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + ok( count == 3, "got count %u, expected 0\n", count ); + count = 0; + hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_DEVICE, enum_device_count, &count, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + ok( count == 0, "got count %u, expected 0\n", count ); + count = 0; + hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_POINTER, enum_device_count, &count, + DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + todo_wine + ok( count == 3, "got count %u, expected 3\n", count ); + count = 0; + hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_KEYBOARD, enum_device_count, &count, + DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + todo_wine + ok( count == 3, "got count %u, expected 3\n", count ); + count = 0; + hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_GAMECTRL, enum_device_count, &count, + DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + ok( count == 1, "got count %u, expected 1\n", count ); + + count = 0; + hr = IDirectInput8_EnumDevices( di8, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + todo_wine + ok( count == 1, "got count %u, expected 1\n", count ); + + count = 0; + hr = IDirectInput8_EnumDevices( di8, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_FORCEFEEDBACK ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + if (IsEqualGUID( &devinst->guidFFDriver, &GUID_NULL )) ok( count == 0, "got count %u, expected 0\n", count ); + else todo_wine ok( count == 1, "got count %u, expected 1\n", count ); + + count = 0; + hr = IDirectInput8_EnumDevices( di8, (devinst->dwDevType & 0xff) + 1, enum_device_count, &count, DIEDFL_ALLDEVICES ); + if ((devinst->dwDevType & 0xff) != DI8DEVTYPE_SUPPLEMENTAL) ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + else ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); + ok( count == 0, "got count %u, expected 0\n", count ); + hr = IDirectInput8_CreateDevice( di8, &devinst->guidInstance, NULL, NULL ); ok( hr == E_POINTER, "CreateDevice returned %#x\n", hr ); hr = IDirectInput8_CreateDevice( di8, NULL, device, NULL ); @@ -3537,6 +3595,57 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, return DIERR_DEVICENOTREG; }
+ hr = IDirectInput_EnumDevices( di, 0, NULL, NULL, DIEDFL_ALLDEVICES ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); + hr = IDirectInput_EnumDevices( di, 0, enum_device_count, &count, 0xdeadbeef ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); + hr = IDirectInput_EnumDevices( di, 0xdeadbeef, enum_device_count, &count, DIEDFL_ALLDEVICES ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); + hr = IDirectInput_EnumDevices( di, 0, enum_device_count, &count, DIEDFL_INCLUDEHIDDEN ); + todo_wine + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); + + count = 0; + hr = IDirectInput_EnumDevices( di, 0, enum_device_count, &count, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + ok( count == 3, "got count %u, expected 0\n", count ); + count = 0; + hr = IDirectInput_EnumDevices( di, DIDEVTYPE_DEVICE, enum_device_count, &count, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + ok( count == 0, "got count %u, expected 0\n", count ); + count = 0; + hr = IDirectInput_EnumDevices( di, DIDEVTYPE_MOUSE, enum_device_count, &count, + DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + todo_wine + ok( count == 3, "got count %u, expected 3\n", count ); + count = 0; + hr = IDirectInput_EnumDevices( di, DIDEVTYPE_KEYBOARD, enum_device_count, &count, + DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + todo_wine + ok( count == 3, "got count %u, expected 3\n", count ); + count = 0; + hr = IDirectInput_EnumDevices( di, DIDEVTYPE_JOYSTICK, enum_device_count, &count, + DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + ok( count == 1, "got count %u, expected 1\n", count ); + + count = 0; + hr = IDirectInput_EnumDevices( di, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + ok( count == 1, "got count %u, expected 1\n", count ); + + count = 0; + hr = IDirectInput_EnumDevices( di, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_FORCEFEEDBACK ); + ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); + if (IsEqualGUID( &devinst->guidFFDriver, &GUID_NULL )) todo_wine ok( count == 0, "got count %u, expected 0\n", count ); + else ok( count == 1, "got count %u, expected 1\n", count ); + + hr = IDirectInput_EnumDevices( di, 0x14, enum_device_count, &count, DIEDFL_ALLDEVICES ); + todo_wine + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); + hr = IDirectInput_CreateDevice( di, &expect_guid_product, (IDirectInputDeviceW **)device, NULL ); ok( hr == DI_OK, "CreateDevice returned %#x\n", hr );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=101888
Your paranoid android.
=== w8 (32 bit report) ===
dinput8: hid.c:4924: Test failed: state[0]: WaitForSingleObject succeeded
=== debiant2 (32 bit report) ===
Report validation errors: dinput8:hid prints too much data (32922 bytes)
=== debiant2 (64 bit WoW report) ===
Report validation errors: dinput8:hid prints too much data (32970 bytes)
Instead of the other way around.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 66 ++++++++++++++++++++++----------------- dlls/dinput8/tests/hid.c | 2 -- 2 files changed, 37 insertions(+), 31 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 835a8656bd1..f53a1b502e9 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -315,39 +315,17 @@ __ASM_GLOBAL_FUNC( enum_callback_wrapper, static HRESULT WINAPI IDirectInputWImpl_EnumDevices( IDirectInput7W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback, void *context, DWORD flags ) { - DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); - unsigned int i = 0; - HRESULT hr;
TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x\n", iface, type, callback, context, flags );
if (!callback) return DIERR_INVALIDPARAM;
- if ((type > DI8DEVCLASS_GAMECTRL && type < DI8DEVTYPE_DEVICE) || type > DI8DEVTYPE_SUPPLEMENTAL) - return DIERR_INVALIDPARAM; - if (flags & ~(DIEDFL_ATTACHEDONLY|DIEDFL_FORCEFEEDBACK|DIEDFL_INCLUDEALIASES|DIEDFL_INCLUDEPHANTOMS|DIEDFL_INCLUDEHIDDEN)) + if (type > DIDEVTYPE_JOYSTICK) return DIERR_INVALIDPARAM; + if (flags & ~(DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK | DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS)) return DIERR_INVALIDPARAM;
- if (!impl->initialized) - return DIERR_NOTINITIALIZED; - - hr = mouse_enum_device( type, flags, &instance, impl->dwVersion, 0 ); - if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) - return DI_OK; - hr = keyboard_enum_device( type, flags, &instance, impl->dwVersion, 0 ); - if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) - return DI_OK; - - do - { - hr = hid_joystick_enum_device( type, flags, &instance, impl->dwVersion, i++ ); - if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) - return DI_OK; - } - while (SUCCEEDED(hr)); - - return DI_OK; + return IDirectInput8_EnumDevices( &impl->IDirectInput8W_iface, type, callback, context, flags ); }
static ULONG WINAPI IDirectInputWImpl_AddRef( IDirectInput7W *iface ) @@ -659,11 +637,41 @@ static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REF return IDirectInput7_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, &IID_IDirectInputDevice8W, (LPVOID *)pdev, punk ); }
-static HRESULT WINAPI IDirectInput8WImpl_EnumDevices(LPDIRECTINPUT8W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, - LPVOID pvRef, DWORD dwFlags) +static HRESULT WINAPI IDirectInput8WImpl_EnumDevices( IDirectInput8W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback, + void *context, DWORD flags ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput_EnumDevices( &This->IDirectInput7W_iface, dwDevType, lpCallback, pvRef, dwFlags ); + DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); + unsigned int i = 0; + HRESULT hr; + + TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x\n", iface, type, callback, context, flags ); + + if (!callback) return DIERR_INVALIDPARAM; + + if ((type > DI8DEVCLASS_GAMECTRL && type < DI8DEVTYPE_DEVICE) || type > DI8DEVTYPE_SUPPLEMENTAL) + return DIERR_INVALIDPARAM; + if (flags & ~(DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK | DIEDFL_INCLUDEALIASES | + DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN)) + return DIERR_INVALIDPARAM; + + if (!impl->initialized) return DIERR_NOTINITIALIZED; + + hr = mouse_enum_device( type, flags, &instance, impl->dwVersion, 0 ); + if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) + return DI_OK; + hr = keyboard_enum_device( type, flags, &instance, impl->dwVersion, 0 ); + if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) + return DI_OK; + + do + { + hr = hid_joystick_enum_device( type, flags, &instance, impl->dwVersion, i++ ); + if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) + return DI_OK; + } while (SUCCEEDED(hr)); + + return DI_OK; }
static HRESULT WINAPI IDirectInput8WImpl_GetDeviceStatus(LPDIRECTINPUT8W iface, REFGUID rguid) diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 39981026acb..977bd04db10 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3602,7 +3602,6 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, hr = IDirectInput_EnumDevices( di, 0xdeadbeef, enum_device_count, &count, DIEDFL_ALLDEVICES ); ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr ); hr = IDirectInput_EnumDevices( di, 0, enum_device_count, &count, DIEDFL_INCLUDEHIDDEN ); - todo_wine ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
count = 0; @@ -3643,7 +3642,6 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, else ok( count == 1, "got count %u, expected 1\n", count );
hr = IDirectInput_EnumDevices( di, 0x14, enum_device_count, &count, DIEDFL_ALLDEVICES ); - todo_wine ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
hr = IDirectInput_CreateDevice( di, &expect_guid_product, (IDirectInputDeviceW **)device, NULL );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index f53a1b502e9..f2526f25972 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -926,12 +926,24 @@ static HRESULT WINAPI JoyConfig8Impl_DeleteType(IDirectInputJoyConfig8 *iface, L return E_NOTIMPL; }
+struct find_device_from_index_params +{ + UINT index; + DIDEVICEINSTANCEW instance; +}; + +static BOOL CALLBACK find_device_from_index( const DIDEVICEINSTANCEW *instance, void *context ) +{ + struct find_device_from_index_params *params = context; + params->instance = *instance; + if (!params->index--) return DIENUM_STOP; + return DIENUM_CONTINUE; +} + static HRESULT WINAPI JoyConfig8Impl_GetConfig(IDirectInputJoyConfig8 *iface, UINT id, LPDIJOYCONFIG info, DWORD flags) { - DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; IDirectInputImpl *di = impl_from_IDirectInputJoyConfig8(iface); - unsigned int i = 0; - UINT found = 0; + struct find_device_from_index_params params = {.index = id}; HRESULT hr;
FIXME("(%p)->(%d, %p, 0x%08x): semi-stub!\n", iface, id, info, flags); @@ -943,16 +955,11 @@ static HRESULT WINAPI JoyConfig8Impl_GetConfig(IDirectInputJoyConfig8 *iface, UI X(DIJC_CALLOUT) #undef X
- do - { - hr = hid_joystick_enum_device( DI8DEVCLASS_GAMECTRL, 0, &instance, di->dwVersion, i++ ); - if (hr != DI_OK) continue; - if (flags & DIJC_GUIDINSTANCE) info->guidInstance = instance.guidInstance; - /* Only take into account the chosen id */ - if (found++ == id) return DI_OK; - } while (SUCCEEDED(hr)); - - return DIERR_NOMOREITEMS; + hr = IDirectInput8_EnumDevices( &di->IDirectInput8W_iface, DI8DEVCLASS_GAMECTRL, find_device_from_index, ¶ms, 0 ); + if (FAILED(hr)) return hr; + if (params.index != ~0) return DIERR_NOMOREITEMS; + if (flags & DIJC_GUIDINSTANCE) info->guidInstance = params.instance.guidInstance; + return DI_OK; }
static HRESULT WINAPI JoyConfig8Impl_SetConfig(IDirectInputJoyConfig8 *iface, UINT id, LPCDIJOYCONFIG info, DWORD flags)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 56 ++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 18 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index f2526f25972..b866d4b5c3a 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -751,12 +751,38 @@ static BOOL should_enumerate_device(const WCHAR *username, DWORD dwFlags, return should_enumerate; }
+struct enum_device_by_semantics_params +{ + IDirectInput8W *iface; + const WCHAR *username; + DWORD flags; + + DIDEVICEINSTANCEW *instances; + DWORD instance_count; +}; + +static BOOL CALLBACK enum_device_by_semantics( const DIDEVICEINSTANCEW *instance, void *context ) +{ + struct enum_device_by_semantics_params *params = context; + IDirectInputImpl *This = impl_from_IDirectInput8W( params->iface ); + + if (should_enumerate_device( params->username, params->flags, &This->device_players, &instance->guidInstance )) + { + params->instance_count++; + params->instances = realloc( params->instances, sizeof(DIDEVICEINSTANCEW) * params->instance_count ); + params->instances[params->instance_count - 1] = *instance; + } + + return DIENUM_CONTINUE; +} + static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( LPDIRECTINPUT8W iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags ) { + struct enum_device_by_semantics_params params = {.iface = iface, .username = ptszUserName, .flags = dwFlags}; static REFGUID guids[2] = { &GUID_SysKeyboard, &GUID_SysMouse }; static const DWORD actionMasks[] = { DIKEYBOARD_MASK, DIMOUSE_MASK }; IDirectInputImpl *This = impl_from_IDirectInput8W(iface); @@ -765,28 +791,22 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( DWORD callbackFlags; unsigned int i = 0; HRESULT hr; - int device_count = 0; int remain; - DIDEVICEINSTANCEW *didevis = 0;
FIXME("(this=%p,%s,%p,%p,%p,%04x): semi-stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat, lpCallback, pvRef, dwFlags);
didevi.dwSize = sizeof(didevi);
- do + hr = IDirectInput8_EnumDevices( &This->IDirectInput8W_iface, DI8DEVCLASS_GAMECTRL, + enum_device_by_semantics, ¶ms, DIEDFL_ATTACHEDONLY | dwFlags ); + if (FAILED(hr)) { - hr = hid_joystick_enum_device( DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, i++ ); - if (hr != DI_OK) continue; - if (should_enumerate_device( ptszUserName, dwFlags, &This->device_players, &didevi.guidInstance )) - { - device_count++; - didevis = realloc( didevis, sizeof(DIDEVICEINSTANCEW) * device_count ); - didevis[device_count - 1] = didevi; - } - } while (SUCCEEDED(hr)); + free( params.instances ); + return hr; + }
- remain = device_count; + remain = params.instance_count; /* Add keyboard and mouse to remaining device count */ if (!(dwFlags & DIEDBSFL_FORCEFEEDBACK)) { @@ -797,21 +817,21 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( } }
- for (i = 0; i < device_count; i++) + for (i = 0; i < params.instance_count; i++) { callbackFlags = diactionformat_priorityW(lpdiActionFormat, lpdiActionFormat->dwGenre); - IDirectInput_CreateDevice(iface, &didevis[i].guidInstance, &lpdid, NULL); + IDirectInput_CreateDevice( iface, ¶ms.instances[i].guidInstance, &lpdid, NULL );
- if (lpCallback(&didevis[i], lpdid, callbackFlags, --remain, pvRef) == DIENUM_STOP) + if (lpCallback( ¶ms.instances[i], lpdid, callbackFlags, --remain, pvRef ) == DIENUM_STOP) { - free( didevis ); + free( params.instances ); IDirectInputDevice_Release(lpdid); return DI_OK; } IDirectInputDevice_Release(lpdid); }
- free( didevis ); + free( params.instances );
if (dwFlags & DIEDBSFL_FORCEFEEDBACK) return DI_OK;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=101891
Your paranoid android.
=== debiant2 (32 bit report) ===
dinput8: dinput.c:556: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:557: Test failed: There should be devices available before action mapping available=0 dinput.c:566: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:576: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:587: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:593: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:599: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:605: Test failed: EnumDevicesBySemantics failed hr=80070057
=== debiant2 (32 bit Chinese:China report) ===
dinput8: dinput.c:556: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:557: Test failed: There should be devices available before action mapping available=0 dinput.c:566: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:576: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:587: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:593: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:599: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:605: Test failed: EnumDevicesBySemantics failed hr=80070057
=== debiant2 (32 bit WoW report) ===
dinput8: dinput.c:556: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:557: Test failed: There should be devices available before action mapping available=0 dinput.c:566: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:576: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:587: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:593: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:599: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:605: Test failed: EnumDevicesBySemantics failed hr=80070057
=== debiant2 (64 bit WoW report) ===
dinput8: dinput.c:556: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:557: Test failed: There should be devices available before action mapping available=0 dinput.c:566: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:576: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:587: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:593: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:599: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:605: Test failed: EnumDevicesBySemantics failed hr=80070057
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 43 +++++++++++++++++++++++++++--------- dlls/dinput/dinput_private.h | 4 ++-- dlls/dinput/joystick_hid.c | 7 ------ dlls/dinput/keyboard.c | 16 +++----------- dlls/dinput/mouse.c | 16 +++----------- dlls/dinput8/tests/hid.c | 5 ++--- 6 files changed, 43 insertions(+), 48 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index b866d4b5c3a..5808754b9a7 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -637,11 +637,21 @@ static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REF return IDirectInput7_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, &IID_IDirectInputDevice8W, (LPVOID *)pdev, punk ); }
+static BOOL try_enum_device( DWORD type, LPDIENUMDEVICESCALLBACKW callback, + DIDEVICEINSTANCEW *instance, void *context, DWORD flags ) +{ + if (type && (instance->dwDevType & 0xff) != type) return DIENUM_CONTINUE; + if ((flags & DIEDFL_FORCEFEEDBACK) && IsEqualGUID( &instance->guidFFDriver, &GUID_NULL )) + return DIENUM_CONTINUE; + return enum_callback_wrapper( callback, instance, context ); +} + static HRESULT WINAPI IDirectInput8WImpl_EnumDevices( IDirectInput8W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback, void *context, DWORD flags ) { DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); + DWORD device_class = 0, device_type = 0; unsigned int i = 0; HRESULT hr;
@@ -657,19 +667,32 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevices( IDirectInput8W *iface, DWO
if (!impl->initialized) return DIERR_NOTINITIALIZED;
- hr = mouse_enum_device( type, flags, &instance, impl->dwVersion, 0 ); - if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) - return DI_OK; - hr = keyboard_enum_device( type, flags, &instance, impl->dwVersion, 0 ); - if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) - return DI_OK; + if (type <= DI8DEVCLASS_GAMECTRL) device_class = type; + else device_type = type;
- do + if (device_class == DI8DEVCLASS_ALL || device_class == DI8DEVCLASS_POINTER) { - hr = hid_joystick_enum_device( type, flags, &instance, impl->dwVersion, i++ ); - if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) + hr = mouse_enum_device( type, flags, &instance, impl->dwVersion ); + if (hr == DI_OK && try_enum_device( device_type, callback, &instance, context, flags ) == DIENUM_STOP) return DI_OK; - } while (SUCCEEDED(hr)); + } + + if (device_class == DI8DEVCLASS_ALL || device_class == DI8DEVCLASS_KEYBOARD) + { + hr = keyboard_enum_device( type, flags, &instance, impl->dwVersion ); + if (hr == DI_OK && try_enum_device( device_type, callback, &instance, context, flags ) == DIENUM_STOP) + return DI_OK; + } + + if (device_class == DI8DEVCLASS_ALL || device_class == DI8DEVCLASS_GAMECTRL) + { + do + { + hr = hid_joystick_enum_device( type, flags, &instance, impl->dwVersion, i++ ); + if (hr == DI_OK && try_enum_device( device_type, callback, &instance, context, flags ) == DIENUM_STOP) + return DI_OK; + } while (SUCCEEDED(hr)); + }
return DI_OK; } diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index a9777dc8dbb..c25fe6320ca 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -52,9 +52,9 @@ struct IDirectInputImpl extern const IDirectInput7AVtbl dinput7_a_vtbl DECLSPEC_HIDDEN; extern const IDirectInput8AVtbl dinput8_a_vtbl DECLSPEC_HIDDEN;
-extern HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version ); extern HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); -extern HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version ); extern HRESULT keyboard_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); extern HRESULT hid_joystick_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); extern HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 67a43924e19..1d57f2c4b21 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1420,13 +1420,6 @@ HRESULT hid_joystick_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *in HidD_FreePreparsedData( preparsed ); CloseHandle( device );
- if (instance->dwSize != sizeof(DIDEVICEINSTANCEW)) - return S_FALSE; - if (version < 0x0800 && type != 0 && type != DIDEVTYPE_JOYSTICK) - return S_FALSE; - if (version >= 0x0800 && type != DI8DEVCLASS_ALL && type != DI8DEVCLASS_GAMECTRL) - return S_FALSE; - TRACE( "found device %s, usage %04x:%04x, product %s, instance %s, name %s\n", debugstr_w(device_path), instance->wUsagePage, instance->wUsage, debugstr_guid( &instance->guidProduct ), debugstr_guid( &instance->guidInstance ), debugstr_w(instance->tszInstanceName) ); diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index ef125176ecb..f906e32a59d 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -144,22 +144,12 @@ static DWORD get_keyboard_subtype(void) return dev_subtype; }
-HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ) +HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version ) { BYTE subtype = get_keyboard_subtype(); DWORD size;
- TRACE( "type %#x, flags %#x, instance %p, version %#04x, index %d\n", type, flags, instance, version, index ); - - if (index != 0) return DIERR_GENERIC; - if (flags & DIEDFL_FORCEFEEDBACK) return DI_NOEFFECT; - if (version < 0x0800 && type != 0 && type != DIDEVTYPE_KEYBOARD) return DI_NOEFFECT; - if (version >= 0x0800 && type != DI8DEVCLASS_ALL && type != DI8DEVCLASS_KEYBOARD && type != DI8DEVTYPE_KEYBOARD) - return DI_NOEFFECT; - - if (instance->dwSize != sizeof(DIDEVICEINSTANCEW) && - instance->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) - return DIERR_INVALIDPARAM; + TRACE( "type %#x, flags %#x, instance %p, version %#04x\n", type, flags, instance, version );
size = instance->dwSize; memset( instance, 0, size ); @@ -188,7 +178,7 @@ HRESULT keyboard_create_device( IDirectInputImpl *dinput, const GUID *guid, IDir return hr; impl->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": struct keyboard*->base.crit");
- keyboard_enum_device( 0, 0, &impl->base.instance, dinput->dwVersion, 0 ); + keyboard_enum_device( 0, 0, &impl->base.instance, dinput->dwVersion ); impl->base.caps.dwDevType = impl->base.instance.dwDevType; impl->base.caps.dwFirmwareRevision = 100; impl->base.caps.dwHardwareRevision = 100; diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 628011c13e1..1b45c8d5fd4 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -72,21 +72,11 @@ static inline struct mouse *impl_from_IDirectInputDevice8W( IDirectInputDevice8W return CONTAINING_RECORD( CONTAINING_RECORD( iface, struct dinput_device, IDirectInputDevice8W_iface ), struct mouse, base ); }
-HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ) +HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version ) { DWORD size;
- TRACE( "type %#x, flags %#x, instance %p, version %#04x, index %d\n", type, flags, instance, version, index ); - - if (index != 0) return DIERR_GENERIC; - if (flags & DIEDFL_FORCEFEEDBACK) return DI_NOEFFECT; - if (version < 0x0800 && type != 0 && type != DIDEVTYPE_MOUSE) return DI_NOEFFECT; - if (version >= 0x0800 && type != DI8DEVCLASS_ALL && type != DI8DEVCLASS_POINTER && type != DI8DEVTYPE_MOUSE) - return DI_NOEFFECT; - - if (instance->dwSize != sizeof(DIDEVICEINSTANCEW) && - instance->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) - return DIERR_INVALIDPARAM; + TRACE( "type %#x, flags %#x, instance %p, version %#04x\n", type, flags, instance, version );
size = instance->dwSize; memset( instance, 0, size ); @@ -117,7 +107,7 @@ HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirect return hr; impl->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": struct mouse*->base.crit");
- mouse_enum_device( 0, 0, &impl->base.instance, dinput->dwVersion, 0 ); + mouse_enum_device( 0, 0, &impl->base.instance, dinput->dwVersion ); impl->base.caps.dwDevType = impl->base.instance.dwDevType; impl->base.caps.dwFirmwareRevision = 100; impl->base.caps.dwHardwareRevision = 100; diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 977bd04db10..1462c78685f 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3533,14 +3533,13 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, count = 0; hr = IDirectInput8_EnumDevices( di8, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_ALLDEVICES ); ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); - todo_wine ok( count == 1, "got count %u, expected 1\n", count );
count = 0; hr = IDirectInput8_EnumDevices( di8, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_FORCEFEEDBACK ); ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); if (IsEqualGUID( &devinst->guidFFDriver, &GUID_NULL )) ok( count == 0, "got count %u, expected 0\n", count ); - else todo_wine ok( count == 1, "got count %u, expected 1\n", count ); + else ok( count == 1, "got count %u, expected 1\n", count );
count = 0; hr = IDirectInput8_EnumDevices( di8, (devinst->dwDevType & 0xff) + 1, enum_device_count, &count, DIEDFL_ALLDEVICES ); @@ -3638,7 +3637,7 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, count = 0; hr = IDirectInput_EnumDevices( di, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_FORCEFEEDBACK ); ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr ); - if (IsEqualGUID( &devinst->guidFFDriver, &GUID_NULL )) todo_wine ok( count == 0, "got count %u, expected 0\n", count ); + if (IsEqualGUID( &devinst->guidFFDriver, &GUID_NULL )) ok( count == 0, "got count %u, expected 0\n", count ); else ok( count == 1, "got count %u, expected 1\n", count );
hr = IDirectInput_EnumDevices( di, 0x14, enum_device_count, &count, DIEDFL_ALLDEVICES );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=101892
Your paranoid android.
=== w8 (32 bit report) ===
dinput8: hid.c:4921: Test failed: state[0]: WaitForSingleObject succeeded
=== debiant2 (32 bit report) ===
dinput8: dinput.c:556: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:557: Test failed: There should be devices available before action mapping available=0 dinput.c:566: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:576: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:587: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:593: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:599: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:605: Test failed: EnumDevicesBySemantics failed hr=80070057
=== debiant2 (32 bit Chinese:China report) ===
dinput8: dinput.c:556: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:557: Test failed: There should be devices available before action mapping available=0 dinput.c:566: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:576: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:587: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:593: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:599: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:605: Test failed: EnumDevicesBySemantics failed hr=80070057
=== debiant2 (32 bit WoW report) ===
dinput8: dinput.c:556: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:557: Test failed: There should be devices available before action mapping available=0 dinput.c:566: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:576: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:587: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:593: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:599: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:605: Test failed: EnumDevicesBySemantics failed hr=80070057
=== debiant2 (64 bit WoW report) ===
dinput8: dinput.c:556: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:557: Test failed: There should be devices available before action mapping available=0 dinput.c:566: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:576: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:587: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:593: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:599: Test failed: EnumDevicesBySemantics failed hr=80070057 dinput.c:605: Test failed: EnumDevicesBySemantics failed hr=80070057