dinput: Return correct errors from HID joystick IDirectInputDevice8_GetDeviceState.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-09-21 09:52:48 +02:00 committed by Alexandre Julliard
parent 78f04ca082
commit aa43d24cd8
2 changed files with 7 additions and 4 deletions

View File

@ -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,

View File

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