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: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Bruno Jesus 2016-08-16 22:24:14 -03:00 committed by Alexandre Julliard
parent cfd3076c31
commit 738e17b2d7
2 changed files with 20 additions and 1 deletions

View File

@ -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;

View File

@ -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);