hey, im having a little problem with SDL and mousemotion events. im using
linux (2.4.6), sdl version 1.2.2.9 (from the SDL_version.h header), X windows
version 4.0.2. its a much updated slackware 7.1 instalation.
basically, my problem is that i recieve mousmotion events constantly, even
when the mouse isnt moving. they stop when i press a key on the keyboard,
but start up again each time i move the mouse. the really weird thing (and
whats causing problems for me) is that if i havent moved the mouse, xrel, and
yrel are set at whatever they were last time i did move the mouse (it wouldnt
be quite so bad if they were both set to 0)
here is a compilable copy of what i am doing:
#include <stdlib.h>
#include <iostream.h>
#include <stdio.h>
#include <GL/gl.h>
#include <SDL/SDL.h>
int main(int argc, char *argv[])
{
if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
SDL_Surface *screen;
screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL );
if ( screen == NULL )
{
fprintf(stderr, "Unable to set 640x480 video: %s\n", SDL_GetError());
exit(1);
}
SDL_ShowCursor(0);
SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_Event event;
Uint8 * keys;
int i=0;
while(event.type != SDL_QUIT)
{
SDL_PollEvent(&event);
switch (event.type)
{
case SDL_KEYDOWN:
keys = SDL_GetKeyState(NULL);
if(keys[SDLK_ESCAPE])
{
exit(0);
}
break;
case SDL_MOUSEMOTION:
cout<<"got mousemotion event: "<<i<<endl;
i++;
break;
case SDL_QUIT:
exit(0);
}
}
return 0;
}
ok, i fixed it. i wasnt checking to see if SDL_PollEvent returned one or
zero…On Tuesday 23 October 2001 08:21, you wrote:
hey, im having a little problem with SDL and mousemotion events. im using
linux (2.4.6), sdl version 1.2.2.9 (from the SDL_version.h header), X
windows version 4.0.2. its a much updated slackware 7.1 instalation.
basically, my problem is that i recieve mousmotion events constantly, even
when the mouse isnt moving. they stop when i press a key on the keyboard,
but start up again each time i move the mouse. the really weird thing (and
whats causing problems for me) is that if i havent moved the mouse, xrel,
and yrel are set at whatever they were last time i did move the mouse (it
wouldnt be quite so bad if they were both set to 0)
here is a compilable copy of what i am doing:
#include <stdlib.h>
#include <iostream.h>
#include <stdio.h>
#include <GL/gl.h>
#include <SDL/SDL.h>
int main(int argc, char *argv[])
{
if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, “Unable to initialize SDL: %s\n”, SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
SDL_Surface *screen;
screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL );
if ( screen == NULL )
{
fprintf(stderr, “Unable to set 640x480 video: %s\n”, SDL_GetError());
exit(1);
}
SDL_ShowCursor(0);
SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
SDL_DEFAULT_REPEAT_INTERVAL);
SDL_Event event;
Uint8 * keys;
int i=0;
while(event.type != SDL_QUIT)
{
SDL_PollEvent(&event);
switch (event.type)
{
case SDL_KEYDOWN:
keys = SDL_GetKeyState(NULL);
if(keys[SDLK_ESCAPE])
{
exit(0);
}
break;
case SDL_MOUSEMOTION:
cout<<"got mousemotion event: "<<i<<endl;
i++;
break;
case SDL_QUIT:
exit(0);
}
}
return 0;
}
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl