Rémi Bernon : dinput: Return correct errors from HID joystick IDirectInputDevice8_GetDeviceState.
Alexandre Julliard
julliard at winehq.org
Tue Sep 21 15:59:02 CDT 2021
Module: wine
Branch: master
Commit: aa43d24cd8ef7cfc89193a3c896a37caf3dc9051
URL: https://source.winehq.org/git/wine.git/?a=commit;h=aa43d24cd8ef7cfc89193a3c896a37caf3dc9051
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Tue Sep 21 09:52:48 2021 +0200
dinput: Return correct errors from HID joystick IDirectInputDevice8_GetDeviceState.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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)
More information about the wine-cvs
mailing list