Reset border wait state after timeout to avoid permanent stall#14
Open
Joke-it wants to merge 1 commit into
Open
Reset border wait state after timeout to avoid permanent stall#14Joke-it wants to merge 1 commit into
Joke-it wants to merge 1 commit into
Conversation
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.
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),
lmsssends the border-crosscommand but the device — correctly — never replies with a position command
(
05 00). Becauselast_sent_posis only ever cleared by an incoming05 00packet and there is no timeout,
lmssstays in the "waiting" state forever andsilently 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 theUSB event handler, drop
last_sent_posonceBORDER_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
mainon Linux Mint (X11), single 1920x1080 screen, USB DeskswitchIII (firmware V1.8).
no position cmd within timeout, resetting border wait stateafter ~500 ms,and the next crossing works without a hotkey.
05 00 00 04/05 00 00 03responses 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) insrc/usb.cppand can be tuned if a different margin is preferred.