Skip to content

Reset border wait state after timeout to avoid permanent stall#14

Open
Joke-it wants to merge 1 commit into
WEYTEC:mainfrom
Joke-it:fix/border-timeout
Open

Reset border wait state after timeout to avoid permanent stall#14
Joke-it wants to merge 1 commit into
WEYTEC:mainfrom
Joke-it:fix/border-timeout

Conversation

@Joke-it

@Joke-it Joke-it commented Jun 12, 2026

Copy link
Copy Markdown

PR title

Reset border wait state after a timeout to avoid permanent mouse-switch stall

PR description

Problem

When the mouse hits a screen border that has no neighbour configured on the
WEY device (e.g. the outer edge of the layout), lmss sends the border-cross
command but the device — correctly — never replies with a position command
(05 00). Because last_sent_pos is only ever cleared by an incoming 05 00
packet and there is no timeout, lmss stays in the "waiting" state forever and
silently drops all subsequent border crossings, including valid ones in
other directions. The only way to recover is a hotkey switch, which makes the
device emit a fresh 05 00.

This is easy to hit with a single-screen source that sits at the edge of the
arrangement: one push against that dead edge disables mouse switching entirely.

Fix

Record the timestamp when a border-cross is sent (last_sent_time) and, in the
USB event handler, drop last_sent_pos once BORDER_RESPONSE_TIMEOUT (500 ms)
has elapsed without a position command. After that the next border-cross is
sent normally and switching recovers on its own.

A valid cross is acknowledged by the device within a few tens of milliseconds
(observed ~30 ms), so the 500 ms margin never interferes with normal switching.

Testing

Built from main on Linux Mint (X11), single 1920x1080 screen, USB Deskswitch
III (firmware V1.8).

  • Pushing against a dead edge now logs
    no position cmd within timeout, resetting border wait state after ~500 ms,
    and the next crossing works without a hotkey.
  • Valid crossings are unaffected: the device's 05 00 00 04 / 05 00 00 03
    responses arrive long before the timeout, so the wait state is cleared by the
    response as before.

Notes

The timeout value is a single named constant (BORDER_RESPONSE_TIMEOUT) in
src/usb.cpp and can be tuned if a different margin is preferred.

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.

1 participant