Skip to content

Fix modifier keys for BLE keyboards without report IDs - #366

Open
kinkutsushi wants to merge 1 commit into
jfedor2:masterfrom
kinkutsushi:fix-ble-unnumbered-reports
Open

Fix modifier keys for BLE keyboards without report IDs#366
kinkutsushi wants to merge 1 commit into
jfedor2:masterfrom
kinkutsushi:fix-ble-unnumbered-reports

Conversation

@kinkutsushi

Copy link
Copy Markdown

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 no REPORT_ID items — which is valid HID — has_report_id_theirs is 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_id parameter 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 + 1 bytes were copied from a rep_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

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>
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