[SDL] Mouse grabbing : how ?

Lutz Sammer johns98 at gmx.net
Thu Jun 8 14:14:49 PDT 2000


PH-Neutre wrote:
> 
> hello,
> 
> I'd like to know how I can do mouse grabbing with SDL, like in heroes3
> or civCTP when i hit CTRL-G.

RTFM!

#ifdef SDL_GRAB_ON
    static int grabbed;

    if( grabbed ) {
        SDL_WM_GrabInput(SDL_GRAB_OFF);
        grabbed=0;
    } else {
        if( SDL_WM_GrabInput(SDL_GRAB_ON)==SDL_GRAB_ON ) {
            grabbed=1;
        }
    }
#endif  // SDL_GRAB_ON

The #define is for older SDL version which didn't support this function.

Bye,
Johns
-- 
Become famous, earn no money, create graphics for FreeCraft.

http://FreeCraft.Org - A free fantasy real-time strategy game engine
http://fgp.cjb.net   - The FreeCraft Graphics Project



More information about the SDL mailing list