embassy-usb-host

Crates

git

Versions

default

Flavors

ReportField

Struct ReportField 

Source
pub struct ReportField {
    pub report_id: u8,
    pub usage_page: u16,
    pub usage_min: u16,
    pub usage_max: u16,
    pub bit_offset: u32,
    pub bit_size: u8,
    pub count: u16,
    pub logical_min: i32,
    pub logical_max: i32,
    pub flags: u8,
}
Expand description

A single logical field decoded from a HID report descriptor.

Fields that share a usage page / page range but represent a single control (axes, single-bit buttons with individual usages) have count == 1. Fields that cover a range of usages (e.g., buttons 1–16) have count > 1 and sequential usage_min..=usage_max; use extract_u32 / extract_bool with the appropriate element index.

Fields§

§report_id: u8

Report ID this field belongs to (0 when the descriptor has no report IDs).

§usage_page: u16

HID usage page (e.g. usage_page::GENERIC_DESKTOP).

§usage_min: u16

First (or only) usage for this field.

§usage_max: u16

Last usage for this field. Equals usage_min for single-usage fields.

§bit_offset: u32

Bit offset of the first element from the start of the report payload (i.e. after the report-ID byte when ReportDescriptor::has_report_ids is true).

§bit_size: u8

Bits per element.

§count: u16

Number of consecutive elements (≥ 1).

§logical_min: i32

Logical minimum (signed).

§logical_max: i32

Logical maximum (signed).

§flags: u8

Input item flags — see the flags module.

Implementations§

Source§

impl ReportField

Source

pub fn is_constant(&self) -> bool

True if this field is padding / carries no data.

Source

pub fn is_variable(&self) -> bool

True if each element represents one control (Variable). False ⇒ Array.

Source

pub fn is_relative(&self) -> bool

True if values are relative (e.g. mouse motion delta).

Source

pub fn is_signed(&self) -> bool

True if values should be interpreted as signed (logical_min < 0).

Source

pub fn index_of_usage(&self, usage: u16) -> Option<usize>

For a range field, return the element index (0-based) corresponding to usage. Returns None if usage is outside usage_min..=usage_max.

Source

pub fn extract_u32(&self, report_payload: &[u8], index: usize) -> Option<u32>

Extract the index-th element as an unsigned integer from report_payload.

report_payload is the raw report bytes without any leading report-ID byte. Returns None if index >= count or the buffer is too short.

Source

pub fn extract_i32(&self, report_payload: &[u8], index: usize) -> Option<i32>

Extract the index-th element as a signed integer.

Sign-extends from bit_size bits when logical_min < 0.

Source

pub fn extract_bool(&self, report_payload: &[u8], index: usize) -> Option<bool>

Extract the index-th element as a bool (non-zero ⇒ true).

Trait Implementations§

Source§

impl Clone for ReportField

Source§

fn clone(&self) -> ReportField

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ReportField

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Format for ReportField

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.