Skip to content

Commit 3846d5f

Browse files
committed
hid: add configurable report size for fido
1 parent 2a520fb commit 3846d5f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/class/hid/hid_device.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y
353353
HID_COLLECTION_END \
354354

355355
// FIDO U2F Authenticator Descriptor Template
356-
#define TUD_HID_REPORT_DESC_FIDO_U2F(...) \
356+
// - 1st parameter is report size, which is 64 bytes maximum in U2F
357+
// - 2nd parameter is HID_REPORT_ID(n) (optional)
358+
#define TUD_HID_REPORT_DESC_FIDO_U2F(report_size, ...) \
357359
HID_USAGE_PAGE_N ( HID_USAGE_PAGE_FIDO_ALLIANCE, 2 ) ,\
358360
HID_USAGE ( HID_USAGE_FIDO_U2F_AUTHENTICATOR_DEVICE ) ,\
359361
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
@@ -362,16 +364,16 @@ static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y
362364
/* Usage Data In */ \
363365
HID_USAGE ( HID_USAGE_FIDO_INPUT_REPORT_DATA ) ,\
364366
HID_LOGICAL_MIN ( 0 ) ,\
365-
HID_LOGICAL_MAX_N ( 255, 2 ) ,\
367+
HID_LOGICAL_MAX_N ( 0xff, 2 ) ,\
366368
HID_REPORT_SIZE ( 8 ) ,\
367-
HID_REPORT_COUNT ( 64 ) ,\
369+
HID_REPORT_COUNT ( report_size ) ,\
368370
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
369371
/* Usage Data Out */ \
370372
HID_USAGE ( HID_USAGE_FIDO_OUTPUT_REPORT_DATA ) ,\
371373
HID_LOGICAL_MIN ( 0 ) ,\
372-
HID_LOGICAL_MAX_N ( 255, 2 ) ,\
374+
HID_LOGICAL_MAX_N ( 0xff, 2 ) ,\
373375
HID_REPORT_SIZE ( 8 ) ,\
374-
HID_REPORT_COUNT ( 64 ) ,\
376+
HID_REPORT_COUNT ( report_size ) ,\
375377
HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
376378
HID_COLLECTION_END \
377379

0 commit comments

Comments
 (0)