Brendan Shanks : dinput: Add "PIDVID" guidProduct and use for non-keyboards/mice.
Alexandre Julliard
julliard at winehq.org
Tue Aug 20 15:35:22 CDT 2019
Module: wine
Branch: master
Commit: d2d3959d3d29b3da334b53283b34cafde653b3e8
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d2d3959d3d29b3da334b53283b34cafde653b3e8
Author: Brendan Shanks <bshanks at codeweavers.com>
Date: Tue Aug 13 14:40:38 2019 -0700
dinput: Add "PIDVID" guidProduct and use for non-keyboards/mice.
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.
Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 d9e2997..27e9c26 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 a5308b6..2220b5d 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 7e01f90..4ee7397 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 1e8c542..b5418d8 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 884dd7f..990f5d1 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;
More information about the wine-cvs
mailing list