Repository navigation
Conversation
Add vibrate(pattern, { bestEffort: true }), which resolves after the
transport write instead of waiting for the acknowledgement. Its
transaction ID stays reserved until the acknowledgement arrives or the
connection is torn down, and overlapping best-effort requests are
dropped, so a missing acknowledgement cannot hold up draws or brightness.
An optional interrupt submits a second pattern a few milliseconds later
from the same queue slot. A new vibration command replaces the playing
one, so a pattern too weak to feel shortens the first into a brief click.
Register acknowledgement waiters before submitting, so an acknowledgement
delivered during the write is not lost, and surface serial write errors
while keeping each header and payload adjacent.
Add fake-transport tests run with node --test, and a CI job for them.
shiny-code-app Bot
pushed a commit
to cbusillo/companion-surface-loupedeck
that referenced
this pull request
Oct 18, 2026
On models with a vibration motor, register for Companion control events and play a short click when Companion reports that a press ran actions (press) or a run-while-held group fired (hold). The adapter never vibrates from raw input, draws or startup. The motor is shared by the whole device, so the control id is ignored, and unknown events are ignored. The click is a Sharp Click interrupted a few milliseconds later by a pattern too weak to feel, which keeps it short and quiet. A hold cuts it 3 ms later than a press, because a finger resting on the key damps it. Per-surface settings enable it (on by default) and choose Light, Medium or Strong. Requests are dropped while one is in flight, before the surface is ready and after close. Stream Controller X has no motor and gets no settings. Adds a node:test suite and runs it in CI. Depends on unreleased @companion-surface/base (controlEvent, see bitfocus/companion-surface-api#90) and @loupedeck/node (best-effort vibrate with interrupt, see Julusian/node-loupedeck#58). Dependency versions will be bumped once those are released.
Author
|
Friendly ping on this one. It is the library half of the haptics work, and it is opt-in: existing On the small Loupedeck user count you raised on the surface API PR: the Companion side is now the generic I tested the full stack on a Live S today. I'm happy to keep this working and to change anything you'd like. |
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.
Goal
I'm adding haptic feedback to Companion's Loupedeck support: a short click when you press a touch button with an action, and another when a hold action fires. This PR is the library piece. The rest will follow as separate PRs to
companion-surface-api,companionandcompanion-surface-loupedeck, and they depend on a release that includes this.Why the library needs a change
vibrate()already exists, but it waits for the device's acknowledgement inside the command queue. Fired on every press, a slow or missing acknowledgement delays the button redraw that follows. And the built-in patterns played in full are either long buzzes or loud clicks, which don't feel like a button press.What
vibrate(pattern, { bestEffort: true })resolves after the transport write, without waiting for the acknowledgement. Its transaction ID stays reserved until the acknowledgement arrives or the connection is torn down, so a late acknowledgement can never resolve another command. While one is outstanding, further best-effort requests are dropped, not queued. Defaultvibrate()behaviour is unchanged.interrupt: { afterMs, pattern }sends a second pattern a few milliseconds later, from the same queue slot so queued draws cannot change the spacing. On a Live S a new vibration command replaces the one playing, so interrupting with a pattern too weak to feel turns a click into a much shorter, quieter one. Two enum members name the effects I used (0x05,0x06).sendnow waits for both write callbacks and reports their errors, while keeping each header and payload adjacent.Testing
node --test(no new dependencies), passing on Node 20 and Node 26. They cover missing, immediate and late acknowledgements, ID wrap and exhaustion, close and disconnect at each stage, write failures, and the interrupt paths. I added aunit:nodescript and a CI job for them. The existingunitscript points at Jest, which isn't installed, so I left it alone. I'm happy to fold these together however you prefer.Sharp Click 60%interrupted after 5 ms bySharp Click 30%was the feel I settled on. I have not tested other models.Notes
The pattern byte appears to be a TI DRV2605 ROM effect ID (the existing enum values line up with that table), which is where the two new names come from. If you'd rather not add enum members on that basis, I can pass raw numbers from the caller instead.
I can split the two fixes into their own PR if that's easier to review.
Disclosure
This change was written with AI assistance. I directed the design, reviewed the code, and tested it on my own hardware.