Jump to content
  • Advertisement
Sign in to follow this  
deftware

SDL and windowed mouse input

This topic is 3179 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all. I'm working on a project that I'd like to allow users to run in windowed mode. The problem I'm having is figuring a way to 'capture' the mouse from SDL so that they don't lose control over their camera when the cursor moves outside the window (as SDL_MOUSEEVENTs aren't generated when the mouse isn't over the application window). The best solution I've come up with so far is to re-center the mouse over the center of the window each frame, and poll the mouse position's deviation from that center point to use as the measured user input. Now, I'd need to figure the 'center' of the window to warp the mouse cursor to, but SDL only lets me retrieve the scale of the app window, and not its x/y position. The documentation doesn't say whether or not SDL_WarpMouse is relative to the window, or absolute on the screen. The end goal is just to allow mouse input in windowed mode, in an SDL application.. Any ideas ? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
The function SDL_GrapInput might help.

AFAIK all SDL's mouse co-ordinates are reported relative to the window. The functions SDL_GetMouseState() and SDL_GetMouseStateRelative() might also help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!