Skip to content

Commit 2a520fb

Browse files
committed
hid: add fido hid descriptor templates
1 parent 154821a commit 2a520fb

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/class/hid/hid.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ enum {
708708
HID_USAGE_PAGE_MSR = 0x8e,
709709
HID_USAGE_PAGE_CAMERA = 0x90,
710710
HID_USAGE_PAGE_ARCADE = 0x91,
711+
HID_USAGE_PAGE_FIDO_ALLIANCE = 0xF1D0,
711712
HID_USAGE_PAGE_VENDOR = 0xFF00 // 0xFF00 - 0xFFFF
712713
};
713714

@@ -844,6 +845,14 @@ enum
844845
HID_USAGE_CONSUMER_AC_PAN = 0x0238,
845846
};
846847

848+
/// HID Usage Table: FIDO Alliance Page (0xF1D0)
849+
enum
850+
{
851+
HID_USAGE_FIDO_U2F_AUTHENTICATOR_DEVICE = 0x01,
852+
HID_USAGE_FIDO_INPUT_REPORT_DATA = 0x20,
853+
HID_USAGE_FIDO_OUTPUT_REPORT_DATA = 0x21
854+
};
855+
847856
/*--------------------------------------------------------------------
848857
* ASCII to KEYCODE Conversion
849858
* Expand to array of [128][2] (shift, keycode)

src/class/hid/hid_device.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,29 @@ static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y
352352
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
353353
HID_COLLECTION_END \
354354

355+
// FIDO U2F Authenticator Descriptor Template
356+
#define TUD_HID_REPORT_DESC_FIDO_U2F(...) \
357+
HID_USAGE_PAGE_N ( HID_USAGE_PAGE_FIDO_ALLIANCE, 2 ) ,\
358+
HID_USAGE ( HID_USAGE_FIDO_U2F_AUTHENTICATOR_DEVICE ) ,\
359+
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
360+
/* Report ID if any */ \
361+
__VA_ARGS__ \
362+
/* Usage Data In */ \
363+
HID_USAGE ( HID_USAGE_FIDO_INPUT_REPORT_DATA ) ,\
364+
HID_LOGICAL_MIN ( 0 ) ,\
365+
HID_LOGICAL_MAX_N ( 255, 2 ) ,\
366+
HID_REPORT_SIZE ( 8 ) ,\
367+
HID_REPORT_COUNT ( 64 ) ,\
368+
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
369+
/* Usage Data Out */ \
370+
HID_USAGE ( HID_USAGE_FIDO_OUTPUT_REPORT_DATA ) ,\
371+
HID_LOGICAL_MIN ( 0 ) ,\
372+
HID_LOGICAL_MAX_N ( 255, 2 ) ,\
373+
HID_REPORT_SIZE ( 8 ) ,\
374+
HID_REPORT_COUNT ( 64 ) ,\
375+
HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
376+
HID_COLLECTION_END \
377+
355378
// HID Generic Input & Output
356379
// - 1st parameter is report size (mandatory)
357380
// - 2nd parameter is report id HID_REPORT_ID(n) (optional)

0 commit comments

Comments
 (0)