Skip to content

Commit

Permalink
Merge pull request #122 from eZioPan/multi-language-support
Browse files Browse the repository at this point in the history
multi-language STRING Desc support
  • Loading branch information
ryan-summers committed Jul 27, 2023
2 parents e1ddea3 + cf693a0 commit 7ebb10f
Show file tree
Hide file tree
Showing 9 changed files with 705 additions and 42 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Ability to select USB revision ([#116](https://github.com/rust-embedded-community/usb-device/pull/116)).
* Added support for alternate settings on interfaces ([#114](https://github.com/rust-embedded-community/usb-device/pull/114)).
* Added support for architectures without atomics ([#115](https://github.com/rust-embedded-community/usb-device/pull/115)).
* Added support for multi-language STRING desc ([#122](https://github.com/rust-embedded-community/usb-device/pull/122)).
* `UsbDeviceBuilder` has a public `.extra_lang_ids()` method to specify LANGIDs besides ENGLISH_US(0x0409)

### Breaking
* `DescriptorWriter::iad()` now requires a `Option<StringIndex>` to optionally specify a string for describing the function ([#121](https://github.com/rust-embedded-community/usb-device/pull/121))
* `.manufacturer()`, `.product()` and `.serial_number()` of `UsbDeviceBuilder` now require `&[&str]` to specify strings match with each LANGIDs supported by device. ([#122](https://github.com/rust-embedded-community/usb-device/pull/122))

### Changed
* `EndpointType` enum now has fields for isochronous synchronization and usage ([#60](https://github.com/rust-embedded-community/usb-device/pull/60)).
* `descriptor_type::STRING` of `fn get_descriptor()` will send the LANGIDs supported by device, and respond STRING Request with specified LANGID. ([#122](https://github.com/rust-embedded-community/usb-device/pull/122))

## [0.2.9] - 2022-08-02

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repository = "https://github.com/mvirkkunen/usb-device"
[dependencies]
defmt = { version = "0.3", optional = true }
portable-atomic = { version = "1.2.0", default-features = false }
num_enum = { version = "0.6.1", default-features = false }

[dev-dependencies]
rusb = "0.9.1"
Expand Down
3 changes: 2 additions & 1 deletion src/class.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::bus::{InterfaceNumber, StringIndex, UsbBus};
use crate::control;
use crate::control_pipe::ControlPipe;
use crate::descriptor::lang_id::LangID;
use crate::descriptor::{BosWriter, DescriptorWriter};
use crate::endpoint::EndpointAddress;
use crate::{Result, UsbError};
Expand Down Expand Up @@ -43,7 +44,7 @@ pub trait UsbClass<B: UsbBus> {
/// * `index` - A string index allocated earlier with
/// [`UsbAllocator`](crate::bus::UsbBusAllocator).
/// * `lang_id` - The language ID for the string to retrieve.
fn get_string(&self, index: StringIndex, lang_id: u16) -> Option<&str> {
fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str> {
let _ = (index, lang_id);
None
}
Expand Down
7 changes: 1 addition & 6 deletions src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ pub mod descriptor_type {
}

/// String descriptor language IDs.
pub mod lang_id {
/// English (US)
///
/// Recommended for use as the first language ID for compatibility.
pub const ENGLISH_US: u16 = 0x0409;
}
pub mod lang_id;

/// Standard capability descriptor types
#[allow(missing_docs)]
Expand Down
Loading

0 comments on commit 7ebb10f

Please sign in to comment.