I am building an USB adapter for an old game controller. So far everything is working fine. My HID descriptor looks like this:
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ 0x09, 0x05, /* USAGE (Game Pad) */ 0xa1, 0x01, /* COLLECTION (Application) */ 0xa1, 0x03, /* COLLECTION (Report) */ 0x85, 0x01, /* REPORT_ID (1) */ 0x05, 0x09, /* USAGE_PAGE (Button) */ 0x19, 0x01, /* USAGE_MINIMUM (Button 1) */ 0x29, 0x0e, /* USAGE_MAXIMUM (Button 14) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x95, 0x0e, /* REPORT_COUNT (14) */ 0x75, 0x01, /* REPORT_SIZE (1) */ 0x81, 0x02, /* INPUT (Data,Var,Abs) */ 0x95, 0x01, /* REPORT_COUNT (1) */ 0x75, 0x02, /* REPORT_SIZE (2) */ 0x81, 0x03, /* INPUT (Cnst) */ 0xa1, 0x00, /* COLLECTION (Physical) */ 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ 0x09, 0x30, /* USAGE (X) */ 0x09, 0x31, /* USAGE (Y) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x64, /* LOGICAL_MAXIMUM (100) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x02, /* REPORT_COUNT (2) */ 0x81, 0x02, /* INPUT (Data,Var,Abs) */ 0xc0, /* END_COLLECTION */ 0xc0, /* END_COLLECTION */ 0xc0 /* END_COLLECTION */
Now I want to add support for up to 4 of these controllers. If I understand the HID spec correctly, one way to do this is to repeat the descriptor 4 times, each time with a different report ID. (I know I could probably just have multiple USB interfaces with the HID class, but I'd rather not do it that way; my USB code would get a great deal more complicated.)
When I tried this Linux refused to recognize the device as a gamepad. The HID
hid-generic) is loaded, and the descriptor seems to be parsed correctly, but there is no device file in
I tested my code on Windows 7, and it looks like this problem is indeed Linux specific. So I am reformulating my original question:
How do I need to modify my HID descriptor, so it works on both Windows and Linux?
When plugging the device in,
dmesg reports this:
usb 3-6: new low-speed USB device number 8 using xhci_hcd usb 3-6: ep 0x81 - rounding interval to 64 microframes, ep desc says 80 microframes input: XYZ Adapter as /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/0003:16C0:05DC.0009/input/input20 hid-generic 0003:16C0:05DC.0009: input,hidraw4: USB HID v1.01 Gamepad [XYZ Adapter] on usb-0000:00:14.0-6/input0
This is identical to what it says when plugging in the working 1-controller version. The device appears in
lsusb, with the correct IDs/descriptors.