fix(hid): handle analytics-only keyboards in host_switch_targets - #718
Open
sam-phinizy wants to merge 4 commits into
Open
fix(hid): handle analytics-only keyboards in host_switch_targets#718sam-phinizy wants to merge 4 commits into
sam-phinizy wants to merge 4 commits into
Conversation
Keyboards whose Easy-Switch controls are analytics-only (divertable=false) depart before switch_linked_hosts can probe the device. The previous code prepared the keyboard's host change first, and the DeviceNotFound error propagated via ?, skipping the target loop entirely — the mouse never received its setCurrentHost command. Now, when the keyboard is unreachable (already departed), the function falls through to switch_targets_directly, which opens each target's own channel and switches it independently. Verified on MX Keys S for Mac (B37C) + MX Master 4 (B042) over Bolt.
Greptile SummaryThe PR narrows the analytics-only keyboard fallback so ordinary HID++ timeouts no longer count as confirmed keyboard departure.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| crates/openlogi-hid/src/session/host_switch.rs | Narrows the direct-target fallback to explicit unreachable-device failures, resolving both previously reported overbroad fallback cases. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Prepare keyboard host change] --> B{Result}
B -->|Success| C[Switch linked targets]
C --> D[Switch keyboard last]
B -->|Device unreachable| E[Switch targets directly]
B -->|Timeout or validation error| F[Propagate error without switching targets]
Reviews (4): Last reviewed commit: "fix(hid): remove TimedOut from departure..." | Re-trigger Greptile
The catch-all error branch also caught HostSlotEmpty, which would have moved the targets to an unpaired host while the keyboard stayed put. Add HostSwitchError::is_device_unreachable() to distinguish transport and discovery failures (Hid, KeyboardNotFound, TimedOut, Hidpp with DeviceNotFound) from validation failures (HostSlotEmpty, UnsupportedKeyboard) and only fall through on the former.
A timeout on a reachable-but-slow keyboard is not a departure signal.
The Hidpp("DeviceNotFound") and Hid variants already cover the real
analytics-mode departure race.
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
host_switch_targetssilently fails on keyboards whose Easy-Switch controls are analytics-only (divertable=false). The keyboard departs beforeswitch_linked_hostscan probe the device, so theDeviceNotFounderror propagates via?and the target loop is never reached — the mouse never receives itssetCurrentHostcommand.switch_targets_directly, which opens each target's own channel and switches it independently.Changes
crates/openlogi-hid/src/session/host_switch.rs):switch_linked_hostsnow catchesDeviceNotFoundduring keyboard preparation and falls through to target-only switching instead of aborting.switch_targets_directlyopens each target's own HID++ channel and sendssetCurrentHostwithout relying on the keyboard's channel.Testing
Verified on MX Keys S for Mac (B37C, firmware 82.1.12) + MX Master 4 (B042) over Bolt receiver on macOS. Not runtime-tested on hardware for Linux or Windows.
OPENLOGI_LOG=debugtrace before fix:After fix:
Mouse successfully followed the keyboard.
Fixes a race condition affecting all keyboards that report
divertable=false analytics=truefor their host switch controls (CIDs 0x00d1–0x00d3).