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>
Этот коммит содержится в:
deadprogram 2023-04-28 21:36:18 +02:00 коммит произвёл Ron Evans
родитель d8ee520bdc
коммит 90935703e6
5 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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