Repository navigation
launcher: report battery level over USB and 2.4 GHz (A7 31) - #15
Open
JanitorHead wants to merge 1 commit into
Open
JanitorHead wants to merge 1 commit into
JanitorHead wants to merge 1 commit into
Conversation
Add kc_user_cmd sub-command 0x31. The reply is A7 31 <percent> <charging>, so Launcher or any host tool can read the battery over the USB cable and over the Ultra-Link 8K receiver; until now the level only reached the host over Bluetooth.
2 of 4 tasks
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.
On the Ultra 8K keyboards the battery level only reaches the host over Bluetooth. Over the USB cable and over the Ultra-Link 8K receiver nothing reports it: the receiver link carries keys, consumer, mouse, device info and Launcher data, and no Launcher command returns the battery. Anyone who uses the 2.4 GHz receiver, which is the point of an 8K board, cannot see the battery from the computer.
This adds one
kc_user_cmdsub-command,0x31. The host sendsA7 31on the raw HID interface (usage page 0xFF60) and the keyboard answersA7 31 <percent> <charging>, usingzmk_battery_state_of_charge()andget_charge_state(). Launcher already forwards raw HID through the receiver (LAUNCHER_PATH_PPT), so the same request works on the cable and on 2.4 GHz with no receiver change. Unknown sub-commands are unaffected.Testing.
Source build. This branch builds for the V3 Ultra 8K ISO (
west build -s app -b keychron -- -DSHIELD=keychron_v3_ultra_iso,zmkfirmware/zmk-build-arm:3.5, Zephyr SDK 0.16.3). I also built its parent commit without the change.kc_user_cmdis byte-identical to the one in the official V3 Ultra 8K ISO v1.0.2-ZK image (KCZKV38I, build Feb 27 2026) once link-time addresses are masked. So this patch applies to the handler that ships.kc_user_cmdfrom both ELFs in an emulator (Unicorn, Cortex-M33). With the change,0x31answers31 49 01for 73 % charging,31 64 00for 100 % and31 05 00for 5 %. The other 255 sub-commands give the same reply as without the change.I did not flash the source build. Its prebuilt 2.4 GHz library (
hal_realtek2.4G, "Add 2.4G lib", May 22 2026) is newer than the one in v1.0.2. Matched function by function against the official image,ppt_driver,ppt_syncandppt_simpleare the same, but 22 of 44ppt_sync_masterfunctions differ. The olderlibppt_sync_master.ano longer links with this app (whiten_and_calculate_crc_fast,md1r_seq), so I could not reproduce the shipped radio from source.On the keyboard. I applied the same change as a binary patch to the official v1.0.2 image, flashed it with the Launcher update protocol, and checked it:
3434:0C31):A7 31 64 01→ 100 %, charging3434:D028):A7 31 64 00→ 100 %, on batterykc_user_cmdsub-command gives the same reply as stock (checked by emulating the stock and patched handlers side by side).It would be great to have this in the official firmware, and ideally shown in Launcher, so users do not need patched images to see the battery over 2.4 GHz.