Skip to content

Commit

Permalink
Add default functions to MouseReport, MediaKeyboardReport and SystemC…
Browse files Browse the repository at this point in the history
…ontrolReport

It was already there for KeyboardReport where documentation is added to
the function
  • Loading branch information
borisfaure committed Apr 23, 2024
1 parent 76bea16 commit 5a65ebb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ pub struct MouseReport {
pub pan: i8, // Scroll left (negative) or right (positive) this many units
}

impl MouseReport {
/// Create a new MouseReport with all fields set to zero.
pub const fn default() -> Self {
Self {
buttons: 0,
x: 0,
y: 0,
wheel: 0,
pan: 0,
}
}
}

/// KeyboardReport describes a report and its companion descriptor that can be
/// used to send keyboard button presses to a host and receive the status of the
/// keyboard LEDs.
Expand Down Expand Up @@ -84,6 +97,7 @@ pub struct KeyboardReport {
}

impl KeyboardReport {
/// Create a new KeyboardReport with all fields set to zero.
pub const fn default() -> Self {
Self {
modifier: 0,
Expand Down Expand Up @@ -798,6 +812,13 @@ pub struct MediaKeyboardReport {
pub usage_id: u16,
}

impl MediaKeyboardReport {
/// Create a new MediaKeyboardReport with all fields set to 0
pub const fn default() -> Self {
Self { usage_id: 0 }
}
}

/// Media player usage ids that can be used in MediaKeyboardReport
#[non_exhaustive]
#[repr(u16)]
Expand Down Expand Up @@ -875,6 +896,13 @@ pub struct SystemControlReport {
pub usage_id: u8,
}

impl SystemControlReport {
/// Create a new SystemControlReport with all fields set to 0
pub const fn default() -> Self {
Self { usage_id: 0 }
}
}

/// System control usage ids to use with SystemControlReport
#[non_exhaustive]
#[repr(u8)]
Expand Down

0 comments on commit 5a65ebb

Please sign in to comment.