Repository navigation
feat(cli): add openlogi haptic play for scriptable haptic pulses - #2662
Open
fahadjibransheikh wants to merge 8 commits into
Open
fahadjibransheikh wants to merge 8 commits into
fahadjibransheikh wants to merge 8 commits into
Conversation
…orker Any client can now ask the agent to play one 0x19b0 waveform on a device and hear how it went (protocol v47). Plays go through the Actions Ring's single-flight haptic worker, so they coalesce with the ring's buzzes and reuse its arming, budget, breaker, and restore ledger instead of a second haptic path. Consecutive plays on one device share a session, so a disarmed engine is turned on once per burst and handed back two seconds after the last play; later plays cost one round-trip.
The haptic command needs the same human-facing selection, so it moves to the agent module and takes the feature it selects for.
Scripts and other apps can buzz a 0x19b0 mouse through the agent: a light tick by default, or a confirmation pulse.
fahadjibransheikh
requested review from
AprilNEA and
davidbudnick
as code owners
November 26, 2026 13:58
[Medium impact] The PR appears safe to merge; the earlier arming loop is fixed.
|
The client play scenarios awaited play_external, the shared feature cache lock and their setup with no limit, so a regression that stranded the worker's reply would hang the test job instead of failing it. Each scenario now runs under a deadline once it holds the cache, and waits a bounded time for it, as the replaced-device scenarios do.
…other The restore ledger assumed one haptic session open at a time, but a client burst and an Actions Ring can share a mouse. A burst opened under an open ring took over the ring's restore, and its idle close turned the engine off while the ring was still open; a ring closing inside a burst did the same to the burst, whose later plays reported Ok unfelt. The ledger now keeps one open session per lane (ring, client) and hands an engine back only once no open session plays on it. Arming no longer travels apart from the play it serves: every play carries its session, and the worker arms a session it has not armed yet before playing it, so a play queued behind another device's arming waits for its own instead of playing into an engine still off. The burst, the pause, and the hand-back request are one state with one writer, Sessions: a burst cannot survive finish() or open while the agent is leaving, so the first play after resume() arms again. A client play while the agent is leaving answers AgentUnavailable, as nothing arms then and its buzz may not be felt.
The burst's idle timer started when a play was queued, so a worker held up past BURST_IDLE (a lost ring buzz plus an unreachable restore) let the burst close while its first play still waited. The worker applies closes first and never arms a closed session, so that play went out unarmed and the client heard Ok for a buzz nobody felt. A burst now counts the plays waiting on it and cannot close while any does; its idle clock starts once the last is answered or abandoned. A play is also queued under the lock that ordered its join, so plays reach the worker in burst order and none carries a burst older than one the worker may already have armed past. The ring-inside-a-burst test now waits for the ring's arming before closing it, so it covers an armed ring closing rather than one that closed before the worker looked.
play_newest re-armed for every newer play that arrived during an arming, with no bound on the loop. Clients alternating between two mice faster than arming completes opened a new burst with each play, so the worker kept arming, played no pulse, and never reached the restores after it. A pass now arms at most one session and plays the play it armed for. A play that arrived meanwhile stays queued for the next pass, so every pass plays a pulse and reaches the restores, and nothing queued is lost.
This branch has not been deployed
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
Adds a scriptable way to play a haptic pulse on a device with HID++
0x19b0(MX Master 4):
openlogi haptic play [tick|confirm]andopenlogi api haptic.Both go through a new agent IPC call that reuses the Actions Ring haptic
worker, so arming, the budget, the breaker and the restore ledger stay in one
place.
Use cases: a build or CI notification, a macro confirming it ran, and haptic
hover feedback for radial menus outside OpenLogi. I use it to tick on each slot
change of another app's ring.
Changes
HapticPulsewire enum (SubtleCollision,DampStateChange).Agent::play_haptic(route, pulse) -> Result<(), WriteError>, appended;PROTOCOL_VERSION46 → 47; golden test.reserve_session_id(), so client haptic sessions draw IDs fromthe same counter as ring sessions.
DeviceNotFound,DeviceUnreachable,FeatureUnsupported{0x19b0}), then callsRingHapticPlayer::play_external, which runs on the existing worker andreturns the result to the caller. Plays within 2 s on one device share a
session: the first arms haptics if they were off, and the engine is restored
2 s after the last play.
openlogi haptic [--device NAME] play [tick|confirm]andopenlogi api haptic --device <id> [--waveform tick|confirm]. Name-basedagent device selection moved out of
backlightintoagent.rsso both use it(separate refactor commit, backlight behaviour unchanged).
USAGE.md.Testing
RUSTFLAGS="-D warnings":cargo fmt --all -- --check; clippy--all-targetsandcargo testover the 16 affectedpackages (4087 passed, 0 failed, 2 ignored); rustdoc; typos;
ast-grep scan;cargo xtask release check-publish; both wasm checks; MSRV 1.99 check.aarch64-unknown-linux-musl) on hook, inject, hid, hidpp,core, ipc and permissions. Not run for agent and agent-core:
ringneeds amusl cross C toolchain I don't have. The diff adds no platform-gated code.
restores; an engine already on gets no config writes; an unadvertised waveform
is refused with nothing sent; the inventory refusals.
046d:b042), macOS,dev agent.
tickandconfirmboth play; the first play of a burst takes~140 ms end to end (arming). Against the mock agent one CLI invocation takes
~6 ms.