Signed-off-by: Brendan Shanks bshanks@codeweavers.com --- dlls/dinput/tests/dinput.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c index c570ecf8cf..5947b17468 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -386,6 +386,30 @@ static BOOL CALLBACK enum_devices_callback(const DIDEVICEINSTANCEA *instance, vo wine_dbgstr_guid(&instance->guidProduct)); }
+ if ((instance->dwDevType & 0xff) == DIDEVTYPE_KEYBOARD) + ok(IsEqualGUID(&instance->guidProduct, &GUID_SysKeyboard), + "Keyboard guidProduct (%s) does not match GUID_SysKeyboard (%s)\n", + wine_dbgstr_guid(&instance->guidProduct), + wine_dbgstr_guid(&GUID_SysMouse)); + else if ((instance->dwDevType & 0xff) == DIDEVTYPE_MOUSE) + ok(IsEqualGUID(&instance->guidProduct, &GUID_SysMouse), + "Mouse guidProduct (%s) does not match GUID_SysMouse (%s)\n", + wine_dbgstr_guid(&instance->guidProduct), + wine_dbgstr_guid(&GUID_SysMouse)); + else { + /* Non-keyboard/mouse devices use the "PIDVID" guidProduct */ + static const GUID pidvid_product_guid = { /* device_pidvid-0000-0000-0000-504944564944 "PIDVID" */ + 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44} + }; + + ok(instance->guidProduct.Data2 == pidvid_product_guid.Data2, + "guidProduct.Data2 is %04x\n", instance->guidProduct.Data2); + ok(instance->guidProduct.Data3 == pidvid_product_guid.Data3, + "guidProduct.Data3 is %04x\n", instance->guidProduct.Data3); + ok(!memcmp(instance->guidProduct.Data4, pidvid_product_guid.Data4, sizeof(pidvid_product_guid.Data4)), + "guidProduct.Data4 does not match: %s\n", wine_dbgstr_guid(&instance->guidProduct)); + } + enum_test->device_count++; return enum_test->return_value; }
Windows uses an undocumented GUID (ending in ASCII "PIDVID") for non-keyboard/mouse devices. Various games (DiRT Rally 2) and libraries (SDL, GLFW) look for this GUID to match specific devices or know that the PID/VID can be extracted.
Add this GUID for all backends to share. linux and linuxinput were already using PIDVID, switch them to using the shared one. Mac was using a different GUID, switch it to use PIDVID.
Signed-off-by: Brendan Shanks bshanks@codeweavers.com --- dlls/dinput/device_private.h | 2 ++ dlls/dinput/joystick.c | 8 ++++++++ dlls/dinput/joystick_linux.c | 15 +-------------- dlls/dinput/joystick_linuxinput.c | 15 +-------------- dlls/dinput/joystick_osx.c | 6 +++--- 5 files changed, 15 insertions(+), 31 deletions(-)
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index d9e2997eaa..27e9c26286 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -114,6 +114,8 @@ typedef struct LPDIRECTINPUTEFFECT ref; } effect_list_item;
+extern const GUID DInput_PIDVID_Product_GUID DECLSPEC_HIDDEN; + /* Various debug tools */ extern void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) DECLSPEC_HIDDEN; extern void _dump_OBJECTINSTANCEA(const DIDEVICEOBJECTINSTANCEA *ddoi) DECLSPEC_HIDDEN; diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index a5308b6cc4..2220b5d576 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -52,6 +52,14 @@ static const WORD PID_XBOX_CONTROLLERS[] = { 0x0719, /* Xbox 360 Wireless Adapter */ };
+/* Windows uses this GUID for guidProduct on non-keyboard/mouse devices. + * Data1 contains the device VID (low word) and PID (high word). + * Data4 ends with the ASCII bytes "PIDVID". + */ +const GUID DInput_PIDVID_Product_GUID = { /* device_pidvid-0000-0000-0000-504944564944 */ + 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44} +}; + static inline JoystickGenericImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface) { return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), JoystickGenericImpl, base); diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 7e01f90843..4ee7397c2c 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -126,19 +126,6 @@ static const GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903 {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7} };
-/* - * Construct the GUID in the same way of Windows doing this. - * Data1 is concatenation of productid and vendorid. - * Data2 and Data3 are NULL. - * Data4 seems to be a constant. - */ -static const GUID DInput_Wine_Joystick_Constant_Part_GUID = { - 0x000000000, - 0x0000, - 0x0000, - {0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44} -}; - #define MAX_JOYSTICKS 64 static INT joystick_devices_count = -1; static struct JoyDev *joystick_devices; @@ -327,7 +314,7 @@ static INT find_joystick_devices(void) else { /* Concatenate product_id with vendor_id to mimic Windows behaviour */ - joydev.guid_product = DInput_Wine_Joystick_Constant_Part_GUID; + joydev.guid_product = DInput_PIDVID_Product_GUID; joydev.guid_product.Data1 = MAKELONG(joydev.vendor_id, joydev.product_id); }
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 1e8c542f21..b5418d805c 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -165,19 +165,6 @@ static const GUID DInput_Wine_Joystick_Base_GUID = { /* 9e573eda-7734-11d2-8d4a- {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7} };
-/* - * Construct the GUID in the same way of Windows doing this. - * Data1 is concatenation of productid and vendorid. - * Data2 and Data3 are NULL. - * Data4 seems to be a constant. - */ -static const GUID DInput_Wine_Joystick_Constant_Part_GUID = { - 0x000000000, - 0x0000, - 0x0000, - {0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44} -}; - #define test_bit(arr,bit) (((BYTE*)(arr))[(bit)>>3]&(1<<((bit)&7)))
#define MAX_JOYDEV 64 @@ -344,7 +331,7 @@ static void find_joydevs(void) joydev.bus_type = device_id.bustype;
/* Concatenate product_id with vendor_id to mimic Windows behaviour */ - joydev.guid_product = DInput_Wine_Joystick_Constant_Part_GUID; + joydev.guid_product = DInput_PIDVID_Product_GUID; joydev.guid_product.Data1 = MAKELONG(joydev.vendor_id, joydev.product_id); }
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 884dd7f3e1..990f5d1f07 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -985,7 +985,7 @@ static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS /* Return joystick */ lpddi->guidInstance = DInput_Wine_OsX_Joystick_GUID; lpddi->guidInstance.Data3 = id; - lpddi->guidProduct = DInput_Wine_OsX_Joystick_GUID; + lpddi->guidProduct = DInput_PIDVID_Product_GUID; lpddi->guidProduct.Data1 = make_vid_pid(device); lpddi->dwDevType = get_device_type(version, is_joystick); lpddi->dwDevType |= DIDEVTYPE_HID; @@ -1033,7 +1033,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS /* Return joystick */ lpddi->guidInstance = DInput_Wine_OsX_Joystick_GUID; lpddi->guidInstance.Data3 = id; - lpddi->guidProduct = DInput_Wine_OsX_Joystick_GUID; + lpddi->guidProduct = DInput_PIDVID_Product_GUID; lpddi->guidProduct.Data1 = make_vid_pid(device); lpddi->dwDevType = get_device_type(version, is_joystick); lpddi->dwDevType |= DIDEVTYPE_HID; @@ -1109,7 +1109,7 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
newDevice->generic.guidInstance = DInput_Wine_OsX_Joystick_GUID; newDevice->generic.guidInstance.Data3 = index; - newDevice->generic.guidProduct = DInput_Wine_OsX_Joystick_GUID; + newDevice->generic.guidProduct = DInput_PIDVID_Product_GUID; newDevice->generic.guidProduct.Data1 = make_vid_pid(device); newDevice->generic.joy_polldev = poll_osx_device_state;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=55461
Your paranoid android.
=== debian10 (32 bit report) ===
dinput: mouse.c:173: Test failed: GetDeviceData() failed: 00000000 cnt:0
=== debian10 (32 bit Chinese:China report) ===
dinput: mouse.c:173: Test failed: GetDeviceData() failed: 00000000 cnt:0
=== debian10 (32 bit WoW report) ===
dinput: mouse.c:173: Test failed: GetDeviceData() failed: 00000000 cnt:0
=== debian10 (64 bit WoW report) ===
dinput: mouse.c:173: Test failed: GetDeviceData() failed: 00000000 cnt:0