From 30ae73542567be9e3dfa2ca636bd53828a0f18a3 Mon Sep 17 00:00:00 2001 From: Bruno Jesus <00cpxxx@gmail.com> Date: Wed, 17 Aug 2016 21:50:06 -0300 Subject: [PATCH] dinput: Properly fill the HID information for the controller in the event driver. Signed-off-by: Bruno Jesus <00cpxxx@gmail.com> Signed-off-by: Alexandre Julliard --- dlls/dinput/joystick_linuxinput.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index aaed7016431..6fa599758f0 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -110,7 +110,7 @@ struct JoyDev { /* data returned by the EVIOCGABS() ioctl */ struct wine_input_absinfo axes[ABS_MAX]; - WORD vendor_id, product_id; + WORD vendor_id, product_id, bus_type; }; struct JoystickImpl @@ -315,6 +315,7 @@ static void find_joydevs(void) { joydev.vendor_id = device_id.vendor; joydev.product_id = device_id.product; + 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; @@ -356,6 +357,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 (joydevs[id].bus_type == BUS_USB && + joydevs[id].vendor_id && joydevs[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, joydevs[id].name, -1, lpddi->tszInstanceName, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszProductName, MAX_PATH); }