Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Fix SDL_WarpMouseInWindow on both KMSDRM and RaspberryPi drivers #2730

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.7
Reported for operating system, platform: Linux, All

Comments on the original bug report:

On 2017-11-20 11:50:36 +0000, Manuel Alfayate Corchete wrote:

Created attachment 3094
Small patch that fixes SDL_WarpMouseInWindow() on KMSDRM and Raspberry Pi graphic backends

Hi,

This patch fixes SDL_WarpMouseInWindow() in both the KMSDRM and Raspberry Pi graphic backends.

When we warp a mouse cursor, we also MUST set the new mouse coordinates, not only move the cursor graphic position. This simple patch does precisely that.
Not doing so causes the mouse to have internal coordinates bigger than on-screen position, thus causing the cursor to get "sticky" on the edges when the game area is smaller than the total window size (which is the whole physical resolution on x-less, fullscreen systems)

It fixes the bug report I previously did here:
https://bugzilla.libsdl.org/show_bug.cgi?id=3970

Now, for example, the current Scummvm GIT version (due for release soon) works as expected on the Pi and KMSDRM embedded-like enviroments.

Please, merge ASAP, it's a very simple yet important fix.

On 2017-11-22 05:42:38 +0000, Sam Lantinga wrote:

Typically drivers call SDL_SendMouseMotion() instead of setting the mouse variables directly. This is standard behavior and apps should be waiting for a mouse motion event with the coordinates that they just called warp with.

Can you make that change for both drivers and test it there?

Thanks!

On 2017-11-22 20:46:08 +0000, Manuel Alfayate Corchete wrote:

(In reply to Sam Lantinga from comment # 1)

Typically drivers call SDL_SendMouseMotion() instead of setting the mouse
variables directly. This is standard behavior and apps should be waiting for
a mouse motion event with the coordinates that they just called warp with.

Can you make that change for both drivers and test it there?

Thanks!

That's not such a good idea as things are: tried to use SDL_SendMouseMotion() instead, and that causes a segfault when the cursor is hidden.
Something must be done in SDL_SendMouseMotion() sub-functions to correct that, but I don't have the time.
If you get it to operate safely when the cursor is hidden (yes, that makes sense and is used in Scummvm) we could use SDL_SendMouseMotion() instead if you want.
But as things are now, manually updating the position is the only working way.

On 2017-11-24 11:02:55 +0000, Sam Lantinga wrote:

I don't have a KMSDRM or Raspberry Pi testing environment, can you investigate why it's crashing when the mouse is hidden? That sounds like a bug - it should be safe to call it anytime.

On 2017-11-25 21:58:03 +0000, Manuel Alfayate Corchete wrote:

Created attachment 3101
Patch that fixes sticky cursor on programs were mouse coords are tracked but cursor area is smaller than total screen area

On 2017-11-25 21:59:17 +0000, Manuel Alfayate Corchete wrote:

(In reply to Sam Lantinga from comment # 3)

I don't have a KMSDRM or Raspberry Pi testing environment, can you
investigate why it's crashing when the mouse is hidden? That sounds like a
bug - it should be safe to call it anytime.

In the end, it was a recursion bug:
KMSDRM_MoveCursor() was calling
KMSDRM_WarpMouse() was calling
SDL_SendMouseMotion() was calling
SDL_PrivateSendMouseMotion() was calling
KMSDRM_MoveCursor().... Boom!!! :D

So calling SDL_WarpMouse in KMSDRM_MoveCursor was plain wrong. Cursor HAS to be moved, but not calling KMSDRM_WarpMouse()... bad, bad idea.

Anyway, here's what I hope to be the final patch on this. It works by callin SendMouseMotion as intended, and works perfectly well on both the Raspberry Pi and KMSDRM. Please merge: I really want this fixed. (The patch is in the previous message)

On 2017-12-05 04:37:23 +0000, Sam Lantinga wrote:

Fixed, thanks!
https://hg.libsdl.org/SDL/rev/73826bd39748

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

No branches or pull requests

1 participant