Hi everyone,
The mouse relative and absolute coordinates appear to be always equal for
the first mouse event. Also, there is always a mouse event generated when
grabbing the mouse. Isn’t that odd? That causes my small test programs using
mouse input not to init as I intend them to.
Here’s a small program illustrating what I’m saying. It quits right away
because a mouse event is detected. I wouldn’t expect mouse events to occur
unless asking for it explicitely (moving mouse, warp call and such).
My newbie self thanks you in advance for your kind help!
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
int main(int argc, char *argv[])
{
SDL_bool exit_flag = SDL_FALSE;
SDL_Surface *screen;
SDL_Event event;
if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ))
{
fprintf( stderr, “Unable to init SDL: %s\n”, SDL_GetError() );
exit( 255 );
}
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_HWSURFACE |
SDL_DOUBLEBUF );
if (!screen)
{
fprintf( stderr, “Unable to set resolution: %s\n”, SDL_GetError() );
exit ( 255 );
}
SDL_WM_GrabInput( SDL_GRAB_ON );
do {
if (SDL_PollEvent( &event ))
{
switch (event.type)
{
case SDL_MOUSEMOTION:
{
fprintf( stderr, “mousex = %d, mousey = %d\n”, event.motion.x,
event.motion.y );
fprintf( stderr, “relx = %d, rely = %d\n”, event.motion.xrel,
event.motion.yrel );
exit_flag = SDL_TRUE;
break;
}
}
}
} while (!exit_flag);
SDL_FreeSurface( screen ); // may be before or after SDL_Quit
SDL_Quit();
}_________________________________________________________________
MSN Messenger : discutez en direct avec vos amis !
http://messenger.fr.msn.ca/