Getting mouse location when outside the window?

I’ve noticed that both SDL_MOUSEMOTION events and SDL_GetMouseState() return 0,0 if the mouse is outside the SDL window (I have only one). Is there any way to get the mouse’s location when it’s outside the window? I’m allowing the user to click and drag to scroll the game’s view, and it’s frustrating to have it abruptly stop as soon as the mouse leaves the window.

-Vern

VernJensen wrote:

I’ve noticed that both SDL_MOUSEMOTION events and SDL_GetMouseState() return 0,0 if the mouse is outside the SDL window (I have only one). Is there any way to get the mouse’s location when it’s outside the window? I’m allowing the user to click and drag to scroll the game’s view, and it’s frustrating to have it abruptly stop as soon as the mouse leaves the window.

Even if it was supported, it wouldn’t likely be portable to every OS. I think the proper cross platform way to play nice on an OS to watch for an SDL_WINDOWEVENT_LEAVE event and stop drawing your cursor, starting again once you get an SDL_WINDOWEVENT_ENTER.------------------------
| Mike Kasprzak | Sykhronics Entertainment (http://www.sykhronics.com) | Blog (http://www.toonormal.com) | Twitter (http://www.twitter.com/mikekasprzak) |

Okay, sorry for the double post, but playing around with a few apps on Windows it looks like once a click breaks a border of a window, it begins scrolling at a constant rate. You should be able to achieve this behavior by noting the last know position and the “leave” event, and picking the nearest edge as the direction. If other messages are still being sent (mouse movements without co-ords), nudging the auto-scroll a unit per message would look the same.------------------------
| Mike Kasprzak | Sykhronics Entertainment (http://www.sykhronics.com) | Blog (http://www.toonormal.com) | Twitter (http://www.twitter.com/mikekasprzak) |