Skip to content

Fix HID boot protocol with adaptive NKRO: every key arrives with Left Ctrl (Nintendo Switch 2) - #16

Closed
Meisterian wants to merge 1 commit into
Keychron:rtl8762gfrom
Meisterian:fix/boot-protocol
Closed

Meisterian wants to merge 1 commit into
Keychron:rtl8762gfrom
Meisterian:fix/boot-protocol

Conversation

@Meisterian

Copy link
Copy Markdown

Against rtl8762g @ 7f8d1673 (4 files, +36/-3). Found and tested on a V1 Ultra 8K ISO
(keychron_v1_ultra_iso).

Problem

Hosts that use the HID boot protocol, for example the Nintendo Switch 2, cannot use
keyboards with adaptive NKRO (ADAPATIVE_NKRO) over USB. Depending on the firmware the Switch 2
showed "no keyboard connected", or found the keyboard but typing did nothing, because every key
arrived together with Left Ctrl
.

After the host sends SET_PROTOCOL(boot), the adaptive NKRO send path keeps sending its
report-protocol report, which starts with report ID 0x01. A boot host reads byte 0 as the
modifier mask, and bit 0 there is Left Ctrl:

key "a" sent today:      01 00 00 04 00 00 00 00 00   (report ID, mods, reserved, keys...)
boot host reads:         mods=01 (Left Ctrl) reserved=00 keys=00 04 ...   -> Ctrl + a
expected boot report:    00 00 04 00 00 00 00 00      (mods, reserved, 6 keys; exactly 8 bytes)

Two related bugs in the same path:

  • usb_hid.c get_keyboard_report() returns sizeof(*boot_report) for a boot report, which is
    larger than 8 because the report body is sized for NKRO. Boot keyboard reports must be exactly
    8 bytes.
  • usb_hid.c zmk_usb_hid_send_report() treats report[0] == 0x04 as the NKRO report and trims
    it. In boot protocol byte 0 is the modifier mask and 0x04 is Left Alt, so boot reports with
    Left Alt held were mangled.

Changes

  • usb_hid.c, usb_hid.h: new zmk_usb_hid_is_boot_protocol(); boot reports are exactly 8
    bytes; the NKRO trimming is skipped in boot protocol.
  • endpoints.c (adaptive send_keyboard_report): in boot protocol send the plain 8-byte boot
    report over USB and no NKRO report; over 2.4G send the 6KRO report (already in boot layout) and
    drop the NKRO report.
  • hid_keychron.c zmk_hid_get_boot_report(): with adaptive NKRO keyboard_report always holds
    the 6-key array, so build the boot report from it even when the NKRO flag is set.

Non-adaptive shields only get the length and trimming fixes; their behaviour is otherwise
unchanged.

Testing

  • Before the fix, pyusb on Linux after SET_PROTOCOL(boot): 9-byte reports starting with 01.
  • With the fix: the V1 Ultra 8K ISO works on a Nintendo Switch 2 by USB cable and types correctly.
    (The boot reports were not captured with pyusb again after the fix.)
  • Builds without new warnings: keychron_v1_ultra_iso (adaptive) and keychron_rs87_ansi
    (non-adaptive), this patch alone on 7f8d1673.
  • Note: on hardware this code ran as part of larger test builds; this change was built on its own
    but not flashed on its own.

Related

  • A possible follow-up builds on this: making the second keyboard collection (NKRO, report ID 4)
    optional at runtime and restoring the Fn+N NKRO toggle.
  • Not fixable here: the Ultra-Link 8K receiver rejects SET_PROTOCOL(boot) on its keyboard
    interface, so 2.4 GHz does not work on the Switch 2 (receiver firmware).

🤖 Generated with Claude Code

After SET_PROTOCOL(boot), the adaptive NKRO send path kept sending its
report-protocol report, which starts with report ID 0x01. A boot host
(e.g. Nintendo Switch 2) reads byte 0 as the modifier mask, so every key
arrived with Left Ctrl held.

- endpoints.c: in boot protocol send the plain 8-byte boot report over
  USB and no NKRO report; over 2.4G drop only the NKRO report.
- usb_hid.c: boot keyboard reports are exactly 8 bytes (the body type is
  sized for NKRO); skip the NKRO trimming in boot protocol, where byte 0
  is the modifier mask and 0x04 means Left Alt.
- hid_keychron.c: with adaptive NKRO build the boot report from the
  6-key array even when the NKRO flag is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Meisterian Meisterian closed this Nov 28, 2026
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