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>
Этот коммит содержится в:
		
							родитель
							
								
									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(), | ||||||
|  |  | ||||||
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче
	
	 deadprogram
						deadprogram