Skip to content

Implemented mouse config#347

Open
NeoTheFox wants to merge 9 commits into
feschber:mainfrom
NeoTheFox:mouse-configuration
Open

Implemented mouse config#347
NeoTheFox wants to merge 9 commits into
feschber:mainfrom
NeoTheFox:mouse-configuration

Conversation

@NeoTheFox
Copy link
Copy Markdown
Contributor

Add two options:
mouse_mod - sets a linear acceleration for the emulated mouse
invert_scroll - inverts the scrolling direction for the emulated mouse

Hopefully it helps to make the pointer more consistent across multiple devices.

Previously discussed in #339

Comment thread input-emulation/Cargo.toml Outdated
Comment thread lan-mouse-ipc/src/lib.rs Outdated
Comment thread lan-mouse-ipc/Cargo.toml Outdated
Comment thread lan-mouse-ipc/src/lib.rs Outdated
Comment thread src/config.rs Outdated
@feschber
Copy link
Copy Markdown
Owner

feschber commented Nov 1, 2025

There is one more thing:

Since we are making changes to the configuration, we should think about the names a bit more.
I'd prefer these options to be under a different section and name them a bit differently like this:

# transformations applied to input events received from other devices
[event_post_processing]
mouse_sensitivity = 1.0
invert_scroll = true

This would later enable a similar section for event pre transformations (when being sent to other devices):

# transformations applied to input events sent to other devices
[event_pre_processing]
mouse_sensitivity = 1.0
# linear_acceleration_factor = 1.2
# scroll_sensitivity = 0.3
invert_scroll = false

Maybe you can come up with some better names, but I find mouse_mod a bit indescriptive and would prefer sensitivity here.

@feschber
Copy link
Copy Markdown
Owner

feschber commented Nov 1, 2025

Maybe input_post_processing would be a better name.

@NeoTheFox
Copy link
Copy Markdown
Contributor Author

Wouldn't a simple input suffice?

@feschber
Copy link
Copy Markdown
Owner

feschber commented Nov 1, 2025

Not if we want to add pre processing later on

@NeoTheFox
Copy link
Copy Markdown
Contributor Author

That's fair. Done and done.

@NeoTheFox
Copy link
Copy Markdown
Contributor Author

A note on my formatter - my cargo version is
cargo 1.90.0 (840b83a10 2025-07-30) (Arch Linux rust 1:1.90.0-4.1)
If the linter is mandatory I implore you to consider adding a clear .rustfmt.toml to the repository, as my version sees no issues here and forces the problematic line into that format.

@feschber
Copy link
Copy Markdown
Owner

feschber commented Nov 1, 2025

A note on my formatter - my cargo version is cargo 1.90.0 (840b83a10 2025-07-30) (Arch Linux rust 1:1.90.0-4.1) If the linter is mandatory I implore you to consider adding a clear .rustfmt.toml to the repository, as my version sees no issues here and forces the problematic line into that format.

I have the same version and it did complain about the formatting when running cargo fmt --check.

Would you mind opening a separate PR for the rust-fmt.toml (I'm not against that)

@feschber feschber force-pushed the mouse-configuration branch from 5497c68 to c047a51 Compare November 2, 2025 11:03
@feschber
Copy link
Copy Markdown
Owner

feschber commented Nov 2, 2025

Ah one last thing: The input_post_processing section in the config should also be optional, not just the individual settings.

@feschber
Copy link
Copy Markdown
Owner

feschber commented Nov 2, 2025

Oh (in case you are unaware): The dynamic updates to the sensitivity and scrolling inversion do not work. You are passing the values to the EmulationProxy but not from there to the actual input-emulation.

@feschber
Copy link
Copy Markdown
Owner

feschber commented Nov 2, 2025

If you don't want to do it, I can fix it myself as well.

@NeoTheFox
Copy link
Copy Markdown
Contributor Author

I'll probably only be able to get back to this on the weekends, so if it's a quick fix - up to you. I'll do it myself in a few days otherwise

@10a5er
Copy link
Copy Markdown

10a5er commented Nov 14, 2025

I’ve been testing this intensively: macOS (Apple Silicon) ↔ Hyprland/Arch (Apple Silicon), both directions. In this setup it finally makes lan-mouse fully usable for real work.

I’m seeing one "maybe-issue" and one point that’s still unclear:

1.	Scroll wheel stops sending events

A gaming mouse tethered to macOS originally forwarded scroll events to the Linux client, but at some point it stopped completely. The wheel still works locally on the macOS host. No combination of config changes or fresh builds (selfbuilt and artefact's from here) brought it back.
This might be on me — I experimented with libinput and Karabiner earlier (trying to invert the wheel direction with upstream), so it’s possible I broke something that im not able to backtrack. Mentioning it in case it’s relevant.

2.	Unclear configuration surface

Not an issue — I just haven’t fully mapped out which configuration options are included in this PR.
Specifically:
• Is scroll sensitivity part of this, or was it only an example?
• How does the layering work between host-side and client-side configs?
• Which namespace is actually used now: input-, event-, or a mix (depending on -pre-, -post-)?

i hope this has any use and is not a complete waste of space.

@feschber feschber mentioned this pull request Nov 24, 2025
4 tasks
@NeoTheFox
Copy link
Copy Markdown
Contributor Author

Sorry for the delay, had a lot of other work to do recently

@Revoxandco
Copy link
Copy Markdown

Hey, can you explain how it works ? I set the variables in the config file for the host and the client but it doesn't work.

@NeoTheFox
Copy link
Copy Markdown
Contributor Author

It's the client config that matters for these settings. You don't put them into the client section on the host, you put them into the config file on the client, like so

[input_post_processing]
mouse_sensitivity = 1.5
invert_scroll = false

@Revoxandco
Copy link
Copy Markdown

It's the client config that matters for these settings. You don't put them into the client section on the host, you put them into the config file on the client, like so

[input_post_processing]
mouse_sensitivity = 1.5
invert_scroll = false

Just putting invert_scroll = false will do it ? Or disable natural in macos settings too is needed ?

@NeoTheFox
Copy link
Copy Markdown
Contributor Author

In OSX case, the "invert_scroll" should be set to "true" to disable natural scrolling. No other adjustments are necessary

@Revoxandco
Copy link
Copy Markdown

image My config is correct I think but it doesn't work.. I am using latest development build that contains your fix

@NeoTheFox
Copy link
Copy Markdown
Contributor Author

@Revoxandco make sure you're starting the right version and that your config is in the right path, I've been driving it daily since I opened this PR and just changed the "invert_scroll" from true to false, and it worked as intended. You can also try using the cli interface to toggle it. (lan-mouse cli command)

@feschber
Copy link
Copy Markdown
Owner

feschber commented Dec 1, 2025

image My config is correct I think but it doesn't work.. I am using latest development build that contains your fix

@Revoxandco this fix is not in the latest development release yet, unless you're specifically compiling this branch from source.

@10a5er
Copy link
Copy Markdown

10a5er commented Dec 28, 2025

you think the teased scroll sensitivity is a doable thing for the future?

UberKitten added a commit to UberKitten/lan-mouse that referenced this pull request Mar 25, 2026
…test upstream

Rebased onto current main which includes:
- Fix stuck modifiers (feschber#385)
- remote key-up on triggered release (feschber#371)
- fix inconsistent mouse capture on macOS (feschber#346)
- improve reliability of connections (feschber#349)
- macos: fix modifier capture (feschber#342)
- macos: fix scroll capture (feschber#350)
- and more

Conflicts resolved in lan-mouse-ipc/src/lib.rs and src/service.rs
(same SaveConfiguration variant conflict as original build).
Also re-added #[derive(Clone)] on InputConfig and #[serde(alias = "input")] for config compat.
jondkinney added a commit to jondkinney/lan-mouse that referenced this pull request May 7, 2026
…gerprints

Replaces the bare `description` value in `authorized_fingerprints`
with `IncomingPeerConfig { description, natural_scroll,
mouse_sensitivity }`. Each row in the receive-side authorization
registry now carries its own scroll-direction and motion-sensitivity
preferences, keyed by TLS certificate fingerprint — the only stable
cross-session identity for an inbound peer.

Backwards-compat: legacy configs that store a bare string per
fingerprint deserialize via a custom `Deserialize` impl on
`IncomingPeerConfig` that accepts either shape (untagged enum) and
fills missing fields with defaults (`natural_scroll: false`,
`mouse_sensitivity: 1.0`). No migration tooling needed; existing
config.toml files keep working.

Wires the schema through:
- lan-mouse-ipc: new `IncomingPeerConfig` type;
  `AuthorizedUpdated(HashMap<String, IncomingPeerConfig>)`;
  `SetIncomingPeerNaturalScroll(fingerprint, bool)` and
  `SetIncomingPeerSensitivity(fingerprint, f64)` requests.
- src/config.rs + src/listen.rs + src/service.rs: type updates
  through the `Arc<RwLock<HashMap<...>>>` shared with the DTLS
  listener, plus per-fingerprint mutators in Service.
- lan-mouse-gtk: `KeyObject` carries the new properties; window
  re-emits them on `AuthorizedUpdated`.

Receive-side application of the new settings (looking up by
fingerprint at handle creation, pushing to InputEmulation) and the
expandable per-row GTK controls land in follow-up commits to keep
the diff focused. The deprecated global `SetNaturalScroll` /
`NaturalScroll` IPC variants stay in place until the global UI
toggle is removed in the cleanup commit.

`FrontendRequest` loses its `Eq`/`PartialEq` derives because `f64`
isn't `Eq`. No callers were comparing requests for equality.

Sensitivity-multiplier algorithm pattern in InputEmulation::consume
(applied in a follow-up commit) is borrowed from feschber#347 by Raidon
Chrome / NeoTheFox, where the global form was originally proposed.

Co-Authored-By: Raidon Chrome <soniczerops@gmail.com>
jondkinney added a commit to jondkinney/lan-mouse that referenced this pull request May 7, 2026
…gerprint

Centralizes scroll-direction inversion and motion-sensitivity scaling
into a single transform site in `InputEmulation::consume`, replacing
the per-backend `set_natural_scroll(bool)` plumbing introduced
earlier in this PR. The platform emulation backends (macos, wlroots,
libei, x11, windows, xdg_desktop_portal) go back to platform-
mechanics-only — no scroll-sign awareness, no shadow per-backend
state, no duplicated transform code.

The active settings are stored per-`EmulationHandle` on
`InputEmulation` itself and applied by mutating the event before it
reaches the backend's `consume()`. The match-arm pattern (multiplier
on `Motion`, sign-flip on `Axis` / `AxisDiscrete120`) follows the
shape used in feschber#347 by Raidon Chrome, ported to per-handle.

Plumbing on the receive side:

- `lan-mouse-ipc` exposes `IncomingPeerConfig` (commit 1).
- `src/emulation.rs::ListenTask` maintains a small cache of
  `addr → fingerprint` (populated from `ListenEvent::Accept`) plus
  the latest `incoming_peers` snapshot pushed by Service.
- On Accept, ListenTask resolves the right `ReceivePostProcessing`
  for the addr and forwards it via `ProxyRequest::SetPostProcessing`
  so EmulationTask can attach it to the handle the moment one is
  assigned.
- On `EmulationRequest::SetIncomingPeers` (Service push triggered
  by user UI changes / authorize / remove / config reload),
  ListenTask re-resolves every known addr and re-publishes to keep
  currently-active sessions in sync.
- `EmulationTask` caches `addr → ReceivePostProcessing` so a
  backend respawn (CGEventTap timeout, portal session restart)
  re-applies the right values to all known handles.

`input-emulation` stays decoupled from `lan-mouse-ipc`; the
conversion from `IncomingPeerConfig` → `ReceivePostProcessing`
happens at the boundary in `src/emulation.rs` so the lower crate
doesn't grow IPC dependencies.

The deprecated global `FrontendRequest::SetNaturalScroll` /
`FrontendEvent::NaturalScroll` IPC variants stay round-tripping
through Service (persist + echo only, no emulation effect) so the
existing GUI toggle continues to render its state until the cleanup
commit removes the global UI surface.

Co-Authored-By: Raidon Chrome <soniczerops@gmail.com>
jondkinney added a commit to jondkinney/lan-mouse that referenced this pull request May 7, 2026
…gerprints

Replaces the bare `description` value in `authorized_fingerprints`
with `IncomingPeerConfig { description, natural_scroll,
mouse_sensitivity }`. Each row in the receive-side authorization
registry now carries its own scroll-direction and motion-sensitivity
preferences, keyed by TLS certificate fingerprint — the only stable
cross-session identity for an inbound peer.

Backwards-compat: legacy configs that store a bare string per
fingerprint deserialize via a custom `Deserialize` impl on
`IncomingPeerConfig` that accepts either shape (untagged enum) and
fills missing fields with defaults (`natural_scroll: false`,
`mouse_sensitivity: 1.0`). No migration tooling needed; existing
config.toml files keep working.

Wires the schema through:
- lan-mouse-ipc: new `IncomingPeerConfig` type;
  `AuthorizedUpdated(HashMap<String, IncomingPeerConfig>)`;
  `SetIncomingPeerNaturalScroll(fingerprint, bool)` and
  `SetIncomingPeerSensitivity(fingerprint, f64)` requests.
- src/config.rs + src/listen.rs + src/service.rs: type updates
  through the `Arc<RwLock<HashMap<...>>>` shared with the DTLS
  listener, plus per-fingerprint mutators in Service.
- lan-mouse-gtk: `KeyObject` carries the new properties; window
  re-emits them on `AuthorizedUpdated`.

Receive-side application of the new settings (looking up by
fingerprint at handle creation, pushing to InputEmulation) and the
expandable per-row GTK controls land in follow-up commits to keep
the diff focused. The deprecated global `SetNaturalScroll` /
`NaturalScroll` IPC variants stay in place until the global UI
toggle is removed in the cleanup commit.

`FrontendRequest` loses its `Eq`/`PartialEq` derives because `f64`
isn't `Eq`. No callers were comparing requests for equality.

Sensitivity-multiplier algorithm pattern in InputEmulation::consume
(applied in a follow-up commit) is borrowed from feschber#347 by Raidon
Chrome / NeoTheFox, where the global form was originally proposed.

Co-Authored-By: Raidon Chrome <soniczerops@gmail.com>
jondkinney added a commit to jondkinney/lan-mouse that referenced this pull request May 7, 2026
…gerprint

Centralizes scroll-direction inversion and motion-sensitivity scaling
into a single transform site in `InputEmulation::consume`, replacing
the per-backend `set_natural_scroll(bool)` plumbing introduced
earlier in this PR. The platform emulation backends (macos, wlroots,
libei, x11, windows, xdg_desktop_portal) go back to platform-
mechanics-only — no scroll-sign awareness, no shadow per-backend
state, no duplicated transform code.

The active settings are stored per-`EmulationHandle` on
`InputEmulation` itself and applied by mutating the event before it
reaches the backend's `consume()`. The match-arm pattern (multiplier
on `Motion`, sign-flip on `Axis` / `AxisDiscrete120`) follows the
shape used in feschber#347 by Raidon Chrome, ported to per-handle.

Plumbing on the receive side:

- `lan-mouse-ipc` exposes `IncomingPeerConfig` (commit 1).
- `src/emulation.rs::ListenTask` maintains a small cache of
  `addr → fingerprint` (populated from `ListenEvent::Accept`) plus
  the latest `incoming_peers` snapshot pushed by Service.
- On Accept, ListenTask resolves the right `ReceivePostProcessing`
  for the addr and forwards it via `ProxyRequest::SetPostProcessing`
  so EmulationTask can attach it to the handle the moment one is
  assigned.
- On `EmulationRequest::SetIncomingPeers` (Service push triggered
  by user UI changes / authorize / remove / config reload),
  ListenTask re-resolves every known addr and re-publishes to keep
  currently-active sessions in sync.
- `EmulationTask` caches `addr → ReceivePostProcessing` so a
  backend respawn (CGEventTap timeout, portal session restart)
  re-applies the right values to all known handles.

`input-emulation` stays decoupled from `lan-mouse-ipc`; the
conversion from `IncomingPeerConfig` → `ReceivePostProcessing`
happens at the boundary in `src/emulation.rs` so the lower crate
doesn't grow IPC dependencies.

The deprecated global `FrontendRequest::SetNaturalScroll` /
`FrontendEvent::NaturalScroll` IPC variants stay round-tripping
through Service (persist + echo only, no emulation effect) so the
existing GUI toggle continues to render its state until the cleanup
commit removes the global UI surface.

Co-Authored-By: Raidon Chrome <soniczerops@gmail.com>
jondkinney added a commit to jondkinney/lan-mouse that referenced this pull request May 7, 2026
…gerprints

Replaces the bare `description` value in `authorized_fingerprints`
with `IncomingPeerConfig { description, natural_scroll,
mouse_sensitivity }`. Each row in the receive-side authorization
registry now carries its own scroll-direction and motion-sensitivity
preferences, keyed by TLS certificate fingerprint — the only stable
cross-session identity for an inbound peer.

Backwards-compat: legacy configs that store a bare string per
fingerprint deserialize via a custom `Deserialize` impl on
`IncomingPeerConfig` that accepts either shape (untagged enum) and
fills missing fields with defaults (`natural_scroll: false`,
`mouse_sensitivity: 1.0`). No migration tooling needed; existing
config.toml files keep working.

Wires the schema through:
- lan-mouse-ipc: new `IncomingPeerConfig` type;
  `AuthorizedUpdated(HashMap<String, IncomingPeerConfig>)`;
  `SetIncomingPeerNaturalScroll(fingerprint, bool)` and
  `SetIncomingPeerSensitivity(fingerprint, f64)` requests.
- src/config.rs + src/listen.rs + src/service.rs: type updates
  through the `Arc<RwLock<HashMap<...>>>` shared with the DTLS
  listener, plus per-fingerprint mutators in Service.
- lan-mouse-gtk: `KeyObject` carries the new properties; window
  re-emits them on `AuthorizedUpdated`.

Receive-side application of the new settings (looking up by
fingerprint at handle creation, pushing to InputEmulation) and the
expandable per-row GTK controls land in follow-up commits to keep
the diff focused. The deprecated global `SetNaturalScroll` /
`NaturalScroll` IPC variants stay in place until the global UI
toggle is removed in the cleanup commit.

`FrontendRequest` loses its `Eq`/`PartialEq` derives because `f64`
isn't `Eq`. No callers were comparing requests for equality.

Sensitivity-multiplier algorithm pattern in InputEmulation::consume
(applied in a follow-up commit) is borrowed from feschber#347 by Raidon
Chrome / NeoTheFox, where the global form was originally proposed.

Co-Authored-By: Raidon Chrome <soniczerops@gmail.com>
jondkinney added a commit to jondkinney/lan-mouse that referenced this pull request May 7, 2026
…gerprint

Centralizes scroll-direction inversion and motion-sensitivity scaling
into a single transform site in `InputEmulation::consume`, replacing
the per-backend `set_natural_scroll(bool)` plumbing introduced
earlier in this PR. The platform emulation backends (macos, wlroots,
libei, x11, windows, xdg_desktop_portal) go back to platform-
mechanics-only — no scroll-sign awareness, no shadow per-backend
state, no duplicated transform code.

The active settings are stored per-`EmulationHandle` on
`InputEmulation` itself and applied by mutating the event before it
reaches the backend's `consume()`. The match-arm pattern (multiplier
on `Motion`, sign-flip on `Axis` / `AxisDiscrete120`) follows the
shape used in feschber#347 by Raidon Chrome, ported to per-handle.

Plumbing on the receive side:

- `lan-mouse-ipc` exposes `IncomingPeerConfig` (commit 1).
- `src/emulation.rs::ListenTask` maintains a small cache of
  `addr → fingerprint` (populated from `ListenEvent::Accept`) plus
  the latest `incoming_peers` snapshot pushed by Service.
- On Accept, ListenTask resolves the right `ReceivePostProcessing`
  for the addr and forwards it via `ProxyRequest::SetPostProcessing`
  so EmulationTask can attach it to the handle the moment one is
  assigned.
- On `EmulationRequest::SetIncomingPeers` (Service push triggered
  by user UI changes / authorize / remove / config reload),
  ListenTask re-resolves every known addr and re-publishes to keep
  currently-active sessions in sync.
- `EmulationTask` caches `addr → ReceivePostProcessing` so a
  backend respawn (CGEventTap timeout, portal session restart)
  re-applies the right values to all known handles.

`input-emulation` stays decoupled from `lan-mouse-ipc`; the
conversion from `IncomingPeerConfig` → `ReceivePostProcessing`
happens at the boundary in `src/emulation.rs` so the lower crate
doesn't grow IPC dependencies.

The deprecated global `FrontendRequest::SetNaturalScroll` /
`FrontendEvent::NaturalScroll` IPC variants stay round-tripping
through Service (persist + echo only, no emulation effect) so the
existing GUI toggle continues to render its state until the cleanup
commit removes the global UI surface.

Co-Authored-By: Raidon Chrome <soniczerops@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants