[SDL] SDL mouse events.

Jonathan Dearborn grimfang4 at hotmail.com
Fri Mar 7 20:54:29 PST 2008


I think it should be mentioned explicitly here that it's fine to use "while(SDL_PollEvent)" for things that need non-blocking behavior (e.g. single-threaded) and you're probably polling the queue more frequently than once per second.  For example, with a logic loop running at 50Hz and the mouse pushing events at 500 Hz, you'll be getting an average of 10 events per loop.

Jonny D



Date: Fri, 7 Mar 2008 15:19:58 -0600
From: bob at pendleton.com
To: sdl at lists.libsdl.org
Subject: Re: [SDL] SDL mouse events.



On 3/7/08, Lucas <lucas_pet at live.co.uk> wrote:
I use 'while(SDL_PollEvent...' to manage my mouse events and the following
 questions came to mind:
Yes, there can be many events of every type on the queue.


 Can there be multiple event per type on the queue?
 If so, how many mouse events would there be on the queue if my program runs
 once every second and my mouse gets polled by windows at 500Hz(and moves
 randomly)? 500?

No, not quite 500, the queue is only 128 items long. Once the queue is full SDL just discards any new events. That means you never have to process more than 128 events at a time, but if you only check for events every second and you can have 500 events pile up during a second, you will lose 372 events. The best idea is to use SDL_WaitEvents() to process events as they come in.


      Bob Pendleton
 
 Thanks.
 
 
 
 _______________________________________________

 SDL mailing list
 SDL at lists.libsdl.org
 http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
 


-- 

+ Bob Pendleton: writer and programmer
+ email: Bob at Pendleton.com 
+ web: www.GameProgrammer.com 

+ www.Wise2Food.com

+--------------------------------------+

_________________________________________________________________
Climb to the top of the charts! Play the word scramble challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080307/a93d246c/attachment.html 


More information about the SDL mailing list