Repository navigation
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
Closed
Meisterian wants to merge 1 commit into
Meisterian wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 2showed "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 itsreport-protocol report, which starts with report ID
0x01. A boot host reads byte 0 as themodifier mask, and bit 0 there is Left Ctrl:
Two related bugs in the same path:
usb_hid.cget_keyboard_report()returnssizeof(*boot_report)for a boot report, which islarger than 8 because the report body is sized for NKRO. Boot keyboard reports must be exactly
8 bytes.
usb_hid.czmk_usb_hid_send_report()treatsreport[0] == 0x04as the NKRO report and trimsit. In boot protocol byte 0 is the modifier mask and
0x04is Left Alt, so boot reports withLeft Alt held were mangled.
Changes
usb_hid.c,usb_hid.h: newzmk_usb_hid_is_boot_protocol(); boot reports are exactly 8bytes; the NKRO trimming is skipped in boot protocol.
endpoints.c(adaptivesend_keyboard_report): in boot protocol send the plain 8-byte bootreport over USB and no NKRO report; over 2.4G send the 6KRO report (already in boot layout) and
drop the NKRO report.
hid_keychron.czmk_hid_get_boot_report(): with adaptive NKROkeyboard_reportalways holdsthe 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
SET_PROTOCOL(boot): 9-byte reports starting with01.(The boot reports were not captured with pyusb again after the fix.)
keychron_v1_ultra_iso(adaptive) andkeychron_rs87_ansi(non-adaptive), this patch alone on
7f8d1673.but not flashed on its own.
Related
optional at runtime and restoring the Fn+N NKRO toggle.
SET_PROTOCOL(boot)on its keyboardinterface, so 2.4 GHz does not work on the Switch 2 (receiver firmware).
🤖 Generated with Claude Code