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>
This commit is contained in:
deadprogram
2023-04-28 21:36:18 +02:00
committed by Ron Evans
parent d8ee520bdc
commit 90935703e6
5 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -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(),
+1 -1
View File
@@ -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 {
+2 -2
View File
@@ -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,
+2 -2
View File
@@ -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(),
+1 -1
View File
@@ -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(),