Skip to content

Commit 7ebb10f

Browse files
authored
Merge pull request #122 from eZioPan/multi-language-support
multi-language STRING Desc support
2 parents e1ddea3 + cf693a0 commit 7ebb10f

File tree

9 files changed

+705
-42
lines changed

9 files changed

+705
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
* Ability to select USB revision ([#116](https://github.com/rust-embedded-community/usb-device/pull/116)).
1313
* Added support for alternate settings on interfaces ([#114](https://github.com/rust-embedded-community/usb-device/pull/114)).
1414
* Added support for architectures without atomics ([#115](https://github.com/rust-embedded-community/usb-device/pull/115)).
15+
* Added support for multi-language STRING desc ([#122](https://github.com/rust-embedded-community/usb-device/pull/122)).
16+
* `UsbDeviceBuilder` has a public `.extra_lang_ids()` method to specify LANGIDs besides ENGLISH_US(0x0409)
1517

1618
### Breaking
1719
* `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))
20+
* `.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))
1821

1922
### Changed
2023
* `EndpointType` enum now has fields for isochronous synchronization and usage ([#60](https://github.com/rust-embedded-community/usb-device/pull/60)).
24+
* `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))
2125

2226
## [0.2.9] - 2022-08-02
2327

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ repository = "https://github.com/mvirkkunen/usb-device"
1212
[dependencies]
1313
defmt = { version = "0.3", optional = true }
1414
portable-atomic = { version = "1.2.0", default-features = false }
15+
num_enum = { version = "0.6.1", default-features = false }
1516

1617
[dev-dependencies]
1718
rusb = "0.9.1"

src/class.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::bus::{InterfaceNumber, StringIndex, UsbBus};
22
use crate::control;
33
use crate::control_pipe::ControlPipe;
4+
use crate::descriptor::lang_id::LangID;
45
use crate::descriptor::{BosWriter, DescriptorWriter};
56
use crate::endpoint::EndpointAddress;
67
use crate::{Result, UsbError};
@@ -43,7 +44,7 @@ pub trait UsbClass<B: UsbBus> {
4344
/// * `index` - A string index allocated earlier with
4445
/// [`UsbAllocator`](crate::bus::UsbBusAllocator).
4546
/// * `lang_id` - The language ID for the string to retrieve.
46-
fn get_string(&self, index: StringIndex, lang_id: u16) -> Option<&str> {
47+
fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str> {
4748
let _ = (index, lang_id);
4849
None
4950
}

src/descriptor.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ pub mod descriptor_type {
1919
}
2020

2121
/// String descriptor language IDs.
22-
pub mod lang_id {
23-
/// English (US)
24-
///
25-
/// Recommended for use as the first language ID for compatibility.
26-
pub const ENGLISH_US: u16 = 0x0409;
27-
}
22+
pub mod lang_id;
2823

2924
/// Standard capability descriptor types
3025
#[allow(missing_docs)]

0 commit comments

Comments
 (0)