Skip to content

Commit

Permalink
Merge branch 'master' into add-hid-sensor-const
Browse files Browse the repository at this point in the history
  • Loading branch information
twitchyliquid64 authored Jul 16, 2024
2 parents b169b92 + 76325c3 commit b58383f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions macros/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down Expand Up @@ -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,
}
}
Expand Down
29 changes: 18 additions & 11 deletions src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],

Check failure on line 985 in src/descriptor.rs

View workflow job for this annotation

GitHub Actions / Clippy

core::default::Default` is not satisfied

Check failure on line 985 in src/descriptor.rs

View workflow job for this annotation

GitHub Actions / Check

core::default::Default` is not satisfied

Check failure on line 985 in src/descriptor.rs

View workflow job for this annotation

GitHub Actions / Build

core::default::Default` is not satisfied

Check failure on line 985 in src/descriptor.rs

View workflow job for this annotation

GitHub Actions / native (macOS-latest)

core::default::Default` is not satisfied
pub data_out: [u8; 64],

Check failure on line 986 in src/descriptor.rs

View workflow job for this annotation

GitHub Actions / Clippy

core::default::Default` is not satisfied

Check failure on line 986 in src/descriptor.rs

View workflow job for this annotation

GitHub Actions / Check

core::default::Default` is not satisfied

Check failure on line 986 in src/descriptor.rs

View workflow job for this annotation

GitHub Actions / Build

core::default::Default` is not satisfied

Check failure on line 986 in src/descriptor.rs

View workflow job for this annotation

GitHub Actions / native (macOS-latest)

core::default::Default` is not satisfied
}

0 comments on commit b58383f

Please sign in to comment.