fix(hidpp): correct UnifiedBattery (0x1004) charging status codes#330
Merged
AprilNEA merged 1 commit intoJun 29, 2026
Merged
Conversation
The getStatus battery-status byte values 2 and 4 were mislabeled: 2 is the final charging stage (nearly full) and 4 is a below-optimal-speed recharge — not a slow charge and a generic error. Codes 5-7 (invalid battery, thermal error, charging error) were missing entirely. Align BatteryStatus with the Linux hid-logitech-hidpp unified-battery mapping and Solaar, and update map_battery_status: the nearly-full stage maps to Charging and 5-7 map to Error, leaving the core domain enum and GUI unchanged.
59eb3aa to
7fbb0d1
Compare
AprilNEA
approved these changes
Jun 29, 2026
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.
Summary
The
UnifiedBattery(0x1004)getStatus"battery status" byte (payload[2])is decoded into
BatteryStatus, but two values were mislabeled and three weremissing:
2wasChargingSlow— it is actually the final charging stage (nearlyfull), still charging.
4wasError— it is actually a below-optimal-speed recharge (the real"slow charge"), not an error.
5/6/7(invalid battery, thermal error, charging error) had novariants at all.
Because the enum stopped at
4, a device reporting5–7failedBatteryStatus::try_fromandget_battery_inforeturnedUnsupportedResponse— i.e. a thermal/charging-error state broke the wholebattery read rather than surfacing the error. A nearly-full charging device
showed "slow", and a genuinely slow charge showed "error".
Evidence
Cross-checked against two independent sources, which agree:
Linux
drivers/hid/hid-logitech-hidpp.c(unified-batteryswitch (data[2])):DischargingChargingChargingNearlyFullFullChargingSlowInvalidBatteryThermalErrorChargingErrorSolaar (
common.pyBatteryStatus):0 DISCHARGING, 1 RECHARGING, 2 ALMOST_FULL, 3 FULL, 4 SLOW_RECHARGE, 5 INVALID_BATTERY, 6 THERMAL_ERROR.Changes
openlogi-hidpp(feature/unified_battery): rename2→ChargingNearlyFull,4→ChargingSlow, addInvalidBattery/ThermalError/ChargingError(
5–7).openlogi-hid(mappings::map_battery_status): map the corrected variants tothe existing core
BatteryStatus— nearly-full →Charging,5–7→Error.The
openlogi-coredomainBatteryStatusand all GUI/diagnostics code areunchanged; this only corrects the wire decode and the bridge to it.
Testing
cargo fmt --all -- --checkcargo clippy -p openlogi-hid -- -D warningscargo test -p openlogi-hidpp(152) andcargo test -p openlogi-hid(60)The full-workspace
clippy/testgate was not run locally (it builds GPUI);the change doesn't touch
openlogi-gui, and the only cross-crate consumer ofthe wire enum is
openlogi-hid::mappings, which is covered above. CI will runthe full gate.
Note
This lands in the vendored
openlogi-hidppfork (0BSD, kept close tolus/logy). The same fix likely applies upstream — happy to send it there tooif you'd prefer to keep the fork in lockstep.