[SDL] SDL_WaitEventTimeout

barrett at 9hells.org barrett at 9hells.org
Thu Nov 6 12:42:01 PST 2003

On Thu, Nov 06, 2003 at 01:47:49PM -0600, Bob Pendleton wrote:
> You need to let us know which OS you are running on so we can properly
> answer the question. Some points to consider.

Linux 2.4.21

> o There is an event queue. If it fills up SDL quietly drops the events.

I looked at the src/events/SDL_events.c, it seems that the queue holds
128 events. The barcode reader sends 11 chars, so 22 events, that
shouldn't be a problem.

> o On most OSes a SDL_Delay(1) will wait for an average of 5
> milliseconds. That happens because the clock ticks every 10
> milliseconds. In a tight loop such as the one you describe the delay
> will tend to synch up with the clock and you will usually delay slightly
> less than 10 milliseconds.

Well, I'm not able to pass the barcode cards twice in less then 50ms.

> o Event handling is OS specific so, to really understand what is going
> on you have to look at the code for the OS you are using.
> My *guess* is that the bar code scanner is send keys very quickly and
> some of them are getting dropped by the OS. How many characters are
> being sent? Is the OS buffering them too? If so, how big is its buffer?
> Is it big enough to hold all the data the card reader is sending? If
> not, the characters are mostly like being dropped by the OS during the
> long wait for SDL_Delay(1) to return.

I tested it in the console, and it never miss a key.

> 			Bob Pendleton


More information about the SDL mailing list