1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
package descriptor
var interfaceAssociationMIDI = [interfaceAssociationTypeLen]byte{
interfaceAssociationTypeLen,
TypeInterfaceAssociation,
0x02, // EndpointAddress
0x02, // Attributes
0x01, // MaxPacketSizeL
0x01, // MaxPacketSizeH
0x00, // Interval
0x00, // Interval
}
var InterfaceAssociationMIDI = InterfaceAssociationType{
data: interfaceAssociationMIDI[:],
}
var interfaceAudio = [interfaceTypeLen]byte{
interfaceTypeLen,
TypeInterface,
0x02, // InterfaceNumber
0x00, // AlternateSetting
0x00, // NumEndpoints
0x01, // InterfaceClass
0x01, // InterfaceSubClass
0x00, // InterfaceProtocol
0x00, // Interface
}
var InterfaceAudio = InterfaceType{
data: interfaceAudio[:],
}
var interfaceMIDIStreaming = [interfaceTypeLen]byte{
interfaceTypeLen,
TypeInterface,
0x03, // InterfaceNumber
0x00, // AlternateSetting
0x02, // NumEndpoints
0x01, // InterfaceClass
0x03, // InterfaceSubClass
0x00, // InterfaceProtocol
0x00, // Interface
}
var InterfaceMIDIStreaming = InterfaceType{
data: interfaceMIDIStreaming[:],
}
const classSpecificAudioTypeLen = 9
var classSpecificAudioInterface = [classSpecificAudioTypeLen]byte{
classSpecificAudioTypeLen,
TypeClassSpecific,
0x01,
0x00, //
0x01, //
0x09,
0x00,
0x01,
0x03,
}
var ClassSpecificAudioInterface = ClassSpecificType{
data: classSpecificAudioInterface[:],
}
const classSpecificMIDIHeaderLen = 7
var classSpecificMIDIHeader = [classSpecificMIDIHeaderLen]byte{
classSpecificMIDIHeaderLen,
TypeClassSpecific,
0x01,
0x00, //
0x01, //
0x41,
0x00,
}
var ClassSpecificMIDIHeader = ClassSpecificType{
data: classSpecificMIDIHeader[:],
}
const classSpecificMIDIInJackLen = 6
var classSpecificMIDIInJack1 = [classSpecificMIDIInJackLen]byte{
classSpecificMIDIInJackLen,
TypeClassSpecific,
0x02, // MIDI In jack
0x01, // Jack type (embedded)
0x01, // Jack ID
0x00, // iJack
}
var ClassSpecificMIDIInJack1 = ClassSpecificType{
data: classSpecificMIDIInJack1[:],
}
var classSpecificMIDIInJack2 = [classSpecificMIDIInJackLen]byte{
classSpecificMIDIInJackLen,
TypeClassSpecific,
0x02, // MIDI In jack
0x02, // Jack type (external)
0x02, // Jack ID
0x00, // iJack
}
var ClassSpecificMIDIInJack2 = ClassSpecificType{
data: classSpecificMIDIInJack2[:],
}
const classSpecificMIDIOutJackLen = 9
var classSpecificMIDIOutJack1 = [classSpecificMIDIOutJackLen]byte{
classSpecificMIDIOutJackLen,
TypeClassSpecific,
0x03, // MIDI Out jack
0x01, // Jack type (embedded)
0x03, // Jack ID
0x01, // number of input pins
0x02, // source ID
0x01, // source pin
0x00, // iJack
}
var ClassSpecificMIDIOutJack1 = ClassSpecificType{
data: classSpecificMIDIOutJack1[:],
}
var classSpecificMIDIOutJack2 = [classSpecificMIDIOutJackLen]byte{
classSpecificMIDIOutJackLen,
TypeClassSpecific,
0x03, // MIDI Out jack
0x02, // Jack type (external)
0x04, // Jack ID
0x01, // number of input pins
0x01, // source ID
0x01, // source pin
0x00, // iJack
}
var ClassSpecificMIDIOutJack2 = ClassSpecificType{
data: classSpecificMIDIOutJack2[:],
}
const classSpecificMIDIEndpointLen = 5
var classSpecificMIDIOutEndpoint = [classSpecificMIDIEndpointLen]byte{
classSpecificMIDIEndpointLen,
TypeClassSpecificEndpoint,
0x01, // CS endpoint
0x01, // number MIDI IN jacks
0x01, // assoc Jack ID
}
var ClassSpecificMIDIOutEndpoint = ClassSpecificType{
data: classSpecificMIDIOutEndpoint[:],
}
var classSpecificMIDIInEndpoint = [classSpecificMIDIEndpointLen]byte{
classSpecificMIDIEndpointLen,
TypeClassSpecificEndpoint,
0x01, // CS endpoint
0x01, // number MIDI Out jacks
0x03, // assoc Jack ID
}
var ClassSpecificMIDIInEndpoint = ClassSpecificType{
data: classSpecificMIDIInEndpoint[:],
}
const endpointMIDITypeLen = 9
var endpointEP6IN = [endpointMIDITypeLen]byte{
endpointMIDITypeLen,
TypeEndpoint,
0x86, // EndpointAddress
0x02, // Attributes
0x40, // MaxPacketSizeL
0x00, // MaxPacketSizeH
0x00, // Interval
0x00, // refresh
0x00, // sync address
}
var EndpointEP6IN = EndpointType{
data: endpointEP6IN[:],
}
var endpointEP7OUT = [endpointMIDITypeLen]byte{
endpointMIDITypeLen,
TypeEndpoint,
0x07, // EndpointAddress
0x02, // Attributes
0x40, // MaxPacketSizeL
0x00, // MaxPacketSizeH
0x00, // Interval
0x00, // refresh
0x00, // sync address
}
var EndpointEP7OUT = EndpointType{
data: endpointEP7OUT[:],
}
var configurationCDCMIDI = [configurationTypeLen]byte{
configurationTypeLen,
TypeConfiguration,
0xaf, 0x00, // adjust length as needed
0x04, // number of interfaces
0x01, // configuration value
0x00, // index to string description
0xa0, // attributes
0x32, // maxpower
}
var ConfigurationCDCMIDI = ConfigurationType{
data: configurationCDCMIDI[:],
}
var CDCMIDI = Descriptor{
Device: DeviceCDC.Bytes(),
Configuration: appendSlices([][]byte{
ConfigurationCDCMIDI.Bytes(),
InterfaceAssociationCDC.Bytes(),
InterfaceCDCControl.Bytes(),
ClassSpecificCDCHeader.Bytes(),
ClassSpecificCDCACM.Bytes(),
ClassSpecificCDCUnion.Bytes(),
ClassSpecificCDCCallManagement.Bytes(),
EndpointEP1IN.Bytes(),
InterfaceCDCData.Bytes(),
EndpointEP2OUT.Bytes(),
EndpointEP3IN.Bytes(),
InterfaceAssociationMIDI.Bytes(),
InterfaceAudio.Bytes(),
ClassSpecificAudioInterface.Bytes(),
InterfaceMIDIStreaming.Bytes(),
ClassSpecificMIDIHeader.Bytes(),
ClassSpecificMIDIInJack1.Bytes(),
ClassSpecificMIDIInJack2.Bytes(),
ClassSpecificMIDIOutJack1.Bytes(),
ClassSpecificMIDIOutJack2.Bytes(),
EndpointEP7OUT.Bytes(),
ClassSpecificMIDIOutEndpoint.Bytes(),
EndpointEP6IN.Bytes(),
ClassSpecificMIDIInEndpoint.Bytes(),
}),
}
|