Fix modifier keys for BLE keyboards without report IDs - #366
Open
kinkutsushi wants to merge 1 commit into
Open
Conversation
The Bluetooth notify callback unconditionally prepended the report ID byte to report data before passing it to handle_received_report(). For devices whose report map contains no REPORT_ID items (e.g. RMK firmware keyboards), the parser reads the report from byte 0, so the prepended byte shifted every field: the modifier bitmap always read as 0x00 and modifier keys (Shift/Ctrl/Alt/GUI) were silently dropped, while array-style keycodes still appeared to work. Pass the report ID through the existing external_report_id parameter instead of prepending it to the data. Devices with report IDs keep the same behavior (the parser uses external_report_id directly), and unnumbered reports are now parsed at the correct offsets. Also fixes a one-byte overread in the notify callback memcpy, where rep_size + 1 bytes were copied from a rep_size-sized buffer. Co-Authored-By: Claude Fable 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.
Hi! First of all, thank you for this project — the Bluetooth version of HID Remapper solved a real problem for me (using a Bluetooth keyboard with a computer where Bluetooth is not allowed).
Problem
The Bluetooth notify callback unconditionally prepends the report ID byte to report data before passing it to
handle_received_report(). For devices whose report map contains noREPORT_IDitems — which is valid HID —has_report_id_theirsis false, so the parser reads fields starting at byte 0 of the buffer. The prepended byte shifts every field by one: the modifier bitmap always reads as 0x00, so Shift/Ctrl/Alt/GUI are silently dropped, while array-style keycodes still (mostly) work, which makes this easy to miss.Fix
Pass the report ID through the existing
external_report_idparameter instead of prepending it to the data. Devices whose report maps do use report IDs keep the exact same behavior. This also fixes a one-byte overread in the notify callback memcpy (rep_size + 1bytes were copied from arep_size-sized buffer).Tested with
Cornix split keyboard (RMK firmware) — it sends an unnumbered 8-byte boot-style keyboard report over HOGP. Modifiers were dead before this change and fully working after; regression-checked that regular keys still work.
🤖 Generated with Claude Code