Browse Source

machine/usb/descriptor: rename and export Append() to make it easier to create new descriptors in user code

Signed-off-by: deadprogram <ron@hybridgroup.com>
fix-flash-eraseblock
deadprogram 2 years ago
committed by Ron Evans
parent
commit
90935703e6
  1. 2
      src/machine/usb/descriptor/cdc.go
  2. 2
      src/machine/usb/descriptor/descriptor.go
  3. 4
      src/machine/usb/descriptor/hid.go
  4. 4
      src/machine/usb/descriptor/joystick.go
  5. 2
      src/machine/usb/descriptor/midi.go

2
src/machine/usb/descriptor/cdc.go

@ -152,7 +152,7 @@ var InterfaceCDCData = InterfaceType{
var CDC = Descriptor{
Device: DeviceCDC.Bytes(),
Configuration: appendSlices([][]byte{
Configuration: Append([][]byte{
ConfigurationCDC.Bytes(),
InterfaceAssociationCDC.Bytes(),
InterfaceCDCControl.Bytes(),

2
src/machine/usb/descriptor/descriptor.go

@ -46,7 +46,7 @@ func (d *Descriptor) Configure(idVendor, idProduct uint16) {
conf.TotalLength(uint16(len(d.Configuration)))
}
func appendSlices[T any](slices [][]T) []T {
func Append[T any](slices [][]T) []T {
var size, pos int
for _, s := range slices {

4
src/machine/usb/descriptor/hid.go

@ -113,7 +113,7 @@ var ClassHID = ClassHIDType{
var CDCHID = Descriptor{
Device: DeviceCDC.Bytes(),
Configuration: appendSlices([][]byte{
Configuration: Append([][]byte{
ConfigurationCDCHID.Bytes(),
InterfaceAssociationCDC.Bytes(),
InterfaceCDCControl.Bytes(),
@ -130,7 +130,7 @@ var CDCHID = Descriptor{
EndpointEP4IN.Bytes(),
}),
HID: map[uint16][]byte{
2: appendSlices([][]byte{
2: Append([][]byte{
HIDUsagePageGenericDesktop,
HIDUsageDesktopKeyboard,
HIDCollectionApplication,

4
src/machine/usb/descriptor/joystick.go

@ -68,7 +68,7 @@ var ClassHIDJoystick = ClassHIDType{
data: classHIDJoystick[:],
}
var JoystickDefaultHIDReport = appendSlices([][]byte{
var JoystickDefaultHIDReport = Append([][]byte{
HIDUsagePageGenericDesktop,
HIDUsageDesktopJoystick,
HIDCollectionApplication,
@ -136,7 +136,7 @@ var JoystickDefaultHIDReport = appendSlices([][]byte{
// custom configurations.
var CDCJoystick = Descriptor{
Device: DeviceJoystick.Bytes(),
Configuration: appendSlices([][]byte{
Configuration: Append([][]byte{
ConfigurationCDCJoystick.Bytes(),
InterfaceAssociationCDC.Bytes(),
InterfaceCDCControl.Bytes(),

2
src/machine/usb/descriptor/midi.go

@ -220,7 +220,7 @@ var ConfigurationCDCMIDI = ConfigurationType{
var CDCMIDI = Descriptor{
Device: DeviceCDC.Bytes(),
Configuration: appendSlices([][]byte{
Configuration: Append([][]byte{
ConfigurationCDCMIDI.Bytes(),
InterfaceAssociationCDC.Bytes(),
InterfaceCDCControl.Bytes(),

Loading…
Cancel
Save