[SDL] Add a timestamp to events
bob at pendleton.com
Wed Jul 27 20:14:07 PDT 2011
On Sat, Jun 11, 2011 at 6:25 AM, Dimitris Zenios
<dimitris.zenios at gmail.com> wrote:
> Hello guys
> I think that adding a timestamp to all SDL_events would be a nice
> feature.That way someone could create double click handling routine by
> subtracting the two timestamps of two click events.
Sorry for the late response, but I happen to agree with you. In fact,
you just outlined one of the reasons for putting timestamps on events
in X. It is the only way to reliably build a user interface based on
the time spacing of events when you can't be sure to process events as
the occur. There are only so many ways to know when something happens.
Also, as someone formally trained in discrete event simulation, I can
tell you that the only way you can reliably interlace real world
events with game events is to have timestamps on real world and
simulated events that can be correlated with each others. One of the
subtle causes of discontinuities in game play, usually blamed on
"lag", are actually the result of improper interleaving of real world
and game events. This is a problem that can not be solved with out
having timestamps on real world events.
So, yes, all events that can reasonably have time stamps should have
times stamps. Ideally timestamps should represent the current GMT
accurate to at least a nanosecond and never rap... so about 128 bits
should do. :-) Ok.... so seriously, the time stamp should be either a
struct timeval (microsecond precision) or a struct timespec
(nanosecond precision) or their cross platform equivalent.
> The way to implement that functionality in my opinion is to add an
> extra Uint32 to the SDL_Event union struct and in the SDL_PushEvent
> function we can do something like that
> SDL_PushEvent(SDL_Event * event)
> event->timestamp = SDL_GetTicks();
> What do you guys think? Looking forward for suggestions.
> Dimitris Zenios
> SDL mailing list
> SDL at lists.libsdl.org
+ Bob Pendleton: writer and programmer
+ email: Bob at Pendleton.com
+ web: www.TheGrumpyProgrammer.com
More information about the SDL