I have found a slight issue with the HID descriptor though. Although it works, MAME sees the buttons not as "Joy 1 Button X" but as "Joy 1 Joystick", "Joy 1 Pointer", "Joy 1 Keyboad" etc. until we get to "Joy 1 Button 10". It works fine, it just looks weird.
Here is my current report descriptor:
Code: Select all
ReportDescriptor:
.db 0x05,0x01 ;Usage_Page (Generic Desktop)
.db 0x09,0x05 ;Usage (Game Pad)
.db 0xA1,0x01 ;Collection (Application)
.db 0x09,0x01 ;Usage (Pointer)
.db 0xA1,0x00 ;Collection (Physical)
.db 0x09,0x30 ;Usage (X)
.db 0x09,0x31 ;Usage (Y)
.db 0x15,0x81 ;Logical_Minimum (-127)
.db 0x25,0x7F ;Logical Maximum (127)
.db 0x75,0x08 ;Report_Size (8)
.db 0x95,0x02 ;Report_Count (2)
.db 0x81,0x02 ;Input (Data, Var, Abs)
.db 0xC0,0x16 ;End_Collection, dummy
.db 0x05,0x09 ;Usage_Page (Button)
.db 0x19,0x01 ;Usage_Minimum (Button 1)
.db 0x29,0x0a ;Usage_Maximum (Button 10)
.db 0x15,0x00 ;Logical_Minimum (0)
.db 0x25,0x01 ;Logical_Maximum (1)
.db 0x75,0x01 ;Report_Size (1)
.db 0x95,0x0a ;Report_Count (10)
.db 0x55,0x00 ;Unit_Exponent (0)
.db 0x65,0x00 ;Unit (None)
.db 0x81,0x02 ;Input (Data, Var, Abs)
;round it out to whole byte for Windows
.db 0x09,0x00 ;Usage (undefined)
.db 0x15,0x01 ;Logical_Minimum (1)
.db 0x25,0x06 ;Logical_Maximum (6)
.db 0x75,0x06 ;Report_Size (6)
.db 0x95,0x01 ;Report_Count (1)
.db 0x81,0x02 ;Input (Data, Var, Abs)
.db 0xC0,0x00 ;End_Collection , dummy padding
ReportDescriptorEnd:
I can't see anything obviously wrong with it. I checked MAME with various other USB controllers and it detects the buttons correctly.
Is there any software available that can read a report descriptor from a USB device? I couldn't find any, but it would be useful to read the descriptor from a working USB gamepad for comparison.