Bruno Jesus : dinput: Properly fill the HID information for the controller in the js driver.
Alexandre Julliard
julliard at winehq.org
Wed Aug 17 10:24:24 CDT 2016
Module: wine
Branch: master
Commit: 738e17b2d7caeacb614d93ea63ff6207174b4cf3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=738e17b2d7caeacb614d93ea63ff6207174b4cf3
Author: Bruno Jesus <00cpxxx at gmail.com>
Date: Tue Aug 16 22:24:14 2016 -0300
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 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/joystick_linux.c | 15 ++++++++++++++-
dlls/dinput/tests/joystick.c | 6 ++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c
index b08d4c9..c0a885d 100644
--- a/dlls/dinput/joystick_linux.c
+++ b/dlls/dinput/joystick_linux.c
@@ -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;
diff --git a/dlls/dinput/tests/joystick.c b/dlls/dinput/tests/joystick.c
index 35ec2d9..00d3b60 100644
--- a/dlls/dinput/tests/joystick.c
+++ b/dlls/dinput/tests/joystick.c
@@ -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);
More information about the wine-cvs
mailing list