machine/usb/hid/joystick: handle case where we cannot find the correct HID descriptor

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2023-04-17 14:38:15 +02:00
committed by Ron Evans
parent 2ab7ee6a8a
commit 25b03414dc
3 changed files with 23 additions and 5 deletions
+6 -1
View File
@@ -302,7 +302,12 @@ func EnableMIDI(txHandler func(), rxHandler func([]byte), setupHandler func(usb.
// EnableJoystick enables HID. This function must be executed from the init().
func EnableJoystick(txHandler func(), rxHandler func([]byte), setupHandler func(usb.Setup) bool, hidDesc []byte) {
class := descriptor.FindClassHIDType(descriptor.CDCJoystick.Configuration, descriptor.ClassHIDJoystick.Bytes())
class, err := descriptor.FindClassHIDType(descriptor.CDCJoystick.Configuration, descriptor.ClassHIDJoystick.Bytes())
if err != nil {
// TODO: some way to notify about error
return
}
class.ClassLength(uint16(len(hidDesc)))
descriptor.CDCJoystick.HID[2] = hidDesc