| Summary: | SDL_GetRelativeMouseState() acts strange immediately after SDL_SetRelativeMouseMode() on OS X | ||
|---|---|---|---|
| Product: | SDL | Reporter: | jbates |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | jorgen |
| Version: | 2.0.1 | ||
| Hardware: | x86_64 | ||
| OS: | Mac OS X 10.8 | ||
| Attachments: |
Simple test app demonstraing behavior
Simple app demonstrating workaround |
||
|
Description
jbates
2014-03-08 00:23:00 UTC
We just recently fixed something similar to this. Can you try in the latest SDL snapshot? http://www.libsdl.org/tmp/SDL-2.0.zip (In reply to Sam Lantinga from comment #1) > We just recently fixed something similar to this. Can you try in the latest > SDL snapshot? > http://www.libsdl.org/tmp/SDL-2.0.zip The snapshot seems to fix the second case, but not the first. Also, with the snapshot build, when the cursor is restored after SDL_SetRelativeMouseMode(SDL_FALSE), it's placed at the center of the window instead of where it was last before SDL_SetRelativeMouseMode(SDL_TRUE). If at all possible, I'd like to keep the old behavior where the cursor coordinates are retained between calls. Let me see if I can come up with a small example program demonstrating the issue. Created attachment 1584 [details]
Simple test app demonstraing behavior
Here's a small test app. It outputs to stdout every time SDL_GetRelativeMouseState() returns a dimension whose absolute value is greater than 50. Left mouse down callsSetRelativeMouseMode(SDL_TRUE), and vice-versa for mouse up.
To demonstrate the bug:
1. Press the mouse button somewhere far from the center of the window. Don't move the mouse or release the button. On OS X, it outputs the delta from the cursor to the center of the window. On Linux and Windows, no mouse motion is registered.
2. Release the mouse button. On OS X, it outputs the delta from the center of the window back to where the cursor is restored (in the snapshot build, the cursor is restored to the center of the window, so nothing happens). On Linux and Windows, no mouse motion is registered.
3. Now double-click and hold the mouse button, careful not to move the mouse. Sometimes (I'm not sure of the exact case) the next time you move the mouse while still holding the button, a larger than expected relative mouse motion is reported on OS X.
Bottom line, SDL_GetRelativeMouseState() acts inconsistently after calls to SDL_SetRelativeMouseMode() on OS X.
Created attachment 1585 [details]
Simple app demonstrating workaround
And here's the same app with the workaround I developed. It calls SDL_GetRelativeMouseState(NULL, NULL) just before the cases that were producing the unexpected results. Including it makes my program operate more-consistently between platforms (OS X, Windows, and Linux)
|