Repository navigation
Add a hold trigger for converting pointer movement to scroll - #1400
Conversation
Add `pointer.redirectsToScrollTrigger`. When set, pointer movement is converted to scroll events only while the trigger is held, using the same deltas and fixed cursor as the always-on mode. The trigger press and release are consumed. Without a trigger, `redirectsToScroll: true` keeps working as before. Move `Scheme.Buttons.Mapping.Trigger` to `Scheme.Trigger` so pointer settings can reuse it. `Mapping.Trigger` remains as a typealias and the JSON format is unchanged. The new setting accepts a mouse button with optional modifier keys. Closes linearmouse#1065
|
@lujjjh one thing I ran into while testing this on my own machine, which I think needs a decision before this is mergeable. The trigger recorder only appears once "Convert pointer movement to scroll events" is already on, and that checkbox takes effect immediately. So the only way to reach the trigger is through the always-on state, and in always-on state the selected device has no usable pointer any more. I did this twice: once on my Magic Mouse and once, by accident, on the built-in trackpad, because the Pointer tab preselects the device you are currently using. Both times the only way out was to quit LinearMouse from another input device or the terminal. That is pre-existing behaviour of What I would suggest, and I am happy to implement whichever you prefer:
Option 1 also makes the config shape self-documenting in the UI, since Either way the JSON stays as it is in this PR. |
|
@anandghegde thanks for catching this. I'm leaning toward option 1 since it makes the three states clearer. For "Always," maybe we could add a confirmation before apply it, or automatically revert after 10 seconds unless the user confirms, so they don’t accidentally lose pointer control. |
The checkbox plus an optional trigger left two visually identical states meaning opposite things: with the box ticked, recording a trigger converts only while it is held, while clearing it converts everything. Replace it with a picker over Off / While holding a trigger / Always, so the state that takes the pointer away is the one the user names. "Always" is the state you cannot undo with the device you just took away, so it is confirmed before it applies and then reverts by itself after ten seconds unless kept -- the same shape macOS uses for a display change. Keep and Revert are the default and cancel actions, so they can be reached from the keyboard while the pointer is unusable. The stored configuration keeps its existing shape, so a scheme that only sets redirectsToScroll still reads back as "Always".
|
Thanks — went with option 1, and pushed it in The picker. "Convert pointer movement to scroll events" is now Off / While holding a trigger / Always, and the trigger recorder only appears under the middle one. The stored configuration is unchanged — still That also closed a trap I'd left in: with the old checkbox, clearing the trigger while it was ticked silently promoted the setting to convert-everything. Clearing now drops back to "While holding a trigger" with conversion off until a new trigger is recorded, so it can't happen by accident. On "Always". I implemented both things you suggested rather than picking one, because neither covers the case alone:
Together they're the shape macOS uses for a display change: you say yes, it applies, and it goes back by itself after 10 seconds unless you keep it. The countdown timer runs in Tests. Added Happy to drop the confirmation dialog and keep only the auto-revert if you'd rather have fewer clicks — the revert path doesn't depend on it. |
|
Thanks for the update! I tested the changes in this PR, and everything works well overall. One thing I noticed is that when a trigger is already set, clicking to record a new one gives no indication that recording is in progress. The new strings also need translations. Aside from those, it looks good to me. Do you think we can mark it as ready for review? |
When a trigger was already set, clicking the recorder kept showing the old trigger, because the binding deliberately ignored the cleared mapping so the stored trigger stays in effect until a new one is recorded. Keep the in-progress mapping separately while recording, so the recorder shows "Recording" (and any modifiers held so far) like the other button recorders do, and drop it when recording ends without a new trigger. Translate the ten strings added for the three-way picker, the trigger recorder and the "Always" confirmation into all 34 catalog locales, reusing the existing terms for pointer, trigger and scroll events. The revert countdown uses plural variations, following "%d line(s)".
|
Thanks for testing it! Both are fixed in Recording indicator. The recorder kept showing the old trigger because the binding threw away the cleared mapping on purpose, so the stored trigger stays in effect until a new one is recorded. The in-progress mapping is now held separately while recording. The recorder shows "Recording" (plus any modifiers held so far), the same as the Auto Scroll and gesture recorders, and the existing trigger stays active underneath. If recording ends without a new trigger, for example by clicking the recorder again, it goes back to showing the stored trigger. Translations. All ten new strings are translated into the 34 locales in the catalog, reusing the existing terms for pointer, trigger and scroll events in each language (and the same formal or informal register each locale already uses). The revert countdown uses plural variations, like The build and all 949 tests pass, and |
|
Looks good! Appreciate your work on this. |
Closes #1065.
This follows option A from #1065, which @lujjjh agreed to: a
redirectsToScrollTriggerfield onScheme.Pointerthat reusesMapping.Trigger, moved to a shared location.Summary
pointer.redirectsToScrollTrigger. While the trigger is held, pointer movement becomes scrolling with the same deltas and fixed cursor asredirectsToScrolltoday. When it's released, the pointer moves normally again.redirectsToScroll: trueworks as before (always on). The trigger only applies whenredirectsToScrollis true.Scheme.Buttons.Mapping.TriggertoScheme.Trigger(Scheme/Trigger.swift).Mapping.Triggeris kept as a typealias, so existing code and the JSON format don't change.Button,ModifierandScrollDirectionstay underMappingfor now.valid(with:)stays inStructuredMapping.swiftas an extension because it checks mapping outcomes.Trigger: a mouse button with optional modifiers. Primary without modifiers, wheel inputs, chords,whileHeldand Logitech controls are rejected. An invalid trigger turns redirecting off rather than falling back to always on. The settings page shows the same error Auto Scroll uses.ButtonMappingButtonRecorderAuto Scroll uses, plus a Clear button. Recording keeps the current trigger until a new one is captured.Configuration.d.ts, the generatedConfiguration.json(npm run generate:json-schema) andConfiguration.md. Added two English strings.Example:
Open questions:
Triggerneeds an input, so I left them out. They'd need a new input kind and would overlap with the scrolling modifier settings. Should they be a follow-up?Testing
xcodebuild test: all 943 unit tests pass. New tests cover decoding, encoding and merging the field, theMapping.Triggertypealias, which triggers are valid, held vs released behaviour (press/release consumed, drags redirected only while held, modifiers matched at press, other buttons pass through, bypassed while recording, reset on deactivate), and where the transformer goes in the chain.swiftformat --lint .is clean andswiftlintreports no new violations.(I used Claude Code to help write this. I've reviewed the changes myself.)