Skip to main content

Crate hid_decode

Crate hid_decode 

Source
Expand description

§HID report descriptor decoding utilities

This library can perform text or structured decoding of USB HID report descriptors. For text decoding, use decode() or TextDecoder. For structured decoding, use decode_items() or ItemDecoder.

The decoders don’t understand the meaning of HID report descriptors, so they can’t be used to automatically determine the size and layout of HID reports.

See Device Class Definition for Human Interface Devices for a detailed description of HID report descriptors.

§Example

let mut output = Vec::new();
hid_decode::decode(&mut output, &GAMEPAD_DESCRIPTOR).expect("write error");
let output = String::try_from(output).expect("non-UTF8 output");
assert_eq!(
    output.lines().collect::<Vec<_>>(),
    [
        "Usage Page: GenericDesktop",
        "Usage: Gamepad",
        "Collection: Application",
        "Usage Page: Button",
        "Usage Minimum: 1",
        "Usage Maximum: 8",
        "Logical Minimum: 0",
        "Logical Maximum: 1",
        "Report Size: 1",
        "Report Count: 8",
        "Input: Data Variable Absolute No-Wrap Linear Preferred-State No-Null-Position Bit-Field",
        "EndCollection",
    ]
);

Re-exports§

pub use crate::item::LengthError;

Modules§

item
Decode a single item inside an HID report descriptor.

Structs§

ItemDecoder
Structured decode of an HID report descriptor.
TextDecoder
Decode an HID report descriptor to plain text.

Functions§

decode
Decode an HID report descriptor to text, using the default settings.
decode_items
Structured decode of an HID report descriptor.