Skip to content

Commit

Permalink
Merge pull request #1 from robin-nitrokey/usage-shimunn
Browse files Browse the repository at this point in the history
Merge shimunn#8
  • Loading branch information
sb-child authored Aug 13, 2024
2 parents bf862f6 + 29f684c commit dbc871e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions examples/list.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
for device in ctap_hmac::get_devices().unwrap() {
println!("{device:?}");
}
}
10 changes: 6 additions & 4 deletions src/hid_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ fn path_to_device(path: &PathBuf) -> io::Result<DeviceInfo> {
}

if key & REPORT_DESCRIPTOR_KEY_MASK == USAGE {
if size != 2 {
usage = u16::from(rd[pos + 1])
} else {
usage = LittleEndian::read_u16(&rd[(pos + 1)..(pos + 1 + (size as usize))]);
if usage == 0 {
if size != 2 {
usage = u16::from(rd[pos + 1])
} else {
usage = LittleEndian::read_u16(&rd[(pos + 1)..(pos + 1 + (size as usize))]);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static BROADCAST_CID: [u8; 4] = [0xff, 0xff, 0xff, 0xff];
pub fn get_devices() -> FidoResult<impl Iterator<Item = hid::DeviceInfo>> {
hid::enumerate()
.context(FidoErrorKind::Io)
.map(|devices| devices.filter(|dev| dev.usage_page == 0xf1d0 && dev.usage == 0x21))
.map(|devices| devices.filter(|dev| dev.usage_page == 0xf1d0 && dev.usage == 0x01))
.map_err(From::from)
}

Expand Down

0 comments on commit dbc871e

Please sign in to comment.