| Summary: | SDL_SetRelativeMouseMode causes xrel/yrel in SDL_MOUSEMOTION to be large absolute values | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Wouter van Oortmerssen <aardappel> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | NEW --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | an.ev.tw, antbir, ice_ix, philipp.wiesemann, sezeroz |
| Version: | 2.0.3 | Keywords: | target-2.0.16 |
| Hardware: | x86_64 | ||
| OS: | Linux | ||
|
Description
Wouter van Oortmerssen
2015-04-21 23:59:20 UTC
Same issue on Debian. In testing, this appears to be a problem when running on Wayland, or in a Virtual Machine. Debian Jessie amd64 VMWare 12 X11 + Gnome SDL_SetMouseRelativeMode(SDL_TRUE) - bad xrel and yrel values. Debian Sid amd64 Thinkpad W530 bare metal X11 + Gnome SDL_SetMouseRelativeMode(SDL_TRUE) - working fine. Debian Sid amd64 Thinkpad W530 bare metal Wayland + Gnome SDL_SetMouseRelativeMode(SDL_TRUE) - bad xrel and yrel values. Setting SDL_SetMouseRelativeMode(SDL_FALSE) seems to help, but defeats the point of capturing mouse movement. To add, SDL_SetHintWithPriority(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1", SDL_HINT_OVERRIDE); This does help, but doesn't seem to warp the mouse back to center. There is currently no relative mouse mode and no warping implemented in SDL for Wayland. SDL_SetRelativeMouseMode() should return -1 if there is no support for relative mouse mode. The (later) bug #3226 describes similar problems on Android where it is also not implemented. Yes, for me this also happens in a VirtualBox VM (one that has been set up with 2d & 3d hardware accelleration, latest version, latest guest drivers). Thing is, if SDL_SetMouseRelativeMode failing with -1 is the cause of the problem, why does it still affect the xrel/yrel values? These values seem to work fine if SDL_SetMouseRelativeMode is never called. I'm not familiar with what kind of support SDL_SetMouseRelativeMode needs from the system, but wouldn't it be more useful if instead of failing it emulated relative mouse mode values to the best of its abilities (by supplying the delta between the last two mouse positions) rather than bogus values? From https://bugzilla.libsdl.org/show_bug.cgi?id=2150 - this occurs on Ubuntu Linux 18.04.1 in a VMware Fusion virtual machine, the above workaround posted works however (also thanks to https://stackoverflow.com/questions/25576438/sdl-getrelativemousestate-strange-behaviour). Example test program, uncomment hint to demonstrate the issue: // cc sdlmotion.c -lSDL2 #include <SDL2/SDL.h> int main() { SDL_Window *window = SDL_CreateWindow("Demo Game", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL); SDL_Event event; // https://stackoverflow.com/questions/25576438/sdl-getrelativemousestate-strange-behaviour SDL_SetHintWithPriority(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1", SDL_HINT_OVERRIDE); printf("SDL_SetRelativeMouseMode = %d\n", SDL_SetRelativeMouseMode(SDL_TRUE)); do { while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_QUIT: exit(0); case SDL_MOUSEMOTION: printf("x=%d, y=%d, xrel=%d, yrel=%d\n", event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); } } } while(1); } I am also seeing this issue with SDL 2.0.10. I'm testing on Ubuntu 18.04 in a VMWware Workstation 15 Player VM. The above workaround stops the extreme mouse warping but it still doesn't quite fix everything as the mouse input now lags a LOT. I did not see this issue on Mac. Additional information: - This also happens on Ubuntu 14.04.6 LTS 32-bit (in a VMWare Workstation 15 Player VM) - Even with the workaround, my xrel/yrel values make no sense. They're just absolute positions relative to the center of the window - Once I reach the edge of the window, my xrel/yrel values become 0 What Wouter said seems to apply to VMware in its default configuration. Setting vmmouse.present to false in my vm configuration solved this problem. I did not need the warp hint after doing this. |