libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
8.69k stars 1.63k forks source link

Confused about warp requirements. #9793

Open codecnotsupported opened 1 month ago

codecnotsupported commented 1 month ago

For SDL2 warping isn't supported if the cursor is visible. However when I removed the check it still works fine. https://github.com/libsdl-org/SDL/blob/0805990668bdf92f4602520c9b7fed6edd90b448/src/video/wayland/SDL_waylandmouse.c#L639-L655

Why is the visible check there in the first place?

For SDL3: https://github.com/libsdl-org/SDL/blob/1103294d33f47ab4c697bb22a9cf27c79c658630/src/video/wayland/SDL_waylandmouse.c#L572-L614

I don't understand the following requirement: https://github.com/libsdl-org/SDL/blob/1103294d33f47ab4c697bb22a9cf27c79c658630/src/video/wayland/SDL_waylandmouse.c#L579 Why does the visibility of the cursor matter? Why does it work if warp emulation is prohibited and the mouse mode is absolute?

Kontrabant commented 1 month ago

It's a hack to work around older games that handle camera movement by hiding the cursor and constantly warping it back to the center while measuring the distance that it moved. Special care has to be taken in this scenario, or the cursor can wind up outside of the window and cannot be warped back in.

codecnotsupported commented 1 month ago

It's a hack to work around older games that handle camera movement by hiding the cursor and constantly warping it back to the center while measuring the distance that it moved. Special care has to be taken in this scenario, or the cursor can wind up outside of the window and cannot be warped back in.

I may be misunderstanding/missing a piece of information, but why not allow warping regardless of visibility?