Mouse grabbing : how?

hello,

I’d like to know how I can do mouse grabbing with SDL, like in heroes3
or civCTP when i hit CTRL-G.

Thanks,

PH–
Nothing cures insomnia like the realization that it’s time to get up.

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

Lutz Sammer wrote:

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!

(excuse me, i’m french, and i don’t understand “RTFM” … :slight_smile:

Thank you for your answer. I looked for this function in the
documentation but i couldn’t find it. In which section is it ?

Thanks,
PH.–
Nothing cures insomnia like the realization that it’s time to get up.