[SDL] Problem with SDL_PollEvent and freezing.

Pete caine23 at hotmail.com
Sun Jun 3 18:31:03 PDT 2001


Hi.  I am new to SDL to be kind if I am doing something wrong ^_^  I am just
printing out the x, y co-ords of the mouse as it moves (I print this in the
event section for mouse motion).  If I move the mouse very slowly it is fine
and updates.  If I move the mouse fast around the window it will stop
printing briefly, and then start again.  If I try pressing a key during this
pause, it misses it (for example, I use ESC to quit, and if I press escape
during the pausing, it doesn't quit like it should).

Here is basically what my program looks like so far (if you need more
specifics I can give those).  This is all in main.

bool bQuit = false;
bool bKey[256];
Uint16 xMouse, yMouse;

Init SDL and OpenGL
SDL_EnableUNICODE (1);

 while (!bQuit)
 {
       UpdateInput ();
 }

UpdateInput looks something like this (hopefully it formatting looks ok,
it's a bit hard in outlook).

while (SDL_PollEvent (&event))
{
    switch (event.type)
    {
              case SDL_KEYDOWN:
                    bKey[event.key.keysym.sym] = true;
                    break;

               case SDL_KEYUP:
                    bKey[event.key.keysym.sym] = false;
                    break;

           case SDL_MOUSEMOTION:
                    xMouse = event.motion.x;
                    yMouse = event.motion.y;
                    printf ("(%i, %i)\n", xMouse, yMouse);
                    break;

           case SDL_MOUSEBUTTONDOWN:
                mouseButton[event.button.button] = 1;
                break;

           case SDL_MOUSEBUTTONUP:
                mouseButton[event.button.button] = 0;
                break;

           case SDL_QUIT:
                bQuit = true;
                break;
           }
   default:
        break;
      }
 }






More information about the SDL mailing list