pub struct ReportDescriptor<const N: usize> {
pub has_report_ids: bool,
/* private fields */
}Expand description
Parsed HID report descriptor.
N is the maximum number of input fields to store. A typical gamepad
descriptor produces 8–20 fields; 32 is sufficient for most devices.
Obtain one by calling ReportDescriptor::parse.
Fields§
§has_report_ids: booltrue when the descriptor uses Report ID items.
Each packet from the device will then begin with a one-byte report ID.
Implementations§
Source§impl<const N: usize> ReportDescriptor<N>
impl<const N: usize> ReportDescriptor<N>
Sourcepub fn parse(descriptor: &[u8]) -> Self
pub fn parse(descriptor: &[u8]) -> Self
Parse a raw HID report descriptor byte slice.
Fields beyond the N-th are silently dropped — increase N if needed.
Sourcepub fn fields(&self) -> impl Iterator<Item = &ReportField>
pub fn fields(&self) -> impl Iterator<Item = &ReportField>
Iterate over all parsed Input fields (skips empty slots).
Sourcepub fn find(
&self,
report_id: u8,
page: u16,
usage: u16,
) -> Option<(&ReportField, usize)>
pub fn find( &self, report_id: u8, page: u16, usage: u16, ) -> Option<(&ReportField, usize)>
Find the Input field whose usage range contains usage on the given
usage_page, for the given report_id.
Returns a reference to the field and the element index within it.
Sourcepub fn extract_i32(
&self,
report: &[u8],
report_id: u8,
page: u16,
usage: u16,
) -> Option<i32>
pub fn extract_i32( &self, report: &[u8], report_id: u8, page: u16, usage: u16, ) -> Option<i32>
Extract a signed value for the given usage from a complete report packet.
report is the full packet received from the interrupt IN endpoint,
including the leading report-ID byte if has_report_ids is true.
Returns None if the field is not found, the buffer is too short, or
(when has_report_ids) report[0] does not match report_id.
Sourcepub fn extract_u32(
&self,
report: &[u8],
report_id: u8,
page: u16,
usage: u16,
) -> Option<u32>
pub fn extract_u32( &self, report: &[u8], report_id: u8, page: u16, usage: u16, ) -> Option<u32>
Extract an unsigned value for the given usage. See extract_i32 for details.