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: u8Report ID this field belongs to (0 when the descriptor has no report IDs).
usage_page: u16HID usage page (e.g. usage_page::GENERIC_DESKTOP).
usage_min: u16First (or only) usage for this field.
usage_max: u16Last usage for this field. Equals usage_min for single-usage fields.
bit_offset: u32Bit 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: u8Bits per element.
count: u16Number of consecutive elements (≥ 1).
logical_min: i32Logical minimum (signed).
logical_max: i32Logical maximum (signed).
flags: u8Input item flags — see the flags module.
Implementations§
Source§impl ReportField
impl ReportField
Sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
True if this field is padding / carries no data.
Sourcepub fn is_variable(&self) -> bool
pub fn is_variable(&self) -> bool
True if each element represents one control (Variable). False ⇒ Array.
Sourcepub fn is_relative(&self) -> bool
pub fn is_relative(&self) -> bool
True if values are relative (e.g. mouse motion delta).
Sourcepub fn is_signed(&self) -> bool
pub fn is_signed(&self) -> bool
True if values should be interpreted as signed (logical_min < 0).
Sourcepub fn index_of_usage(&self, usage: u16) -> Option<usize>
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.
Sourcepub fn extract_u32(&self, report_payload: &[u8], index: usize) -> Option<u32>
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.
Trait Implementations§
Source§impl Clone for ReportField
impl Clone for ReportField
Source§fn clone(&self) -> ReportField
fn clone(&self) -> ReportField
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more