[PATCH 3/3] dinput: Properly fill the HID information for the controller in the js driver
Bruno Jesus
00cpxxx at gmail.com
Tue Aug 16 20:24:14 CDT 2016
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>
-------------- next part --------------
---
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 4882744..4be3092 100644
--- a/dlls/dinput/tests/joystick.c
+++ b/dlls/dinput/tests/joystick.c
@@ -219,6 +219,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);
--
2.8.1
More information about the wine-patches
mailing list