Giter Club home page Giter Club logo

Comments (7)

Kontrabant avatar Kontrabant commented on September 13, 2024

This is unlikely to ever be fixed in SDL2, as mouse coordinates are treated everywhere in the library as integers. SDL3 uses floats for pointer coordinates to avoid losing subpixel precision, including for warp destination coordinates.

SDL2 also doesn't implement setting the pointer position hint via the confinement protocol in the Wayland driver, so it won't appear to be affected because any warp functionality is a no-op.

from sdl.

slouken avatar slouken commented on September 13, 2024

Does this happen with SDL3, using the latest code in main?

from sdl.

mahkoh avatar mahkoh commented on September 13, 2024

Can I use SDL3 as a drop in in a proprietary game that currently uses SDL2? Otherwise, can you recommend some demo application that I can test SDL3 with?

Edit: It would have to be an application that uses absolute motion + warp to emulate relative motion. I believe that relative motion works as expected since it uses raw motion data that usually has no fractional component.

Edit: I tried sdl2-compat and in X11 mode the pointer is unable to move at all even if I move the mouse quickly so that the delta should be >=1. Wayland continues to work as expected.

from sdl.

slouken avatar slouken commented on September 13, 2024

Conceptually, I would think a warp would clear out any fractional mouse motion when it resets the position. I'm curious why this works on Wayland?

from sdl.

mahkoh avatar mahkoh commented on September 13, 2024

It appears that the wayland driver automatically switches into relative motion mode if the application tries to warp the cursor and the cursor is invisible.

from sdl.

slouken avatar slouken commented on September 13, 2024

That makes sense. I wonder if we should do that for other drivers?

from sdl.

Kontrabant avatar Kontrabant commented on September 13, 2024

Additionally, it looks like XWayland converts absolute pointer coordinates to integers internally: https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/hw/xwayland/xwayland-input.c#L660

With SDL3 under a real X session, subpixel pointer coordinates are passed through. On XWayland, I'm only seeing integers.

That makes sense. I wonder if we should do that for other drivers?

It wouldn't be hard to move the activation logic to the mouse layer, and the Wayland SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP hint could be repurposed for the general case. The one 'gotcha' case to watch out for is when SDL tries to warp the pointer during fullscreen transitions, as this has inadvertently activated the relative mode emulation when it shouldn't if the client has the system cursor hidden in favor of drawing their own software cursor.

e: Running testrelative with SDL_MOUSE_RELATIVE_MODE_WARP=1 shows just how badly the rounding affects the movement under XWayland.

from sdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.