[SDL] Locking Mouse

Ryan C. Gordon icculus at clutteredmind.org
Tue Aug 21 04:23:01 PDT 2001

> One solution would be to Wrap the mouse to the position each frame, but if
> the frame rate is low (e.g. with OpenGL) then the mouse cursor moves
> during the subsequent calls of the wrap function.

SDL_ShowCursor(SDL_DISABLE), then draw your own mouse cursor. This gives
you complete control of the rendering, it looks the same on every
platform, etc.

Warping the mouse every frame is inefficient, and causes an unwanted
mousemotion event to boot.

Also, you might want to consider if the user will like the control of
their mouse pointer being restricted arbitrarily. Unless you've got a good
reason, it'll probably be somewhat annoying from a usability standpoint,
but then again, I don't know what exactly you have in mind, so I shouldn't


More information about the SDL mailing list