7
7
"encoding/binary"
8
8
"errors"
9
9
"machine/usb"
10
+ "machine/usb/descriptor"
10
11
)
11
12
12
13
type USBDevice struct {
@@ -29,7 +30,7 @@ type Serialer interface {
29
30
RTS () bool
30
31
}
31
32
32
- var usbDescriptor = usb . DescriptorCDC
33
+ var usbDescriptor = descriptor . CDC
33
34
34
35
var usbDescriptorConfig uint8 = usb .DescriptorConfigCDC
35
36
88
89
)
89
90
90
91
var (
91
- usbEndpointDescriptors [usb .NumberOfEndpoints ]usb. DeviceDescriptor
92
+ usbEndpointDescriptors [usb .NumberOfEndpoints ]descriptor. Device
92
93
93
94
isEndpointHalt = false
94
95
isRemoteWakeUpEnabled = false
@@ -141,13 +142,13 @@ func sendDescriptor(setup usb.Setup) {
141
142
// composite descriptor
142
143
switch {
143
144
case (usbDescriptorConfig & usb .DescriptorConfigHID ) > 0 :
144
- usbDescriptor = usb . DescriptorCDCHID
145
+ usbDescriptor = descriptor . CDCHID
145
146
case (usbDescriptorConfig & usb .DescriptorConfigMIDI ) > 0 :
146
- usbDescriptor = usb . DescriptorCDCMIDI
147
+ usbDescriptor = descriptor . CDCMIDI
147
148
case (usbDescriptorConfig & usb .DescriptorConfigJoystick ) > 0 :
148
- usbDescriptor = usb . DescriptorCDCJoystick
149
+ usbDescriptor = descriptor . CDCJoystick
149
150
default :
150
- usbDescriptor = usb . DescriptorCDC
151
+ usbDescriptor = descriptor . CDC
151
152
}
152
153
153
154
usbDescriptor .Configure (usbVendorID (), usbProductID ())
@@ -302,11 +303,11 @@ func EnableMIDI(txHandler func(), rxHandler func([]byte), setupHandler func(usb.
302
303
303
304
// EnableJoystick enables HID. This function must be executed from the init().
304
305
func EnableJoystick (txHandler func (), rxHandler func ([]byte ), setupHandler func (usb.Setup ) bool , hidDesc []byte ) {
305
- idx := bytes .Index (usb . DescriptorCDCJoystick .Configuration , []byte {
306
+ idx := bytes .Index (descriptor . CDCJoystick .Configuration , []byte {
306
307
0x09 , 0x21 , 0x11 , 0x01 , 0x00 , 0x01 , 0x22 ,
307
308
})
308
- binary .LittleEndian .PutUint16 (usb . DescriptorCDCJoystick .Configuration [idx + 7 :idx + 9 ], uint16 (len (hidDesc )))
309
- usb . DescriptorCDCJoystick .HID [2 ] = hidDesc
309
+ binary .LittleEndian .PutUint16 (descriptor . CDCJoystick .Configuration [idx + 7 :idx + 9 ], uint16 (len (hidDesc )))
310
+ descriptor . CDCJoystick .HID [2 ] = hidDesc
310
311
usbDescriptorConfig |= usb .DescriptorConfigJoystick
311
312
endPoints [usb .HID_ENDPOINT_OUT ] = (usb .ENDPOINT_TYPE_INTERRUPT | usb .EndpointOut )
312
313
usbRxHandler [usb .HID_ENDPOINT_OUT ] = rxHandler
0 commit comments