usbd_human_interface_device/
descriptor.rs1use num_enum::{IntoPrimitive, TryFromPrimitive};
3use packed_struct::prelude::*;
4
5pub(crate) const USB_CLASS_HID: u8 = 0x03;
6pub(crate) const SPEC_VERSION_1_11: u16 = 0x0111; pub(crate) const COUNTRY_CODE_NOT_SUPPORTED: u8 = 0x0;
8
9#[cfg_attr(feature = "defmt", derive(defmt::Format))]
10#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, TryFromPrimitive, IntoPrimitive)]
11#[repr(u8)]
12pub enum InterfaceProtocol {
13 None = 0x00,
14 Keyboard = 0x01,
15 Mouse = 0x02,
16}
17
18#[cfg_attr(feature = "defmt", derive(defmt::Format))]
19#[derive(Debug, Clone, Copy, PartialEq, Eq, PrimitiveEnum, TryFromPrimitive, IntoPrimitive)]
20#[repr(u8)]
21pub(crate) enum DescriptorType {
22 Hid = 0x21,
23 Report = 0x22,
24}
25
26#[cfg_attr(feature = "defmt", derive(defmt::Format))]
27#[derive(Clone, Copy, Debug, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)]
28#[repr(u8)]
29pub(crate) enum InterfaceSubClass {
30 None = 0x00,
31 Boot = 0x01,
32}
33
34impl From<InterfaceProtocol> for InterfaceSubClass {
35 fn from(protocol: InterfaceProtocol) -> Self {
36 if protocol == InterfaceProtocol::None {
37 Self::None
38 } else {
39 Self::Boot
40 }
41 }
42}
43
44#[cfg_attr(feature = "defmt", derive(defmt::Format))]
45#[derive(Debug, Clone, Copy, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)]
46#[repr(u8)]
47pub enum HidProtocol {
48 Boot = 0x00,
49 Report = 0x01,
50}
51
52#[cfg_attr(feature = "defmt", derive(defmt::Format))]
53#[derive(Clone, Copy, Debug, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)]
54#[repr(u8)]
55pub(crate) enum HidRequest {
56 GetReport = 0x01,
57 GetIdle = 0x02,
58 GetProtocol = 0x03,
59 SetReport = 0x09,
60 SetIdle = 0x0A,
61 SetProtocol = 0x0B,
62}