From e990e4b232585e9f4b155ddcba898ad5c33d913e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Mon, 27 Sep 2021 09:43:05 +0200 Subject: [PATCH] dinput: Return proper error status from HID joystick GetObjectInfo. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When no object matched the enumeration or when DIPH_DEVICE is used. Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- 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 1b5fe6fd044..ade58166e27 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 );