We usually have them wrong but sometimes right.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/hid.c | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index b02cdf1aa30..e5e1bfde79d 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -4214,8 +4214,6 @@ static void test_simple_joystick(void) ok( res == 1, "got %u expected %u\n", res, 1 ); check_member( objdata[0], expect_objdata[0], "%#x", dwOfs ); check_member( objdata[0], expect_objdata[0], "%#x", dwData ); - todo_wine - check_member( objdata[0], expect_objdata[0], "%#x", dwSequence ); ok( objdata[0].uAppData == -1, "got %p, expected %p\n", (void *)objdata[0].uAppData, (void *)-1 ); res = 4; hr = IDirectInputDevice8_GetDeviceData( device, sizeof(DIDEVICEOBJECTDATA), objdata, &res, 0 ); @@ -4226,8 +4224,6 @@ static void test_simple_joystick(void) winetest_push_context( "objdata[%d]", i ); check_member( objdata[i], expect_objdata[1 + i], "%#x", dwOfs ); check_member( objdata[i], expect_objdata[1 + i], "%#x", dwData ); - todo_wine - check_member( objdata[i], expect_objdata[1 + i], "%#x", dwSequence ); ok( objdata[i].uAppData == -1, "got %p, expected %p\n", (void *)objdata[i].uAppData, (void *)-1 ); winetest_pop_context(); }
This adds some todo_wine because we now get the correct object, but it has incorrect offset and instance number.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 3 ++- dlls/dinput8/tests/hid.c | 12 +++--------- 2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index a9ca6fe6cc6..fb0d769d85f 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -209,7 +209,8 @@ static BOOL enum_object( struct hid_joystick *impl, const DIPROPHEADER *filter, if ((filter->dwObj & 0x00ffffff) != (instance->dwType & 0x00ffffff)) return DIENUM_CONTINUE; return callback( impl, caps, instance, data ); case DIPH_BYUSAGE: - if (LOWORD(filter->dwObj) != instance->wUsagePage || HIWORD(filter->dwObj) != instance->wUsage) return DIENUM_CONTINUE; + if (HIWORD( filter->dwObj ) != instance->wUsagePage) return DIENUM_CONTINUE; + if (LOWORD( filter->dwObj ) != instance->wUsage) return DIENUM_CONTINUE; return callback( impl, caps, instance, data ); default: FIXME( "unimplemented filter dwHow %#x dwObj %#x\n", filter->dwHow, filter->dwObj ); diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index e5e1bfde79d..1afb2916d4d 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3919,9 +3919,7 @@ static void test_simple_joystick(void) prop_range.lMax = 0xdeadbeef; hr = IDirectInputDevice8_GetProperty( device, DIPROP_RANGE, &prop_range.diph ); ok( hr == DI_OK, "IDirectInputDevice8_GetProperty DIPROP_RANGE returned %#x\n", hr ); - todo_wine ok( prop_range.lMin == 0, "got %d expected %d\n", prop_range.lMin, 0 ); - todo_wine ok( prop_range.lMax == 65535, "got %d expected %d\n", prop_range.lMax, 65535 );
prop_pointer.diph.dwHow = DIPH_BYUSAGE; @@ -3962,9 +3960,10 @@ static void test_simple_joystick(void) ok( hr == DI_OK, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr );
check_member( objinst, expect_objects[1], "%u", dwSize ); - todo_wine check_member_guid( objinst, expect_objects[1], guidType ); + todo_wine check_member( objinst, expect_objects[1], "%#x", dwOfs ); + todo_wine check_member( objinst, expect_objects[1], "%#x", dwType ); check_member( objinst, expect_objects[1], "%#x", dwFlags ); if (!localized) todo_wine check_member_wstr( objinst, expect_objects[1], tszName ); @@ -3974,7 +3973,6 @@ static void test_simple_joystick(void) check_member( objinst, expect_objects[1], "%u", wCollectionNumber ); check_member( objinst, expect_objects[1], "%u", wDesignatorIndex ); check_member( objinst, expect_objects[1], "%#04x", wUsagePage ); - todo_wine check_member( objinst, expect_objects[1], "%#04x", wUsage ); check_member( objinst, expect_objects[1], "%#04x", dwDimension ); check_member( objinst, expect_objects[1], "%#04x", wExponent ); @@ -4310,9 +4308,7 @@ static void test_simple_joystick(void) prop_range.lMax = 0xdeadbeef; hr = IDirectInputDevice8_GetProperty( device, DIPROP_RANGE, &prop_range.diph ); ok( hr == DI_OK, "IDirectInputDevice8_GetProperty DIPROP_RANGE returned %#x\n", hr ); - todo_wine ok( prop_range.lMin == -14000, "got %d expected %d\n", prop_range.lMin, -14000 ); - todo_wine ok( prop_range.lMax == -4000, "got %d expected %d\n", prop_range.lMax, -4000 ); prop_range.diph.dwHow = DIPH_BYUSAGE; prop_range.diph.dwObj = MAKELONG( HID_USAGE_GENERIC_Y, HID_USAGE_PAGE_GENERIC ); @@ -4320,9 +4316,7 @@ static void test_simple_joystick(void) prop_range.lMax = 0xdeadbeef; hr = IDirectInputDevice8_GetProperty( device, DIPROP_RANGE, &prop_range.diph ); ok( hr == DI_OK, "IDirectInputDevice8_GetProperty DIPROP_RANGE returned %#x\n", hr ); - todo_wine ok( prop_range.lMin == 1000, "got %d expected %d\n", prop_range.lMin, 1000 ); - todo_wine ok( prop_range.lMax == 51000, "got %d expected %d\n", prop_range.lMax, 51000 );
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2), &state ); @@ -4478,7 +4472,7 @@ static void test_simple_joystick(void) if (broken( state.lX == -10750 )) win_skip( "Ignoring 32-bit rounding\n" ); else { - todo_wine + todo_wine_if( i != 2 ) check_member( state, expect_state_abs[i], "%d", lX ); todo_wine_if( i != 2 ) check_member( state, expect_state_abs[i], "%d", lY );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 9 +++++++++ dlls/dinput8/tests/hid.c | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index fb0d769d85f..9cacda6b02b 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -500,28 +500,33 @@ static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, con TRACE( "iface %p, guid %s, header %p\n", iface, debugstr_guid( guid ), header );
if (!header) return DIERR_INVALIDPARAM; + if (header->dwHeaderSize != sizeof(DIPROPHEADER)) return DIERR_INVALIDPARAM; if (!IS_DIPROP( guid )) return DI_OK;
switch (LOWORD( guid )) { case (DWORD_PTR)DIPROP_RANGE: + if (header->dwSize != sizeof(DIPROPRANGE)) return DIERR_INVALIDPARAM; enum_value_objects( impl, header, DIDFT_AXIS, get_property_prop_range, header ); return DI_OK; case (DWORD_PTR)DIPROP_PRODUCTNAME: { DIPROPSTRING *value = (DIPROPSTRING *)header; + if (header->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM; lstrcpynW( value->wsz, impl->instance.tszProductName, MAX_PATH ); return DI_OK; } case (DWORD_PTR)DIPROP_INSTANCENAME: { DIPROPSTRING *value = (DIPROPSTRING *)header; + if (header->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM; lstrcpynW( value->wsz, impl->instance.tszInstanceName, MAX_PATH ); return DI_OK; } case (DWORD_PTR)DIPROP_VIDPID: { DIPROPDWORD *value = (DIPROPDWORD *)header; + if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM; if (!impl->attrs.VendorID || !impl->attrs.ProductID) return DIERR_UNSUPPORTED; value->dwData = MAKELONG( impl->attrs.VendorID, impl->attrs.ProductID ); return DI_OK; @@ -529,12 +534,14 @@ static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, con case (DWORD_PTR)DIPROP_JOYSTICKID: { DIPROPDWORD *value = (DIPROPDWORD *)header; + if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM; value->dwData = impl->instance.guidInstance.Data3; return DI_OK; } case (DWORD_PTR)DIPROP_GUIDANDPATH: { DIPROPGUIDANDPATH *value = (DIPROPGUIDANDPATH *)header; + if (header->dwSize != sizeof(DIPROPGUIDANDPATH)) return DIERR_INVALIDPARAM; lstrcpynW( value->wszPath, impl->device_path, MAX_PATH ); return DI_OK; } @@ -566,11 +573,13 @@ static HRESULT WINAPI hid_joystick_SetProperty( IDirectInputDevice8W *iface, con TRACE( "iface %p, guid %s, header %p\n", iface, debugstr_guid( guid ), header );
if (!header) return DIERR_INVALIDPARAM; + if (header->dwHeaderSize != sizeof(DIPROPHEADER)) return DIERR_INVALIDPARAM; if (!IS_DIPROP( guid )) return DI_OK;
switch (LOWORD( guid )) { case (DWORD_PTR)DIPROP_RANGE: + if (header->dwSize != sizeof(DIPROPRANGE)) return DIERR_INVALIDPARAM; enum_value_objects( impl, header, DIDFT_AXIS, set_property_prop_range, (void *)header ); return DI_OK; default: diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 1afb2916d4d..a290072f660 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3785,11 +3785,9 @@ static void test_simple_joystick(void) hr = IDirectInputDevice8_GetProperty( device, DIPROP_VIDPID, NULL ); ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetProperty returned %#x\n", hr ); hr = IDirectInputDevice8_GetProperty( device, DIPROP_VIDPID, &prop_string.diph ); - todo_wine ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetProperty returned %#x\n", hr ); prop_dword.diph.dwHeaderSize = sizeof(DIPROPHEADER) - 1; hr = IDirectInputDevice8_GetProperty( device, DIPROP_VIDPID, &prop_dword.diph ); - todo_wine ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetProperty returned %#x\n", hr ); prop_dword.diph.dwHeaderSize = sizeof(DIPROPHEADER);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 12 ++++++++++++ dlls/dinput8/tests/hid.c | 7 ------- 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 9cacda6b02b..35a85f0f3d3 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -582,6 +582,18 @@ static HRESULT WINAPI hid_joystick_SetProperty( IDirectInputDevice8W *iface, con if (header->dwSize != sizeof(DIPROPRANGE)) return DIERR_INVALIDPARAM; enum_value_objects( impl, header, DIDFT_AXIS, set_property_prop_range, (void *)header ); return DI_OK; + case (DWORD_PTR)DIPROP_FFLOAD: + case (DWORD_PTR)DIPROP_GRANULARITY: + case (DWORD_PTR)DIPROP_VIDPID: + if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM; + return DIERR_READONLY; + case (DWORD_PTR)DIPROP_TYPENAME: + case (DWORD_PTR)DIPROP_USERNAME: + if (header->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM; + return DIERR_READONLY; + case (DWORD_PTR)DIPROP_GUIDANDPATH: + if (header->dwSize != sizeof(DIPROPGUIDANDPATH)) return DIERR_INVALIDPARAM; + return DIERR_READONLY; default: return IDirectInputDevice2WImpl_SetProperty( iface, guid, header ); } diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index a290072f660..cf4762ec86b 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -4337,17 +4337,14 @@ static void test_simple_joystick(void) hr = IDirectInputDevice8_SetProperty( device, DIPROP_VIDPID, NULL ); ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_SetProperty returned %#x\n", hr ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_VIDPID, &prop_string.diph ); - todo_wine ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_SetProperty returned %#x\n", hr );
prop_dword.diph.dwHow = DIPH_DEVICE; prop_dword.diph.dwObj = 0; prop_dword.dwData = 0xdeadbeef; hr = IDirectInputDevice8_SetProperty( device, DIPROP_VIDPID, &prop_dword.diph ); - todo_wine ok( hr == DIERR_READONLY, "IDirectInputDevice8_SetProperty DIPROP_VIDPID returned %#x\n", hr ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_GUIDANDPATH, &prop_guid_path.diph ); - todo_wine ok( hr == DIERR_READONLY, "IDirectInputDevice8_SetProperty DIPROP_GUIDANDPATH returned %#x\n", hr );
prop_string.diph.dwHow = DIPH_DEVICE; @@ -4367,16 +4364,12 @@ static void test_simple_joystick(void) debugstr_w(prop_string.wsz) );
hr = IDirectInputDevice8_SetProperty( device, DIPROP_TYPENAME, &prop_string.diph ); - todo_wine ok( hr == DIERR_READONLY, "IDirectInputDevice8_SetProperty DIPROP_TYPENAME returned %#x\n", hr ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_USERNAME, &prop_string.diph ); - todo_wine ok( hr == DIERR_READONLY, "IDirectInputDevice8_SetProperty DIPROP_USERNAME returned %#x\n", hr ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFLOAD, &prop_dword.diph ); - todo_wine ok( hr == DIERR_READONLY, "IDirectInputDevice8_SetProperty DIPROP_FFLOAD returned %#x\n", hr ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_GRANULARITY, &prop_dword.diph ); - todo_wine ok( hr == DIERR_READONLY, "IDirectInputDevice8_SetProperty DIPROP_GRANULARITY returned %#x\n", hr );
hr = IDirectInputDevice8_SetProperty( device, DIPROP_JOYSTICKID, &prop_dword.diph );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 9 +++++++-- dlls/dinput8/tests/hid.c | 2 -- 2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 35a85f0f3d3..45e75588aed 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -638,12 +638,17 @@ static HRESULT WINAPI hid_joystick_Unacquire( IDirectInputDevice8W *iface ) static HRESULT WINAPI hid_joystick_GetDeviceState( IDirectInputDevice8W *iface, DWORD len, void *ptr ) { struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface ); + HRESULT hr = DI_OK;
if (!ptr) return DIERR_INVALIDPARAM; + if (len != impl->base.data_format.user_df->dwDataSize) return DIERR_INVALIDPARAM;
- fill_DataFormat( ptr, len, &impl->state, &impl->base.data_format ); + EnterCriticalSection( &impl->base.crit ); + if (!impl->base.acquired) hr = DIERR_NOTACQUIRED; + else fill_DataFormat( ptr, len, &impl->state, &impl->base.data_format ); + LeaveCriticalSection( &impl->base.crit );
- return DI_OK; + return hr; }
static BOOL get_object_info( struct hid_joystick *impl, struct hid_caps *caps, diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index cf4762ec86b..f24acfbf70d 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -4093,7 +4093,6 @@ static void test_simple_joystick(void) ok( hr == DI_OK, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr );
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2), &state ); - todo_wine ok( hr == DIERR_NOTACQUIRED, "IDirectInputDevice8_GetDeviceState returned: %#x\n", hr );
hr = IDirectInputDevice8_Poll( device ); @@ -4107,7 +4106,6 @@ static void test_simple_joystick(void) ok( hr == DI_NOEFFECT, "IDirectInputDevice8_Poll returned: %#x\n", hr );
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2) + 1, &state ); - todo_wine ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetDeviceState returned: %#x\n", hr );
for (i = 0; i < ARRAY_SIZE(injected_input); ++i)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 14 +++++++++++++- dlls/dinput8/tests/hid.c | 1 - 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 45e75588aed..f7107733d26 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -704,6 +704,18 @@ static HRESULT WINAPI hid_joystick_GetDeviceInfo( IDirectInputDevice8W *iface, D return S_OK; }
+static HRESULT WINAPI hid_joystick_Poll( IDirectInputDevice8W *iface ) +{ + struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface ); + HRESULT hr = DI_NOEFFECT; + + EnterCriticalSection( &impl->base.crit ); + if (!impl->base.acquired) hr = DIERR_NOTACQUIRED; + LeaveCriticalSection( &impl->base.crit ); + + return hr; +} + static HRESULT WINAPI hid_joystick_BuildActionMap( IDirectInputDevice8W *iface, DIACTIONFORMATW *format, const WCHAR *username, DWORD flags ) { @@ -756,7 +768,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl = IDirectInputDevice2WImpl_SendForceFeedbackCommand, IDirectInputDevice2WImpl_EnumCreatedEffectObjects, IDirectInputDevice2WImpl_Escape, - IDirectInputDevice2WImpl_Poll, + hid_joystick_Poll, IDirectInputDevice2WImpl_SendDeviceData, /*** IDirectInputDevice7 methods ***/ IDirectInputDevice7WImpl_EnumEffectsInFile, diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index f24acfbf70d..b4aad6b7d5a 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -4102,7 +4102,6 @@ static void test_simple_joystick(void) ok( hr == DI_OK, "IDirectInputDevice8_Acquire returned: %#x\n", hr );
hr = IDirectInputDevice8_Poll( device ); - todo_wine ok( hr == DI_NOEFFECT, "IDirectInputDevice8_Poll returned: %#x\n", hr );
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2) + 1, &state );