sdlterm/src/sdlterm.cc
changeset 62 2f61931520c9
parent 61 15088f62c4ac
child 67 71f60bf6ebb7
equal deleted inserted replaced
61:15088f62c4ac 62:2f61931520c9
   369 }
   369 }
   370 
   370 
   371 
   371 
   372 bool Terminal::wait_event(Event &event, Uint32 timeout)
   372 bool Terminal::wait_event(Event &event, Uint32 timeout)
   373 {
   373 {
   374     static SDL_Event sdl_event;
       
   375     bool event_ready = false;
       
   376 
       
   377     // use timer to simulate SDL_WaitEventTimeout, which is not available in SDL 1.2
   374     // use timer to simulate SDL_WaitEventTimeout, which is not available in SDL 1.2
   378     SDL_TimerID timer_id = NULL;
   375     SDL_TimerID timer_id = NULL;
   379     if (timeout)
   376     if (timeout)
   380     {
   377     {
   381         timer_id = SDL_AddTimer(timeout, _wait_event_callback, NULL);
   378         timer_id = SDL_AddTimer(timeout, _wait_event_callback, NULL);
   382     }
   379     }
   383 
   380 
       
   381     // loop until we have something to return
       
   382     SDL_Event sdl_event;
       
   383     bool event_ready = false;
   384     while (SDL_WaitEvent(&sdl_event) && !event_ready)
   384     while (SDL_WaitEvent(&sdl_event) && !event_ready)
   385     {
   385     {
   386         switch (sdl_event.type)
   386         switch (sdl_event.type)
   387         {
   387         {
   388             case SDL_USEREVENT:
   388             case SDL_USEREVENT: