[PATCH 3/5] dinput: Return proper error status from HID joystick GetObjectInfo.
Rémi Bernon
rbernon at codeweavers.com
Mon Sep 27 02:43:05 CDT 2021
When no object matched the enumeration or when DIPH_DEVICE is used.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/dinput/joystick_hid.c | 7 +++++--
dlls/dinput8/tests/hid.c | 4 ----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 06537e9fd25..3535e533029 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -682,6 +682,7 @@ static HRESULT WINAPI hid_joystick_GetObjectInfo( IDirectInputDevice8W *iface, D
.dwHow = how,
.dwObj = obj
};
+ BOOL ret;
TRACE( "iface %p, instance %p, obj %#x, how %#x.\n", iface, instance, obj, how );
@@ -689,9 +690,11 @@ static HRESULT WINAPI hid_joystick_GetObjectInfo( IDirectInputDevice8W *iface, D
if (instance->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3W) &&
instance->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW))
return DIERR_INVALIDPARAM;
+ if (how == DIPH_DEVICE) return DIERR_INVALIDPARAM;
- enum_objects( impl, &filter, DIDFT_ALL, get_object_info, instance );
- return S_OK;
+ ret = enum_objects( impl, &filter, DIDFT_ALL, get_object_info, instance );
+ if (ret != DIENUM_CONTINUE) return DI_OK;
+ return DIERR_NOTFOUND;
}
static HRESULT WINAPI hid_joystick_GetDeviceInfo( IDirectInputDevice8W *iface, DIDEVICEINSTANCEW *instance )
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index d73d4dabfff..c7f5b82c187 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -3959,12 +3959,10 @@ static void test_simple_joystick(void)
ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr );
objinst.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW);
hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, 0, DIPH_DEVICE );
- todo_wine
ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr );
res = MAKELONG( HID_USAGE_GENERIC_Z, HID_USAGE_PAGE_GENERIC );
hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, res, DIPH_BYUSAGE );
- todo_wine
ok( hr == DIERR_NOTFOUND, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr );
res = MAKELONG( HID_USAGE_GENERIC_X, HID_USAGE_PAGE_GENERIC );
hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, res, DIPH_BYUSAGE );
@@ -3988,14 +3986,12 @@ static void test_simple_joystick(void)
check_member( objinst, expect_objects[1], "%u", wReportId );
hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, 0x14, DIPH_BYOFFSET );
- todo_wine
ok( hr == DIERR_NOTFOUND, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr );
hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, 0, DIPH_BYOFFSET );
todo_wine
ok( hr == DIERR_NOTFOUND, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr );
res = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( 3 );
hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, res, DIPH_BYID );
- todo_wine
ok( hr == DIERR_NOTFOUND, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr );
res = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( 1 );
hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, res, DIPH_BYID );
--
2.33.0
More information about the wine-devel
mailing list