From: Zebediah Figura zfigura@codeweavers.com
We set the instance and product IDs for all joysticks to match the latter parts of hid_joystick_guid and dinput_pidvid_guid, respectively. Therefore there is no need to manually check which one we are matching against.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
Supersedes: 235833-235834
dlls/dinput/joystick_hid.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 5fdc563054b..70b44c28474 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1564,8 +1564,8 @@ failed: return DIERR_DEVICENOTREG; }
-static HRESULT hid_joystick_device_open( int index, DIDEVICEINSTANCEW *filter, WCHAR *device_path, - HANDLE *device, PHIDP_PREPARSED_DATA *preparsed, +static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEINSTANCEW *filter, + WCHAR *device_path, HANDLE *device, PHIDP_PREPARSED_DATA *preparsed, HIDD_ATTRIBUTES *attrs, HIDP_CAPS *caps, DWORD version ) { char buffer[sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) + MAX_PATH * sizeof(WCHAR)]; @@ -1580,8 +1580,7 @@ static HRESULT hid_joystick_device_open( int index, DIDEVICEINSTANCEW *filter, W DWORD type; GUID hid;
- TRACE( "index %d, product %s, instance %s\n", index, debugstr_guid( &filter->guidProduct ), - debugstr_guid( &filter->guidInstance ) ); + TRACE( "index %d, guid %s\n", index, debugstr_guid( guid ) );
HidD_GetHidGuid( &hid );
@@ -1626,8 +1625,7 @@ static HRESULT hid_joystick_device_open( int index, DIDEVICEINSTANCEW *filter, W }
/* enumerate device by GUID */ - if (index < 0 && IsEqualGUID( &filter->guidProduct, &instance.guidProduct )) break; - if (index < 0 && IsEqualGUID( &filter->guidInstance, &instance.guidInstance )) break; + if (IsEqualGUID( guid, &instance.guidProduct ) || IsEqualGUID( guid, &instance.guidInstance )) break;
/* enumerate all devices */ if (index >= 0 && !index--) break; @@ -1653,13 +1651,14 @@ HRESULT hid_joystick_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *in HIDD_ATTRIBUTES attrs = {.Size = sizeof(attrs)}; PHIDP_PREPARSED_DATA preparsed; WCHAR device_path[MAX_PATH]; + GUID guid = GUID_NULL; HIDP_CAPS caps; HANDLE device; HRESULT hr;
TRACE( "type %#lx, flags %#lx, instance %p, version %#lx, index %d\n", type, flags, instance, version, index );
- hr = hid_joystick_device_open( index, instance, device_path, &device, &preparsed, + hr = hid_joystick_device_open( index, &guid, instance, device_path, &device, &preparsed, &attrs, &caps, version ); if (hr != DI_OK) return hr;
@@ -2035,19 +2034,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,8 +2042,8 @@ 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 )) - hr = hid_joystick_device_open( -1, &instance, impl->device_path, &impl->device, &impl->preparsed, + if (memcmp( device_path_guid.Data4, guid->Data4, sizeof(device_path_guid.Data4) )) + hr = hid_joystick_device_open( -1, guid, &instance, impl->device_path, &impl->device, &impl->preparsed, &attrs, &impl->caps, dinput->dwVersion ); else {
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 70b44c28474..07cf2e6158d 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1564,7 +1564,7 @@ failed: return DIERR_DEVICENOTREG; }
-static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEINSTANCEW *filter, +static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEINSTANCEW *instance, WCHAR *device_path, HANDLE *device, PHIDP_PREPARSED_DATA *preparsed, HIDD_ATTRIBUTES *attrs, HIDP_CAPS *caps, DWORD version ) { @@ -1572,7 +1572,6 @@ static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEIN SP_DEVICE_INTERFACE_DETAIL_DATA_W *detail = (void *)buffer; SP_DEVICE_INTERFACE_DATA iface = {.cbSize = sizeof(iface)}; SP_DEVINFO_DATA devinfo = {.cbSize = sizeof(devinfo)}; - DIDEVICEINSTANCEW instance = *filter; WCHAR device_id[MAX_PATH], *tmp; HDEVINFO set, xi_set; UINT32 i = 0, handle; @@ -1600,10 +1599,10 @@ static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEIN type != DEVPROP_TYPE_UINT32) continue; if (FAILED(hid_joystick_device_try_open( handle, detail->DevicePath, device, preparsed, - attrs, caps, &instance, version ))) + attrs, caps, instance, version ))) continue;
- if (device_instance_is_disabled( &instance, &override )) + if (device_instance_is_disabled( instance, &override )) goto next;
if (override && SetupDiGetDeviceInstanceIdW( set, &devinfo, device_id, MAX_PATH, NULL ) && @@ -1620,12 +1619,12 @@ static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEIN CloseHandle( *device ); HidD_FreePreparsedData( *preparsed ); if (FAILED(hid_joystick_device_try_open( handle, detail->DevicePath, device, preparsed, - attrs, caps, &instance, version ))) + attrs, caps, instance, version ))) continue; }
/* enumerate device by GUID */ - if (IsEqualGUID( guid, &instance.guidProduct ) || IsEqualGUID( guid, &instance.guidInstance )) break; + if (IsEqualGUID( guid, &instance->guidProduct ) || IsEqualGUID( guid, &instance->guidInstance )) break;
/* enumerate all devices */ if (index >= 0 && !index--) break; @@ -1642,7 +1641,6 @@ static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEIN if (!*device || !*preparsed) return DIERR_DEVICENOTREG;
lstrcpynW( device_path, detail->DevicePath, MAX_PATH ); - *filter = instance; return DI_OK; }
@@ -2007,12 +2005,6 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi .dwHeaderSize = sizeof(filter), .dwHow = DIPH_DEVICE, }; - DIDEVICEINSTANCEW instance = - { - .dwSize = sizeof(instance), - .guidProduct = *guid, - .guidInstance = *guid - }; DIPROPRANGE range = { .diph = @@ -2043,18 +2035,17 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi impl->internal_ref = 1;
if (memcmp( device_path_guid.Data4, guid->Data4, sizeof(device_path_guid.Data4) )) - hr = hid_joystick_device_open( -1, guid, &instance, impl->device_path, &impl->device, &impl->preparsed, + hr = hid_joystick_device_open( -1, guid, &impl->base.instance, impl->device_path, &impl->device, &impl->preparsed, &attrs, &impl->caps, dinput->dwVersion ); else { 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 ); + &impl->caps, &impl->base.instance, dinput->dwVersion ); } if (hr != DI_OK) goto failed;
- impl->base.instance = instance; - impl->base.caps.dwDevType = instance.dwDevType; + impl->base.caps.dwDevType = impl->base.instance.dwDevType; impl->attrs = attrs; list_init( &impl->effect_list );