[PATCH] dinput: Use vid/pid for first chunk of product guid on OSX, too

Andrew Eikum aeikum at codeweavers.com
Mon Aug 6 11:11:30 CDT 2018


This is already done on the linux backends.

Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
 dlls/dinput/joystick_osx.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c
index b0dcdd99d5..282b6c2790 100644
--- a/dlls/dinput/joystick_osx.c
+++ b/dlls/dinput/joystick_osx.c
@@ -932,18 +932,31 @@ static INT find_joystick_devices(void)
     return  joystick_devices_count;
 }
 
+static DWORD make_vid_pid(IOHIDDeviceRef device)
+{
+    long vendID, prodID;
+
+    vendID = get_device_property_long(device, CFSTR(kIOHIDVendorIDKey));
+    prodID = get_device_property_long(device, CFSTR(kIOHIDProductIDKey));
+
+    return MAKELONG(vendID, prodID);
+}
+
 static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
 {
+    IOHIDDeviceRef device;
+
     TRACE("dwDevType %u dwFlags 0x%08x version 0x%04x id %d\n", dwDevType, dwFlags, version, id);
 
     if (id >= find_joystick_devices()) return E_FAIL;
 
+    device = get_device_ref(id);
+
     if ((dwDevType == 0) ||
     ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
     (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800)))
     {
         if (dwFlags & DIEDFL_FORCEFEEDBACK) {
-            IOHIDDeviceRef device = get_device_ref(id);
             if(!device)
                 return S_FALSE;
             if(get_ff(device, NULL) != S_OK)
@@ -953,6 +966,7 @@ static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS
         lpddi->guidInstance = DInput_Wine_OsX_Joystick_GUID;
         lpddi->guidInstance.Data3 = id;
         lpddi->guidProduct = DInput_Wine_OsX_Joystick_GUID;
+        lpddi->guidProduct.Data1 = make_vid_pid(device);
         /* we only support traditional joysticks for now */
         if (version >= 0x0800)
             lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
@@ -993,6 +1007,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS
         lpddi->guidInstance = DInput_Wine_OsX_Joystick_GUID;
         lpddi->guidInstance.Data3 = id;
         lpddi->guidProduct = DInput_Wine_OsX_Joystick_GUID;
+        lpddi->guidProduct.Data1 = make_vid_pid(device);
         /* we only support traditional joysticks for now */
         if (version >= 0x0800)
             lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
@@ -1060,9 +1075,12 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
 
     newDevice->id = index;
 
+    device = get_device_ref(index);
+
     newDevice->generic.guidInstance = DInput_Wine_OsX_Joystick_GUID;
     newDevice->generic.guidInstance.Data3 = index;
     newDevice->generic.guidProduct = DInput_Wine_OsX_Joystick_GUID;
+    newDevice->generic.guidProduct.Data1 = make_vid_pid(device);
     newDevice->generic.joy_polldev = poll_osx_device_state;
 
     /* get the device name */
@@ -1074,7 +1092,6 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
     strcpy(newDevice->generic.name, name);
 
     list_init(&newDevice->effects);
-    device = get_device_ref(index);
     if(get_ff(device, &newDevice->ff) == S_OK){
         newDevice->generic.devcaps.dwFlags |= DIDC_FORCEFEEDBACK;
 
-- 
2.18.0




More information about the wine-devel mailing list