Add USB HID joystick support (#3366)

machine/usb: add USB HID joystick support
This commit is contained in:
irieda
2023-01-08 06:30:40 +09:00
committed by GitHub
parent 0566bbfeb4
commit a7ff2731b9
10 changed files with 482 additions and 14 deletions
+50 -1
View File
@@ -109,9 +109,58 @@ var DescriptorCDCMIDI = Descriptor{
0x06, 0x24, 0x02, 0x02, 0x02, 0x00,
0x09, 0x24, 0x03, 0x01, 0x03, 0x01, 0x02, 0x01, 0x00,
0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x01, 0x01, 0x00,
0x09, 0x05, 0x05, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00,
0x09, 0x05, 0x07, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00,
0x05, 0x25, 0x01, 0x01, 0x01,
0x09, 0x05, 0x86, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00,
0x05, 0x25, 0x01, 0x01, 0x03,
},
}
var DescriptorCDCJoystick = Descriptor{
Device: []byte{
0x12, 0x01, 0x00, 0x02, 0xef, 0x02, 0x01, 0x40,
0x41, 0x23, 0x36, 0x80, 0x00, 0x01, 0x01, 0x02,
0x03, 0x01,
},
Configuration: []byte{
// Configuration Descriptor Header
0x09, 0x02,
0x6b, 0x00, // Total Length: 0x006b(107)
0x03, 0x01, 0x00, 0xa0, 0xfa,
// InterfaceAssociation Descriptoy
0x08, 0x0b, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,
// InterfaceSescriptor(CDC-Ctrl)
0x09, 0x04, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00,
// Communication Descriptor
0x05, 0x24, 0x00, 0x10, 0x01,
// Communication Descriptor
0x05, 0x24, 0x01, 0x01, 0x01,
// Communication Descriptor
0x04, 0x24, 0x02, 0x06,
// Communication Descriptor
0x05, 0x24, 0x06, 0x00, 0x01,
// ENDPOINT Descriptor
0x07, 0x05, 0x81, 0x03, 0x10, 0x00, 0x40,
// InterfaceSescriptor(CDC-Data)
0x09, 0x04, 0x01, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x00,
// ENDPOINT Descriptor
0x07, 0x05, 0x02, 0x02, 0x40, 0x00, 0x00,
// ENDPOINT Descriptor
0x07, 0x05, 0x83, 0x02, 0x40, 0x00, 0x00,
// InterfaceSescriptor(HID)
0x09, 0x04, 0x02, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00,
// HID Descriptor
0x09, // bLength: 9
0x21, // bDescriptorType: 0x21(HID)
0x11, 0x01, // bcdHID: 0x111
0x00, // bCountryCode: Not Supported
0x01, // bNumDescriptors: 1
0x22, // Type: HID Report
0x00, 0x00, // Length
// ENDPOINT Descriptor
0x07, 0x05, 0x84, 0x03, 0x40, 0x00, 0x01,
// ENDPOINT Descriptor
0x07, 0x05, 0x05, 0x03, 0x40, 0x00, 0x01,
},
HID: map[uint16][]byte{},
}