diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 6c2ae43..85dadab 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -229,7 +229,7 @@ pub fn gen_hid_descriptor(args: TokenStream, input: TokenStream) -> TokenStream let (descriptor, fields) = output; let mut out = quote! { - #[derive(Debug, Clone, Copy)] + #[derive(Debug, Clone, Copy, Default, Eq, PartialEq)] #[repr(C, packed)] #decl diff --git a/macros/src/spec.rs b/macros/src/spec.rs index 5a3df8a..5948bda 100644 --- a/macros/src/spec.rs +++ b/macros/src/spec.rs @@ -177,6 +177,7 @@ pub fn try_resolve_constant(key_name: String, path: String) -> Option<u32> { ("usage_page", "ALPHANUMERIC_DISPLAY") => Some(0x14), ("usage_page", "SENSOR") => Some(0x20), ("usage_page", "BARCODE_SCANNER") => Some(0x8C), + ("usage_page", "FIDO_ALLIANCE") => Some(0xF1D0), ("usage_page", "VENDOR_DEFINED_START") => Some(0xFF00), ("usage_page", "VENDOR_DEFINED_END") => Some(0xFFFF), @@ -238,6 +239,11 @@ pub fn try_resolve_constant(key_name: String, path: String) -> Option<u32> { ("usage", "SENSOR_POWER_STATE_D3_SLEEP_WITH_WAKE") => Some(0x0854), ("usage", "SENSOR_POWER_STATE_D4_POWER_OFF") => Some(0x0855), + // FIDO Alliance usage_page + ("usage", "U2F_AUTHENTICATOR_DEVICE") => Some(0x1), + ("usage", "INPUT_REPORT_DATA") => Some(0x20), + ("usage", "OUTPUT_REPORT_DATA") => Some(0x21), + (_, _) => None, } } diff --git a/src/descriptor.rs b/src/descriptor.rs index c1a8e0c..7b6ea62 100644 --- a/src/descriptor.rs +++ b/src/descriptor.rs @@ -83,17 +83,6 @@ pub struct KeyboardReport { pub keycodes: [u8; 6], } -impl KeyboardReport { - pub const fn default() -> Self { - Self { - modifier: 0, - reserved: 0, - leds: 0, - keycodes: [0u8; 6], - } - } -} - /// KeyboardUsage describes the key codes to be used in implementing a USB keyboard. /// /// The usage type of all key codes is Selectors, except for the modifier keys @@ -978,3 +967,21 @@ impl From<u8> for SystemControlKey { } } } + +/// CtapReport describes a report and its companion descriptor that can be +/// used to present a FIDO-compatible authenticator device to the host. +#[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], +}