Skip to content

Fix raw input mouse position jumping after window state changes#18586

Merged
sonninnos merged 1 commit intolibretro:masterfrom
PoloniumRain:raw-mouse-position-fix
Jan 8, 2026
Merged

Fix raw input mouse position jumping after window state changes#18586
sonninnos merged 1 commit intolibretro:masterfrom
PoloniumRain:raw-mouse-position-fix

Conversation

@PoloniumRain
Copy link
Copy Markdown
Contributor

This fixes multiple Windows raw input issues that can occur after the window state changes, which can cause the mouse pointer to jump around and make incorrect selections on the menu.

Things that can cause this to happen:

  1. Switching between windowed and fullscreen modes.
  2. Window resizes, such as those triggered by cores.
  3. Losing and regaining window focus while in windowed mode.

It's hard to describe exactly how to reproduce each issue, so i've created the video below which shows the behaviour before and after this fix:

Comparison.mp4

The behaviour can vary depending on what menu item was previously selected before the window resize/refocus happened, but it's all the same kind of problems where the mouse jumps around and will do something unintended when clicked. This PR fixes all of these issues by syncing the internal mouse coordinates with the OS cursor position when these window state changes occur.

The raw input mouse behaviour now also matches dinput in these cases (dinput does not have any of these issues).

@sonninnos
Copy link
Copy Markdown
Collaborator

Please keep the code C89 compliant and why not also put that last_focus static bool in the existing winraw_input_t struct instead.

@PoloniumRain PoloniumRain force-pushed the raw-mouse-position-fix branch from 10336b7 to f87cb88 Compare January 6, 2026 20:45
@PoloniumRain
Copy link
Copy Markdown
Contributor Author

@sonninnos Ok, done. To be honest i'm still learning this stuff and completely forgot about C89 😅

@sonninnos
Copy link
Copy Markdown
Collaborator

Nice. Might as well put that old winraw_focus in the struct too while at it and make both as bools.

@PoloniumRain PoloniumRain force-pushed the raw-mouse-position-fix branch from f87cb88 to 31ff088 Compare January 7, 2026 00:12
Comment thread input/drivers/winraw_input.c Outdated
@PoloniumRain PoloniumRain force-pushed the raw-mouse-position-fix branch from 31ff088 to 7bdeba3 Compare January 7, 2026 17:55
@sonninnos sonninnos merged commit 67231fe into libretro:master Jan 8, 2026
34 checks passed
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.

2 participants