Skip to content

Fix cursor jumping when a pointing device is attached to each board (#263) - #357

Open
mglushko wants to merge 1 commit into
hrvach:mainfrom
mglushko:fix-pointer-sync
Open

Fix cursor jumping when a pointing device is attached to each board (#263)#357
mglushko wants to merge 1 commit into
hrvach:mainfrom
mglushko:fix-pointer-sync

Conversation

@mglushko

@mglushko mglushko commented Aug 3, 2026

Copy link
Copy Markdown

Summary

Fixes the cursor jumping to a screen corner (and often triggering an unwanted output switch) when there is a pointing device attached to both boards — e.g. a keyboard with an integrated trackball on one and a regular mouse on the other. Hopefully this fully fixes #263.

Root cause

Each board tracks pointer_x/pointer_y independently, but there is only one cursor. Position was only ever propagated in one direction: the non-active board forwards full mouse reports over UART and the active board adopts them. Nothing traveled back, so a pointing device on the active board would move the cursor while the other board kept a stale position.

Two visible symptoms:

  1. Jump in from a corner after switching. switch_to_another_pc() sends a hidden_pointer report to park the cursor in a corner of the outgoing screen. When that screen belongs to the other board, the report goes over UART and handle_mouse_abs_uart_msg() stores the parking coordinates as a real cursor position. The next movement from that board resumes from the corner — and since the parked X sits on the screen edge, even a tiny movement satisfies the edge check and triggers an immediate switch back.

  2. Snap to the other device's last position. Alternating between the two pointing devices moved the cursor back to wherever the other board last recorded it.

Changes

  • New POINTER_SYNC_MSG packet type carrying the cursor's x/y.
  • sync_pointer_position() publishes the current position to the other board.
  • Sent at the end of switch_to_another_pc() (which also overwrites the parking coordinates left by the park report), and on movement when the board is the active output — the case where the report otherwise stays local.

No config, webconfig, or flash-layout changes.

Testing

Verified on hardware with a pointing device on each board (mouse in the mouse port, a second mouse in the keyboard port):

  • Alternating between the two devices no longer snaps the cursor.
  • Crossing screens with one device then using the other no longer jumps in from the corner.
  • Nudging the second device after crossing no longer causes an unwanted switch back.

Each board tracks the cursor position independently, but there is only one
cursor. Positions were only ever propagated in one direction: the non-active
board forwards full mouse reports over UART, which the active board adopts.
Nothing travelled the other way, so whenever a pointing device on the active
board moved the cursor, the other board kept a stale position.

With a pointing device on each board (e.g. a keyboard with an integrated
trackball plus a regular mouse) the cursor therefore jumped back to whatever
position the other board last recorded as soon as that other device was used.

Two cases are fixed:

 - switch_to_another_pc parks the cursor in a corner of the outgoing screen via
   a hidden_pointer report. When that screen belongs to the other board the
   report travels over UART and the receiving board stored the parking
   coordinates as a real cursor position, so the next movement from that board
   jumped in from the corner. As the parked X sits on the screen edge, the
   smallest movement then triggered an unwanted switch back.

 - Ordinary movement by the active board is now published to the other board,
   so alternating between pointing devices no longer snaps the cursor back to
   the other device_s last known position.

Fixes hrvach#263
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.

On one PC, mouse always jumps to top right corner after keyboard input

1 participant