I find this clearer, especially with respect to how device_path_guid is handled.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/dinput/joystick_hid.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 5fdc563054b..e54d50f8bfa 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2035,19 +2035,6 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi TRACE( "dinput %p, guid %s, out %p\n", dinput, debugstr_guid( guid ), out );
*out = NULL; - instance.guidProduct.Data1 = dinput_pidvid_guid.Data1; - instance.guidInstance.Data1 = hid_joystick_guid.Data1; - if (IsEqualGUID( &dinput_pidvid_guid, &instance.guidProduct )) - instance.guidProduct = *guid; - else if (IsEqualGUID( &hid_joystick_guid, &instance.guidInstance )) - instance.guidInstance = *guid; - else - { - instance.guidInstance.Data1 = device_path_guid.Data1; - instance.guidInstance.Data2 = device_path_guid.Data2; - instance.guidInstance.Data3 = device_path_guid.Data3; - if (!IsEqualGUID( &device_path_guid, &instance.guidInstance )) return DIERR_DEVICENOTREG; - }
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; dinput_device_init( &impl->base, &hid_joystick_vtbl, guid, dinput ); @@ -2056,15 +2043,31 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi impl->base.read_event = CreateEventW( NULL, TRUE, FALSE, NULL ); impl->internal_ref = 1;
- if (!IsEqualGUID( &device_path_guid, &instance.guidInstance )) + instance.guidProduct.Data1 = dinput_pidvid_guid.Data1; + instance.guidInstance.Data1 = hid_joystick_guid.Data1; + if (IsEqualGUID( &dinput_pidvid_guid, &instance.guidProduct )) + { + instance.guidProduct = *guid; hr = hid_joystick_device_open( -1, &instance, impl->device_path, &impl->device, &impl->preparsed, &attrs, &impl->caps, dinput->dwVersion ); - else + } + else if (IsEqualGUID( &hid_joystick_guid, &instance.guidInstance )) + { + instance.guidInstance = *guid; + hr = hid_joystick_device_open( -1, &instance, impl->device_path, &impl->device, &impl->preparsed, + &attrs, &impl->caps, dinput->dwVersion ); + } + else if (!memcmp( &device_path_guid.Data4, instance.guidInstance.Data4, sizeof(device_path_guid.Data4) )) { wcscpy( impl->device_path, *(const WCHAR **)guid ); hr = hid_joystick_device_try_open( 0, impl->device_path, &impl->device, &impl->preparsed, &attrs, &impl->caps, &instance, dinput->dwVersion ); } + else + { + hr = DIERR_DEVICENOTREG; + } + if (hr != DI_OK) goto failed;
impl->base.instance = instance;