extern crate usbd_hid_macros;
pub use usbd_hid_macros::gen_hid_descriptor;
pub trait SerializedDescriptor {
fn desc() -> &'static [u8];
}
pub trait AsInputReport {
fn serialize(&self, buffer: &mut [u8]) -> Result<usize, BufferOverflow>;
}
#[derive(Debug)]
pub struct BufferOverflow;
pub mod generator_prelude {
pub use crate::descriptor::{AsInputReport, SerializedDescriptor};
pub use usbd_hid_macros::gen_hid_descriptor;
}
#[gen_hid_descriptor(
(collection = APPLICATION, usage_page = GENERIC_DESKTOP, usage = MOUSE) = {
(collection = PHYSICAL, usage = POINTER) = {
(usage_page = BUTTON, usage_min = BUTTON_1, usage_max = BUTTON_8) = {
#[packed_bits = 8] #[item_settings(data,variable,absolute)] buttons=input;
};
(usage_page = GENERIC_DESKTOP,) = {
(usage = X,) = {
#[item_settings(data,variable,relative)] x=input;
};
(usage = Y,) = {
#[item_settings(data,variable,relative)] y=input;
};
(usage = WHEEL,) = {
#[item_settings(data,variable,relative)] wheel=input;
};
};
(usage_page = CONSUMER,) = {
(usage = AC_PAN,) = {
#[item_settings(data,variable,relative)] pan=input;
};
};
};
}
)]
#[allow(dead_code)]
pub struct MouseReport {
pub buttons: u8,
pub x: i8,
pub y: i8,
pub wheel: i8, pub pan: i8, }
#[gen_hid_descriptor(
(collection = APPLICATION, usage_page = GENERIC_DESKTOP, usage = KEYBOARD) = {
(usage_page = KEYBOARD, usage_min = 0xE0, usage_max = 0xE7) = {
#[packed_bits = 8] #[item_settings(data,variable,absolute)] modifier=input;
};
(usage_min = 0x00, usage_max = 0xFF) = {
#[item_settings(constant,variable,absolute)] reserved=input;
};
(usage_page = LEDS, usage_min = 0x01, usage_max = 0x05) = {
#[packed_bits = 5] #[item_settings(data,variable,absolute)] leds=output;
};
(usage_page = KEYBOARD, usage_min = 0x00, usage_max = 0xDD) = {
#[item_settings(data,array,absolute)] keycodes=input;
};
}
)]
#[allow(dead_code)]
pub struct KeyboardReport {
pub modifier: u8,
pub reserved: u8,
pub leds: u8,
pub keycodes: [u8; 6],
}
impl KeyboardReport {
pub const fn default() -> Self {
Self {
modifier: 0,
reserved: 0,
leds: 0,
keycodes: [0u8; 6],
}
}
}
#[repr(u8)]
#[allow(unused)]
#[non_exhaustive]
#[derive(Copy, Debug, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum KeyboardUsage {
KeyboardErrorRollOver = 0x01,
KeyboardPOSTFail = 0x02,
KeyboardErrorUndefined = 0x03,
KeyboardAa = 0x04,
KeyboardBb = 0x05,
KeyboardCc = 0x06,
KeyboardDd = 0x07,
KeyboardEe = 0x08,
KeyboardFf = 0x09,
KeyboardGg = 0x0A,
KeyboardHh = 0x0B,
KeyboardIi = 0x0C,
KeyboardJj = 0x0D,
KeyboardKk = 0x0E,
KeyboardLl = 0x0F,
KeyboardMm = 0x10,
KeyboardNn = 0x11,
KeyboardOo = 0x12,
KeyboardPp = 0x13,
KeyboardQq = 0x14,
KeyboardRr = 0x15,
KeyboardSs = 0x16,
KeyboardTt = 0x17,
KeyboardUu = 0x18,
KeyboardVv = 0x19,
KeyboardWw = 0x1A,
KeyboardXx = 0x1B,
KeyboardYy = 0x1C,
KeyboardZz = 0x1D,
Keyboard1Exclamation = 0x1E,
Keyboard2At = 0x1F,
Keyboard3Hash = 0x20,
Keyboard4Dollar = 0x21,
Keyboard5Percent = 0x22,
Keyboard6Caret = 0x23,
Keyboard7Ampersand = 0x24,
Keyboard8Asterisk = 0x25,
Keyboard9OpenParens = 0x26,
Keyboard0CloseParens = 0x27,
KeyboardEnter = 0x28,
KeyboardEscape = 0x29,
KeyboardBackspace = 0x2A,
KeyboardTab = 0x2B,
KeyboardSpacebar = 0x2C,
KeyboardDashUnderscore = 0x2D,
KeyboardEqualPlus = 0x2E,
KeyboardOpenBracketBrace = 0x2F,
KeyboardCloseBracketBrace = 0x30,
KeyboardBackslashBar = 0x31,
KeyboardNonUSHash = 0x32,
KeyboardSemiColon = 0x33,
KeyboardSingleDoubleQuote = 0x34,
KeyboardBacktickTilde = 0x35,
KeyboardCommaLess = 0x36,
KeyboardPeriodGreater = 0x37,
KeyboardSlashQuestion = 0x38,
KeyboardCapsLock = 0x39,
KeyboardF1 = 0x3A,
KeyboardF2 = 0x3B,
KeyboardF3 = 0x3C,
KeyboardF4 = 0x3D,
KeyboardF5 = 0x3E,
KeyboardF6 = 0x3F,
KeyboardF7 = 0x40,
KeyboardF8 = 0x41,
KeyboardF9 = 0x42,
KeyboardF10 = 0x43,
KeyboardF11 = 0x44,
KeyboardF12 = 0x45,
KeyboardPrintScreen = 0x46,
KeyboardScrollLock = 0x47,
KeyboardPause = 0x48,
KeyboardInsert = 0x49,
KeyboardHome = 0x4A,
KeyboardPageUp = 0x4B,
KeyboardDelete = 0x4C,
KeyboardEnd = 0x4D,
KeyboardPageDown = 0x4E,
KeyboardRightArrow = 0x4F,
KeyboardLeftArrow = 0x50,
KeyboardDownArrow = 0x51,
KeyboardUpArrow = 0x52,
KeypadNumLock = 0x53,
KeypadDivide = 0x54,
KeypadMultiply = 0x55,
KeypadMinus = 0x56,
KeypadPlus = 0x57,
KeypadEnter = 0x58,
Keypad1End = 0x59,
Keypad2DownArrow = 0x5A,
Keypad3PageDown = 0x5B,
Keypad4LeftArrow = 0x5C,
Keypad5 = 0x5D,
Keypad6RightArrow = 0x5E,
Keypad7Home = 0x5F,
Keypad8UpArrow = 0x60,
Keypad9PageUp = 0x61,
Keypad0Insert = 0x62,
KeypadPeriodDelete = 0x63,
KeyboardNonUSSlash = 0x64,
KeyboardApplication = 0x65,
KeyboardPower = 0x66,
KeypadEqual = 0x67,
KeyboardF13 = 0x68,
KeyboardF14 = 0x69,
KeyboardF15 = 0x6A,
KeyboardF16 = 0x6B,
KeyboardF17 = 0x6C,
KeyboardF18 = 0x6D,
KeyboardF19 = 0x6E,
KeyboardF20 = 0x6F,
KeyboardF21 = 0x70,
KeyboardF22 = 0x71,
KeyboardF23 = 0x72,
KeyboardF24 = 0x73,
KeyboardExecute = 0x74,
KeyboardHelp = 0x75,
KeyboardMenu = 0x76,
KeyboardSelect = 0x77,
KeyboardStop = 0x78,
KeyboardAgain = 0x79,
KeyboardUndo = 0x7A,
KeyboardCut = 0x7B,
KeyboardCopy = 0x7C,
KeyboardPaste = 0x7D,
KeyboardFind = 0x7E,
KeyboardMute = 0x7F,
KeyboardVolumeUp = 0x80,
KeyboardVolumeDown = 0x81,
KeyboardLockingCapsLock = 0x82,
KeyboardLockingNumLock = 0x83,
KeyboardLockingScrollLock = 0x84,
KeypadComma = 0x85,
KeypadEqualSign = 0x86,
KeyboardInternational1 = 0x87,
KeyboardInternational2 = 0x88,
KeyboardInternational3 = 0x89,
KeyboardInternational4 = 0x8A,
KeyboardInternational5 = 0x8B,
KeyboardInternational6 = 0x8C,
KeyboardInternational7 = 0x8D,
KeyboardInternational8 = 0x8E,
KeyboardInternational9 = 0x8F,
KeyboardLANG1 = 0x90,
KeyboardLANG2 = 0x91,
KeyboardLANG3 = 0x92,
KeyboardLANG4 = 0x93,
KeyboardLANG5 = 0x94,
KeyboardLANG6 = 0x95,
KeyboardLANG7 = 0x96,
KeyboardLANG8 = 0x97,
KeyboardLANG9 = 0x98,
KeyboardAlternateErase = 0x99,
KeyboardSysReqAttention = 0x9A,
KeyboardCancel = 0x9B,
KeyboardClear = 0x9C,
KeyboardPrior = 0x9D,
KeyboardReturn = 0x9E,
KeyboardSeparator = 0x9F,
KeyboardOut = 0xA0,
KeyboardOper = 0xA1,
KeyboardClearAgain = 0xA2,
KeyboardCrSelProps = 0xA3,
KeyboardExSel = 0xA4,
Keypad00 = 0xB0,
Keypad000 = 0xB1,
ThousandsSeparator = 0xB2,
DecimalSeparator = 0xB3,
CurrencyUnit = 0xB4,
CurrencySubunit = 0xB5,
KeypadOpenParens = 0xB6,
KeypadCloseParens = 0xB7,
KeypadOpenBrace = 0xB8,
KeypadCloseBrace = 0xB9,
KeypadTab = 0xBA,
KeypadBackspace = 0xBB,
KeypadA = 0xBC,
KeypadB = 0xBD,
KeypadC = 0xBE,
KeypadD = 0xBF,
KeypadE = 0xC0,
KeypadF = 0xC1,
KeypadBitwiseXor = 0xC2,
KeypadLogicalXor = 0xC3,
KeypadModulo = 0xC4,
KeypadLeftShift = 0xC5,
KeypadRightShift = 0xC6,
KeypadBitwiseAnd = 0xC7,
KeypadLogicalAnd = 0xC8,
KeypadBitwiseOr = 0xC9,
KeypadLogicalOr = 0xCA,
KeypadColon = 0xCB,
KeypadHash = 0xCC,
KeypadSpace = 0xCD,
KeypadAt = 0xCE,
KeypadExclamation = 0xCF,
KeypadMemoryStore = 0xD0,
KeypadMemoryRecall = 0xD1,
KeypadMemoryClear = 0xD2,
KeypadMemoryAdd = 0xD3,
KeypadMemorySubtract = 0xD4,
KeypadMemoryMultiply = 0xD5,
KeypadMemoryDivide = 0xD6,
KeypadPositiveNegative = 0xD7,
KeypadClear = 0xD8,
KeypadClearEntry = 0xD9,
KeypadBinary = 0xDA,
KeypadOctal = 0xDB,
KeypadDecimal = 0xDC,
KeypadHexadecimal = 0xDD,
KeyboardLeftControl = 0xE0,
KeyboardLeftShift = 0xE1,
KeyboardLeftAlt = 0xE2,
KeyboardLeftGUI = 0xE3,
KeyboardRightControl = 0xE4,
KeyboardRightShift = 0xE5,
KeyboardRightAlt = 0xE6,
KeyboardRightGUI = 0xE7,
Reserved = 0xE8,
}
impl From<u8> for KeyboardUsage {
fn from(k: u8) -> Self {
match k {
0x01 => Self::KeyboardErrorRollOver,
0x02 => Self::KeyboardPOSTFail,
0x03 => Self::KeyboardErrorUndefined,
0x04 => Self::KeyboardAa,
0x05 => Self::KeyboardBb,
0x06 => Self::KeyboardCc,
0x07 => Self::KeyboardDd,
0x08 => Self::KeyboardEe,
0x09 => Self::KeyboardFf,
0x0A => Self::KeyboardGg,
0x0B => Self::KeyboardHh,
0x0C => Self::KeyboardIi,
0x0D => Self::KeyboardJj,
0x0E => Self::KeyboardKk,
0x0F => Self::KeyboardLl,
0x10 => Self::KeyboardMm,
0x11 => Self::KeyboardNn,
0x12 => Self::KeyboardOo,
0x13 => Self::KeyboardPp,
0x14 => Self::KeyboardQq,
0x15 => Self::KeyboardRr,
0x16 => Self::KeyboardSs,
0x17 => Self::KeyboardTt,
0x18 => Self::KeyboardUu,
0x19 => Self::KeyboardVv,
0x1A => Self::KeyboardWw,
0x1B => Self::KeyboardXx,
0x1C => Self::KeyboardYy,
0x1D => Self::KeyboardZz,
0x1E => Self::Keyboard1Exclamation,
0x1F => Self::Keyboard2At,
0x20 => Self::Keyboard3Hash,
0x21 => Self::Keyboard4Dollar,
0x22 => Self::Keyboard5Percent,
0x23 => Self::Keyboard6Caret,
0x24 => Self::Keyboard7Ampersand,
0x25 => Self::Keyboard8Asterisk,
0x26 => Self::Keyboard9OpenParens,
0x27 => Self::Keyboard0CloseParens,
0x28 => Self::KeyboardEnter,
0x29 => Self::KeyboardEscape,
0x2A => Self::KeyboardBackspace,
0x2B => Self::KeyboardTab,
0x2C => Self::KeyboardSpacebar,
0x2D => Self::KeyboardDashUnderscore,
0x2E => Self::KeyboardEqualPlus,
0x2F => Self::KeyboardOpenBracketBrace,
0x30 => Self::KeyboardCloseBracketBrace,
0x31 => Self::KeyboardBackslashBar,
0x32 => Self::KeyboardNonUSHash,
0x33 => Self::KeyboardSemiColon,
0x34 => Self::KeyboardSingleDoubleQuote,
0x35 => Self::KeyboardBacktickTilde,
0x36 => Self::KeyboardCommaLess,
0x37 => Self::KeyboardPeriodGreater,
0x38 => Self::KeyboardSlashQuestion,
0x39 => Self::KeyboardCapsLock,
0x3A => Self::KeyboardF1,
0x3B => Self::KeyboardF2,
0x3C => Self::KeyboardF3,
0x3D => Self::KeyboardF4,
0x3E => Self::KeyboardF5,
0x3F => Self::KeyboardF6,
0x40 => Self::KeyboardF7,
0x41 => Self::KeyboardF8,
0x42 => Self::KeyboardF9,
0x43 => Self::KeyboardF10,
0x44 => Self::KeyboardF11,
0x45 => Self::KeyboardF12,
0x46 => Self::KeyboardPrintScreen,
0x47 => Self::KeyboardScrollLock,
0x48 => Self::KeyboardPause,
0x49 => Self::KeyboardInsert,
0x4A => Self::KeyboardHome,
0x4B => Self::KeyboardPageUp,
0x4C => Self::KeyboardDelete,
0x4D => Self::KeyboardEnd,
0x4E => Self::KeyboardPageDown,
0x4F => Self::KeyboardRightArrow,
0x50 => Self::KeyboardLeftArrow,
0x51 => Self::KeyboardDownArrow,
0x52 => Self::KeyboardUpArrow,
0x53 => Self::KeypadNumLock,
0x54 => Self::KeypadDivide,
0x55 => Self::KeypadMultiply,
0x56 => Self::KeypadMinus,
0x57 => Self::KeypadPlus,
0x58 => Self::KeypadEnter,
0x59 => Self::Keypad1End,
0x5A => Self::Keypad2DownArrow,
0x5B => Self::Keypad3PageDown,
0x5C => Self::Keypad4LeftArrow,
0x5D => Self::Keypad5,
0x5E => Self::Keypad6RightArrow,
0x5F => Self::Keypad7Home,
0x60 => Self::Keypad8UpArrow,
0x61 => Self::Keypad9PageUp,
0x62 => Self::Keypad0Insert,
0x63 => Self::KeypadPeriodDelete,
0x64 => Self::KeyboardNonUSSlash,
0x65 => Self::KeyboardApplication,
0x66 => Self::KeyboardPower,
0x67 => Self::KeypadEqual,
0x68 => Self::KeyboardF13,
0x69 => Self::KeyboardF14,
0x6A => Self::KeyboardF15,
0x6B => Self::KeyboardF16,
0x6C => Self::KeyboardF17,
0x6D => Self::KeyboardF18,
0x6E => Self::KeyboardF19,
0x6F => Self::KeyboardF20,
0x70 => Self::KeyboardF21,
0x71 => Self::KeyboardF22,
0x72 => Self::KeyboardF23,
0x73 => Self::KeyboardF24,
0x74 => Self::KeyboardExecute,
0x75 => Self::KeyboardHelp,
0x76 => Self::KeyboardMenu,
0x77 => Self::KeyboardSelect,
0x78 => Self::KeyboardStop,
0x79 => Self::KeyboardAgain,
0x7A => Self::KeyboardUndo,
0x7B => Self::KeyboardCut,
0x7C => Self::KeyboardCopy,
0x7D => Self::KeyboardPaste,
0x7E => Self::KeyboardFind,
0x7F => Self::KeyboardMute,
0x80 => Self::KeyboardVolumeUp,
0x81 => Self::KeyboardVolumeDown,
0x82 => Self::KeyboardLockingCapsLock,
0x83 => Self::KeyboardLockingNumLock,
0x84 => Self::KeyboardLockingScrollLock,
0x85 => Self::KeypadComma,
0x86 => Self::KeypadEqualSign,
0x87 => Self::KeyboardInternational1,
0x88 => Self::KeyboardInternational2,
0x89 => Self::KeyboardInternational3,
0x8A => Self::KeyboardInternational4,
0x8B => Self::KeyboardInternational5,
0x8C => Self::KeyboardInternational6,
0x8D => Self::KeyboardInternational7,
0x8E => Self::KeyboardInternational8,
0x8F => Self::KeyboardInternational9,
0x90 => Self::KeyboardLANG1,
0x91 => Self::KeyboardLANG2,
0x92 => Self::KeyboardLANG3,
0x93 => Self::KeyboardLANG4,
0x94 => Self::KeyboardLANG5,
0x95 => Self::KeyboardLANG6,
0x96 => Self::KeyboardLANG7,
0x97 => Self::KeyboardLANG8,
0x98 => Self::KeyboardLANG9,
0x99 => Self::KeyboardAlternateErase,
0x9A => Self::KeyboardSysReqAttention,
0x9B => Self::KeyboardCancel,
0x9C => Self::KeyboardClear,
0x9D => Self::KeyboardPrior,
0x9E => Self::KeyboardReturn,
0x9F => Self::KeyboardSeparator,
0xA0 => Self::KeyboardOut,
0xA1 => Self::KeyboardOper,
0xA2 => Self::KeyboardClearAgain,
0xA3 => Self::KeyboardCrSelProps,
0xA4 => Self::KeyboardExSel,
0xB0 => Self::Keypad00,
0xB1 => Self::Keypad000,
0xB2 => Self::ThousandsSeparator,
0xB3 => Self::DecimalSeparator,
0xB4 => Self::CurrencyUnit,
0xB5 => Self::CurrencySubunit,
0xB6 => Self::KeypadOpenParens,
0xB7 => Self::KeypadCloseParens,
0xB8 => Self::KeypadOpenBrace,
0xB9 => Self::KeypadCloseBrace,
0xBA => Self::KeypadTab,
0xBB => Self::KeypadBackspace,
0xBC => Self::KeypadA,
0xBD => Self::KeypadB,
0xBE => Self::KeypadC,
0xBF => Self::KeypadD,
0xC0 => Self::KeypadE,
0xC1 => Self::KeypadF,
0xC2 => Self::KeypadBitwiseXor,
0xC3 => Self::KeypadLogicalXor,
0xC4 => Self::KeypadModulo,
0xC5 => Self::KeypadLeftShift,
0xC6 => Self::KeypadRightShift,
0xC7 => Self::KeypadBitwiseAnd,
0xC8 => Self::KeypadLogicalAnd,
0xC9 => Self::KeypadBitwiseOr,
0xCA => Self::KeypadLogicalOr,
0xCB => Self::KeypadColon,
0xCC => Self::KeypadHash,
0xCD => Self::KeypadSpace,
0xCE => Self::KeypadAt,
0xCF => Self::KeypadExclamation,
0xD0 => Self::KeypadMemoryStore,
0xD1 => Self::KeypadMemoryRecall,
0xD2 => Self::KeypadMemoryClear,
0xD3 => Self::KeypadMemoryAdd,
0xD4 => Self::KeypadMemorySubtract,
0xD5 => Self::KeypadMemoryMultiply,
0xD6 => Self::KeypadMemoryDivide,
0xD7 => Self::KeypadPositiveNegative,
0xD8 => Self::KeypadClear,
0xD9 => Self::KeypadClearEntry,
0xDA => Self::KeypadBinary,
0xDB => Self::KeypadOctal,
0xDC => Self::KeypadDecimal,
0xDD => Self::KeypadHexadecimal,
0xE0 => Self::KeyboardLeftControl,
0xE1 => Self::KeyboardLeftShift,
0xE2 => Self::KeyboardLeftAlt,
0xE3 => Self::KeyboardLeftGUI,
0xE4 => Self::KeyboardRightControl,
0xE5 => Self::KeyboardRightShift,
0xE6 => Self::KeyboardRightAlt,
0xE7 => Self::KeyboardRightGUI,
_ => Self::Reserved,
}
}
}
#[gen_hid_descriptor(
(collection = APPLICATION, usage_page = CONSUMER, usage = CONSUMER_CONTROL) = {
(usage_page = CONSUMER, usage_min = 0x00, usage_max = 0x514) = {
#[item_settings(data,array,absolute,not_null)] usage_id=input;
};
}
)]
#[allow(dead_code)]
pub struct MediaKeyboardReport {
pub usage_id: u16,
}
#[non_exhaustive]
#[repr(u16)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum MediaKey {
Zero = 0x00,
Play = 0xB0,
Pause = 0xB1,
Record = 0xB2,
NextTrack = 0xB5,
PrevTrack = 0xB6,
Stop = 0xB7,
RandomPlay = 0xB9,
Repeat = 0xBC,
PlayPause = 0xCD,
Mute = 0xE2,
VolumeIncrement = 0xE9,
VolumeDecrement = 0xEA,
Reserved = 0xEB,
}
impl From<MediaKey> for u16 {
fn from(mk: MediaKey) -> u16 {
mk as u16
}
}
impl From<u8> for MediaKey {
fn from(k: u8) -> Self {
match k {
0x00 => Self::Zero,
0xB0 => Self::Play,
0xB1 => Self::Pause,
0xB2 => Self::Record,
0xB5 => Self::NextTrack,
0xB6 => Self::PrevTrack,
0xB7 => Self::Stop,
0xB9 => Self::RandomPlay,
0xBC => Self::Repeat,
0xCD => Self::PlayPause,
0xE2 => Self::Mute,
0xE9 => Self::VolumeIncrement,
0xEA => Self::VolumeDecrement,
_ => Self::Reserved,
}
}
}
impl From<u16> for MediaKey {
fn from(k: u16) -> Self {
(k as u8).into()
}
}
#[gen_hid_descriptor(
(collection = APPLICATION, usage_page = GENERIC_DESKTOP, usage = SYSTEM_CONTROL) = {
(usage_min = 0x81, usage_max = 0xB7, logical_min = 1) = {
#[item_settings(data,array,absolute,not_null)] usage_id=input;
};
}
)]
#[allow(dead_code)]
pub struct SystemControlReport {
pub usage_id: u8,
}
#[non_exhaustive]
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SystemControlKey {
PowerDown = 0x81,
Sleep = 0x82,
WakeUp = 0x83,
ContextMenu = 0x84,
MainMenu = 0x85,
AppMenu = 0x86,
MenuHelp = 0x87,
MenuExit = 0x88,
MenuSelect = 0x89,
MenuRight = 0x8A,
MenuLeft = 0x8B,
MenuUp = 0x8C,
MenuDown = 0x8D,
ColdRestart = 0x8E,
WarmRestart = 0x8F,
DpadUp = 0x90,
DpadDown = 0x91,
DpadRight = 0x92,
DpadLeft = 0x93,
SystemFunctionShift = 0x97,
SystemFunctionShiftLock = 0x98,
SystemDismissNotification = 0x9A,
SystemDoNotDisturb = 0x9B,
Dock = 0xA0,
Undock = 0xA1,
Setup = 0xA2,
Break = 0xA3,
DebuggerBreak = 0xA4,
ApplicationBreak = 0xA5,
ApplicationDebuggerBreak = 0xA6,
SpeakerMute = 0xA7,
Hibernate = 0xA8,
DisplayInvert = 0xB0,
DisplayInternal = 0xB1,
DisplayExternal = 0xB2,
DisplayBoth = 0xB3,
DisplayDual = 0xB4,
DisplayToggleInternalExternal = 0xB5,
DisplaySwapPrimarySecondary = 0xB6,
DisplayLcdAutoscale = 0xB7,
Reserved = 0xB8,
}
impl From<SystemControlKey> for u8 {
fn from(sck: SystemControlKey) -> u8 {
sck as u8
}
}
impl From<u8> for SystemControlKey {
fn from(k: u8) -> Self {
match k {
0x81 => Self::PowerDown,
0x82 => Self::Sleep,
0x83 => Self::WakeUp,
0x84 => Self::ContextMenu,
0x85 => Self::MainMenu,
0x86 => Self::AppMenu,
0x87 => Self::MenuHelp,
0x88 => Self::MenuExit,
0x89 => Self::MenuSelect,
0x8A => Self::MenuRight,
0x8B => Self::MenuLeft,
0x8C => Self::MenuUp,
0x8D => Self::MenuDown,
0x8E => Self::ColdRestart,
0x8F => Self::WarmRestart,
0x90 => Self::DpadUp,
0x91 => Self::DpadDown,
0x92 => Self::DpadRight,
0x93 => Self::DpadLeft,
0x97 => Self::SystemFunctionShift,
0x98 => Self::SystemFunctionShiftLock,
0x9A => Self::SystemDismissNotification,
0x9B => Self::SystemDoNotDisturb,
0xA0 => Self::Dock,
0xA1 => Self::Undock,
0xA2 => Self::Setup,
0xA3 => Self::Break,
0xA4 => Self::DebuggerBreak,
0xA5 => Self::ApplicationBreak,
0xA6 => Self::ApplicationDebuggerBreak,
0xA7 => Self::SpeakerMute,
0xA8 => Self::Hibernate,
0xB0 => Self::DisplayInvert,
0xB1 => Self::DisplayInternal,
0xB2 => Self::DisplayExternal,
0xB3 => Self::DisplayBoth,
0xB4 => Self::DisplayDual,
0xB5 => Self::DisplayToggleInternalExternal,
0xB6 => Self::DisplaySwapPrimarySecondary,
0xB7 => Self::DisplayLcdAutoscale,
_ => Self::Reserved,
}
}
}
#[gen_hid_descriptor(
(collection = APPLICATION, usage_page = FIDO_ALLIANCE, usage = U2F_AUTHENTICATOR_DEVICE) = {
(usage = INPUT_REPORT_DATA, logical_min = 0x0) = {
#[item_settings(data,variable,absolute)] data_in=input;
};
(usage = OUTPUT_REPORT_DATA, logical_min = 0x0) = {
#[item_settings(data,variable,absolute)] data_out=output;
};
}
)]
#[allow(dead_code)]
pub struct CtapReport {
pub data_in: [u8; 64],
pub data_out: [u8; 64],
}