feat(q5_max): implement bi-directional Raw HID protocol #12

Merged
rootiest merged 2 commits from feat/raw-hid into main 2026-04-11 05:01:22 +00:00
Owner

Implements a custom Raw HID protocol for the Q5 Max enabling bi-directional communication with the host bridge application. Includes layer sync, host data delivery, and fixes for RAW_EPSIZE and via_command_kb hook conflicts.

Implements a custom Raw HID protocol for the Q5 Max enabling bi-directional communication with the host bridge application. Includes layer sync, host data delivery, and fixes for RAW_EPSIZE and `via_command_kb` hook conflicts.
rootiest added 3 commits 2026-04-11 04:52:08 +00:00
Session file is only relevant during development and unique to the local
machine.
Add hid_protocol.h defining a shared 32-byte packet structure for the
qmk-host bridge application (command IDs 0x40-0x7E, clear of VIA's
range). Implement via_command_kb() in keymap.c to intercept incoming
packets: LAYER_SYNC applies a new active layer, VOLUME and BRIGHTNESS
store host-reported values for future RGB indicators, and ACTIVE_APP
is stubbed for a later commit. Layer state changes are broadcast to the
host via raw_hid_send() from layer_state_set_user(), guarded by
g_hid_recv_active to prevent echo loops when the change itself
originated from HID.
Two build errors:

1. RAW_EPSIZE undeclared — usb_descriptor.h is not in scope when
   keymap.c is compiled through Keychron's build path. Replace all
   uses with HID_PACKET_SIZE (= 32), now defined in hid_protocol.h.

2. via_command_kb duplicate symbol — keychron_raw_hid.c already defines
   via_command_kb (non-weak) so we cannot redefine it in keymap.c.

Fix by adding a weak kc_raw_hid_rx_kb() extension hook to
keychron_raw_hid.c (following the same pattern as kc_rgb_matrix_rx).
kc_raw_hid_rx() now calls this hook from its default case instead of
returning false directly. The keymap overrides kc_raw_hid_rx_kb() to
handle our custom HID command range (0x40-0x7E).
rootiest closed this pull request 2026-04-11 05:00:51 +00:00
rootiest reopened this pull request 2026-04-11 05:01:04 +00:00
rootiest changed target branch from fix/chatter to main 2026-04-11 05:01:05 +00:00
rootiest merged commit bc1556547d into main 2026-04-11 05:01:22 +00:00
rootiest deleted branch feat/raw-hid 2026-04-11 05:01:23 +00:00
Sign in to join this conversation.