Skip to content

Commit

Permalink
Extended endpoint descriptors to 9 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcebox committed May 25, 2024
1 parent 2ce827a commit 4d49f14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Updated `usb-device` dependency to 0.3.2.
- Updated `num_enum` dependency to 0.7.2.
- Extended endpoint descriptors to 9 bytes as stated in specification.

### Removed

Expand Down
17 changes: 13 additions & 4 deletions src/midi_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ impl<B: UsbBus> UsbClass<B> for MidiClass<'_, B> {
let midi_streaming_total_length = 7
+ (self.n_in_jacks + self.n_out_jacks) as usize
* (MIDI_IN_SIZE + MIDI_OUT_SIZE) as usize
+ 7
+ 9
+ (4 + self.n_out_jacks as usize)
+ 7
+ 9
+ (4 + self.n_in_jacks as usize);

//Streaming extra info
Expand Down Expand Up @@ -206,7 +206,11 @@ impl<B: UsbBus> UsbClass<B> for MidiClass<'_, B> {
0, // jack mappings. must be filled in and cropped.
];

writer.endpoint(&self.standard_bulkout)?; // len = 7
writer.endpoint_ex(&self.standard_bulkout, |data| {
data[0] = 0; // bRefresh
data[1] = 0; // bSynchAddress
Ok(2)
})?; // len = 9

endpoint_data[1] = self.n_out_jacks;
for i in 0..self.n_out_jacks {
Expand All @@ -218,7 +222,12 @@ impl<B: UsbBus> UsbClass<B> for MidiClass<'_, B> {
&endpoint_data[0..2 + self.n_out_jacks as usize],
)?;

writer.endpoint(&self.standard_bulkin)?; // len = 7
writer.endpoint_ex(&self.standard_bulkin, |data| {
data[0] = 0; // bRefresh
data[1] = 0; // bSynchAddress
Ok(2)
})?; // len = 9

endpoint_data[1] = self.n_in_jacks;
for i in 0..self.n_in_jacks {
endpoint_data[2 + i as usize] = self.out_jack_id_emb(i);
Expand Down

0 comments on commit 4d49f14

Please sign in to comment.