Skip to main content

Crate hid_decode

Crate hid_decode 

Source
Expand description

§HID report descriptor decoding utilities

This library can perform text decoding of USB HID report descriptors.

It does not perform stateful functional decoding, so it can’t (yet) 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.iter().copied()).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",
    ]
);

Structs§

DecoderContext
HID Decoder state.
Verbosity
Configuration for decoding descriptors to text.

Enums§

LengthError
An error that resulted from improper item encoding.

Functions§

decode
Decode HID descriptor bytes as text.
decode_with_options
Decode HID descriptor bytes as text.