Commit 738e17b2 authored by Bruno Jesus's avatar Bruno Jesus Committed by Alexandre Julliard

dinput: Properly fill the HID information for the controller in the js driver.

Even the Xbox 360 controller which does not use HID has the same flags and usage page set on Windows. Signed-off-by: 's avatarBruno Jesus <00cpxxx@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent cfd3076c
......@@ -83,7 +83,7 @@ struct JoyDev
BYTE button_count;
int *dev_axes_map;
WORD vendor_id, product_id;
WORD vendor_id, product_id, bus_type;
};
typedef struct JoystickImpl JoystickImpl;
......@@ -250,6 +250,7 @@ static INT find_joystick_devices(void)
read_sys_id_variable(i, "vendor", &joydev.vendor_id);
read_sys_id_variable(i, "product", &joydev.product_id);
read_sys_id_variable(i, "bustype", &joydev.bus_type);
if (joydev.vendor_id == 0 || joydev.product_id == 0)
{
......@@ -299,6 +300,18 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
/* Assume the joystick as HID if it is attached to USB bus and has a valid VID/PID */
if (joystick_devices[id].bus_type == BUS_USB &&
joystick_devices[id].vendor_id && joystick_devices[id].product_id)
{
lpddi->dwDevType |= DIDEVTYPE_HID;
lpddi->wUsagePage = 0x01; /* Desktop */
if (lpddi->dwDevType == DI8DEVTYPE_JOYSTICK || lpddi->dwDevType == DIDEVTYPE_JOYSTICK)
lpddi->wUsage = 0x04; /* Joystick */
else
lpddi->wUsage = 0x05; /* Game Pad */
}
MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszInstanceName, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszProductName, MAX_PATH);
lpddi->guidFFDriver = GUID_NULL;
......
......@@ -223,6 +223,12 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
lpddi->wUsagePage,
lpddi->wUsage);
/* Check if this is a HID device */
if (lpddi->dwDevType & DIDEVTYPE_HID)
ok(lpddi->wUsagePage == 0x01 && (lpddi->wUsage == 0x04 || lpddi->wUsage == 0x05),
"Expected a game controller HID UsagePage and Usage, got page 0x%x usage 0x%x\n",
lpddi->wUsagePage, lpddi->wUsage);
/* Test for joystick ID property */
ZeroMemory(&dipw, sizeof(dipw));
dipw.diph.dwSize = sizeof(DIPROPDWORD);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment