diff options
| author | matteo <email> | 2025-09-21 18:00:32 +0200 |
|---|---|---|
| committer | matteo <email> | 2025-09-21 18:00:32 +0200 |
| commit | 2cf7cc4c92fe0f7897513286e4bce944870e1bad (patch) | |
| tree | 1c9ca94fae6c37801836492135212f4b9655275d /embassy-usb | |
| parent | 5f5f71efd09266eccb0ab7e4048994f244eed5ae (diff) | |
fix compilation with usbd-hid feature off
Diffstat (limited to 'embassy-usb')
| -rw-r--r-- | embassy-usb/src/class/hid.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/embassy-usb/src/class/hid.rs b/embassy-usb/src/class/hid.rs index 8df23b384..f97bcdfac 100644 --- a/embassy-usb/src/class/hid.rs +++ b/embassy-usb/src/class/hid.rs | |||
| @@ -8,6 +8,7 @@ use core::sync::atomic::{AtomicUsize, Ordering}; | |||
| 8 | use ssmarshal::serialize; | 8 | use ssmarshal::serialize; |
| 9 | #[cfg(feature = "usbd-hid")] | 9 | #[cfg(feature = "usbd-hid")] |
| 10 | use usbd_hid::descriptor::AsInputReport; | 10 | use usbd_hid::descriptor::AsInputReport; |
| 11 | #[cfg(feature = "usbd-hid")] | ||
| 11 | use usbd_hid::hid_class::HidProtocolMode; | 12 | use usbd_hid::hid_class::HidProtocolMode; |
| 12 | 13 | ||
| 13 | use crate::control::{InResponse, OutResponse, Recipient, Request, RequestType}; | 14 | use crate::control::{InResponse, OutResponse, Recipient, Request, RequestType}; |
| @@ -32,6 +33,30 @@ const HID_REQ_SET_REPORT: u8 = 0x09; | |||
| 32 | const HID_REQ_GET_PROTOCOL: u8 = 0x03; | 33 | const HID_REQ_GET_PROTOCOL: u8 = 0x03; |
| 33 | const HID_REQ_SET_PROTOCOL: u8 = 0x0b; | 34 | const HID_REQ_SET_PROTOCOL: u8 = 0x0b; |
| 34 | 35 | ||
| 36 | /// Get/Set Protocol mapping | ||
| 37 | /// See (7.2.5 and 7.2.6): <https://www.usb.org/sites/default/files/hid1_11.pdf> | ||
| 38 | #[cfg(not(feature = "usbd-hid"))] | ||
| 39 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] | ||
| 40 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 41 | #[repr(u8)] | ||
| 42 | pub enum HidProtocolMode { | ||
| 43 | /// Hid Boot Protocol Mode | ||
| 44 | Boot = 0, | ||
| 45 | /// Hid Report Protocol Mode | ||
| 46 | Report = 1, | ||
| 47 | } | ||
| 48 | |||
| 49 | #[cfg(not(feature = "usbd-hid"))] | ||
| 50 | impl From<u8> for HidProtocolMode { | ||
| 51 | fn from(mode: u8) -> HidProtocolMode { | ||
| 52 | if mode == HidProtocolMode::Boot as u8 { | ||
| 53 | HidProtocolMode::Boot | ||
| 54 | } else { | ||
| 55 | HidProtocolMode::Report | ||
| 56 | } | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 35 | /// Configuration for the HID class. | 60 | /// Configuration for the HID class. |
| 36 | pub struct Config<'d> { | 61 | pub struct Config<'d> { |
| 37 | /// HID report descriptor. | 62 | /// HID report descriptor. |
