Skip to content

hid_report: fall back to boot extractor when NKRO extraction fails#338

Open
ibrahim1416 wants to merge 1 commit into
hrvach:mainfrom
ibrahim1416:fix/wireless-keyboard-nkro-fallback
Open

hid_report: fall back to boot extractor when NKRO extraction fails#338
ibrahim1416 wants to merge 1 commit into
hrvach:mainfrom
ibrahim1416:fix/wireless-keyboard-nkro-fallback

Conversation

@ibrahim1416
Copy link
Copy Markdown

Summary

Some wireless dongles (observed on a Lemokey Link, VID 0x362d PID 0xd030) advertise an NKRO collection in their HID report descriptor but actually transmit standard boot-style keyboard reports — a 1-byte report ID followed by [modifier, reserved, 6 keycodes] (total 9 bytes).

Because the descriptor's parsed NKRO bitmap dimensions don't match the actual report layout, _extract_kbd_nkro() returns -1. extract_kbd_data() was not checking this return value, so process_keyboard_report() continued with a zeroed report. The result: the keyboard interface enumerates fine, reports arrive at the host every keystroke, but no keys are ever forwarded.

Changes

  • extract_kbd_data() now falls through to the next extractor when _extract_kbd_nkro() returns -1, clearing the partially-filled report first.
  • The "8 bytes optionally prefixed with a report ID" boot-style branch drops the !iface->uses_report_id guard so it can catch report-ID-prefixed boot reports (len == 9).

Test plan

  • Lemokey Link dongle: keyboard now types correctly through DeskHop. Modifiers (Shift) and regular keys both forwarded.
  • Wired keyboard (was already working): still works after change — falls into the same extractor it always did since its is_nkro is false.

🤖 Generated with Claude Code

Some wireless dongles (e.g. Lemokey Link, VID 0x362d PID 0xd030) advertise
an NKRO collection in their HID descriptor but actually transmit standard
boot-style keyboard reports: a 1-byte report ID followed by 8 bytes of
[modifier, reserved, 6 keycodes]. The descriptor's NKRO bitmap dimensions
do not match the actual report layout, so _extract_kbd_nkro() returns -1.

Previously, extract_kbd_data() did not check the return value and the
caller proceeded with a zeroed report — so the keyboard appeared to be
working at the USB level but no keys were ever forwarded.

This change makes extract_kbd_data() fall through to the boot extractor
when NKRO extraction fails. The "8 bytes optionally prefixed with a
report ID" branch also drops the !iface->uses_report_id condition so
it can catch report-ID'd boot-style reports (len == 9).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant