pub fn usage_maximum(value: impl Into<u16>) -> DescriptorBytesExpand description
Create a Usage Maximum value.
Note: this does not implement the “extended usage” format which also contains a usage page.
Examples found in repository?
examples/gamepad.rs (line 17)
7fn main() {
8 // This describes a gamepad that has 8 buttons.
9 let bytes = [
10 usage_page(KnownUsagePage::GenericDesktop),
11 usage(generic_desktop::KnownUsage::Gamepad),
12 collection(KnownCollectionType::Application),
13 // Instead of adding a Usage parameter for each button,
14 // we describe an array of buttons, numbered 1 to 8.
15 usage_page(KnownUsagePage::Button),
16 usage_minimum(1u16),
17 usage_maximum(8u16),
18 // A button state is either 0 or 1.
19 logical_minimum(0),
20 logical_maximum(1),
21 // Each button is 1 bit; the report struct contains 8 of them.
22 report_size(1),
23 report_count(8),
24 input(IoFlags::data().variable()),
25 end_collection(),
26 ];
27 println!("writing gamepad descriptor to {FILENAME}");
28 write_to_file(bytes, FILENAME).unwrap();
29}More examples
examples/keyboard.rs (line 21)
8fn main() {
9 // This is the keyboard descriptor provided by the Device Class Definition
10 // for Human Interface Devices (HID) specification, Appendix B.
11 let bytes = [
12 usage_page(KnownUsagePage::GenericDesktop),
13 usage(generic_desktop::KnownUsage::Keyboard),
14 collection(KnownCollectionType::Application),
15 // 8 modifier keys (Left Ctrl/Shift/Alt/Gui, Right Ctrl/Shift/Alt/Gui)
16 // each get their own dedicated bit in the report.
17 report_size(1),
18 report_count(8),
19 usage_page(KnownUsagePage::KeyboardKeypad),
20 usage_minimum(KnownUsage::LeftControl),
21 usage_maximum(KnownUsage::RightGui),
22 logical_minimum(0),
23 logical_maximum(1),
24 input(ioflags::DATA_VARIABLE_ABSOLUTE),
25 // A padding byte in the input report, for legacy compatibility.
26 report_count(1),
27 report_size(8),
28 input(ioflags::CONSTANT),
29 // 5 status LEDs, and 3 padding bits.
30 report_count(5),
31 report_size(1),
32 usage_page(KnownUsagePage::Led),
33 usage_minimum(1u16),
34 usage_maximum(5u16),
35 output(ioflags::DATA_VARIABLE_ABSOLUTE),
36 report_count(1),
37 report_size(3),
38 output(ioflags::CONSTANT),
39 // An array of (up to) 6 active keys.
40 report_count(6),
41 report_size(8),
42 logical_minimum(0),
43 logical_maximum(255),
44 usage_page(KnownUsagePage::KeyboardKeypad),
45 usage_minimum(0u16),
46 usage_maximum(255u16),
47 input(ioflags::ARRAY),
48 end_collection(),
49 ];
50 println!("writing keyboard descriptor to {FILENAME}");
51 write_to_file(bytes, FILENAME).unwrap();
52}