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@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
50785992d0
commit
d2d3959d3d
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue