refactor: expose hook HID runtime state#139
Merged
hieshima merged 2 commits intoTomBadash:masterfrom May 5, 2026
Merged
Conversation
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.
Why
Follow-up to #120 and #82.
#120 split the platform hook implementations behind a shared import surface, but intentionally kept the runtime semantics unchanged. After that split,
Enginestill infers HID++ readiness by directly peeking at the privatehook._hid_gesturehandle.That private access is fragile because Mouser now has multiple readiness concepts:
Linux makes this split explicit: evdev can be ready while HID++ is not, or HID++ can reconnect before evdev has grabbed the input device. This PR adds a small runtime state surface so those meanings are separated and testable.
Related work
Follow-up to:
_hid_gestureaccess fromEngine.Related runtime issues:
Nearby open/merged work this does not solve directly:
What changed
HidRuntimeStatewith:input_readyhid_readyconnected_devicehid_runtime_stateto the hook contract.input_ready=True,hid_ready=Falseinput_ready=False,hid_ready=Truehid_runtime_state:device_connectedconnected_devicehid_features_ready_hid_gesturefallback for existing test doubles and compatibility during the migration.Scope
This is behavior-preserving infrastructure.
It does not change:
_hid_gestureis still retained for operation paths. The next runtime cleanup step can move Engine replay/poll/setter consumers onto this state surface and add a generation token for stale result handling.Tests
Full result on macOS: