Module: wine Branch: master Commit: dcb84a45f69f57efeb547f11ed5a8474ee74de1e URL: https://gitlab.winehq.org/wine/wine/-/commit/dcb84a45f69f57efeb547f11ed5a847...
Author: Florian Will florian.will@gmail.com Date: Sun Apr 2 00:13:47 2023 +0200
dinput: Fix EnumObjects callback return value handling.
This solves an issue in ZUSI 3 settings for DirectInput devices. Delphi defines the True value of the "C-compatible" LongBool type as -1, which wine interpreted to mean DIENUM_STOP because it is != DIENUM_CONTINUE. Change that logic so only an explicit DIENUM_STOP (= 0) return value stops the enumeration of objects.
---
dlls/dinput/device.c | 4 +++- dlls/dinput/tests/device8.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 19c3241e51f..4db8bd943cb 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -730,7 +730,9 @@ static BOOL enum_objects_callback( struct dinput_device *impl, UINT index, struc struct enum_objects_params *params = data; if (instance->wUsagePage == HID_USAGE_PAGE_PID && !(instance->dwType & DIDFT_NODATA)) return DIENUM_CONTINUE; - return params->callback( instance, params->context ); + + /* Applications may return non-zero values instead of DIENUM_CONTINUE. */ + return params->callback( instance, params->context ) ? DIENUM_CONTINUE : DIENUM_STOP; }
static HRESULT WINAPI dinput_device_EnumObjects( IDirectInputDevice8W *iface, LPDIENUMDEVICEOBJECTSCALLBACKW callback, diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c index 128fb2992f6..a649fe53b41 100644 --- a/dlls/dinput/tests/device8.c +++ b/dlls/dinput/tests/device8.c @@ -1346,7 +1346,7 @@ static void test_sys_mouse( DWORD version ) res = 0; hr = IDirectInputDevice8_EnumObjects( device, check_object_count_bad_retval, &res, DIDFT_AXIS ); ok( hr == DI_OK, "EnumObjects returned %#lx\n", hr ); - todo_wine ok( res == 3, "got %lu expected 3\n", res ); + ok( res == 3, "got %lu expected 3\n", res );
objinst.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW); res = MAKELONG( HID_USAGE_GENERIC_X, HID_USAGE_PAGE_GENERIC );