diff --git a/src/descriptor.rs b/src/descriptor.rs index c1a8e0c..e465e7a 100644 --- a/src/descriptor.rs +++ b/src/descriptor.rs @@ -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. @@ -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, @@ -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)] @@ -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)]