Skip to main content
GameDev.net gamedev.net
🔒 Locked

TouchInput structure

Started by fanaticlatic Aug 17, 2012 at 3:04 PM 1 replies 2.2k views
Original Post
fanaticlatic
fanaticlatic
Hello all,

I am trying to implement support for multi-touch in a windows 7 environment.

I am using the following links:
http://msdn.microsof...d562197(v=vs.85).aspx
http://msdn.microsof...d317321(v=vs.85).aspx
http://msdn.microsof...d317334(v=vs.85).aspx

Through all those links I can't seem to find any information on how and when to use the time-stamp (dwTime) member of the TouchIput structure, and more importantly what to do when the time-stamp wraps around.

Currently I check the time-stamp of the event message and compare it too a stored value from the previous frame like so:

[source lang="cpp"]
if( ( touchstore[ i ].dwID == message[ mindex ].dwID ) && ( message[ mindex ].dwTime > touchstore[ i ].dwTime ) )
{
touchstore[ i ] = message;
// do something when touch sequence matches and timestamp of message is newer than stored touch
}
[/source]

dwTime is a DWORD and represents a timestamp in milliseconds, How do I cater for dwTime wrapping around?


Thanks for any help and advice you can provide.

Mark.
"I have more fingers in more pies than a leper at a bakery!"
nobodynews
nobodynews
When a timestamp wraps around the time difference is about 50 days (2^32 milliseconds / 1000 milliseconds per second / 60 seconds per minute / 60 minutes per hour / 24 hours per day = 49.71 days). You could decide that if you receive a message more than an arbitrary time (1 second, 1 hour, 1 day...) before the previous message that it must have occurred *after* the last message even though the times is technically < the last message. Or to integrate it with your code, something like this I believe would work:

if( ( touchstore[ i ].dwID == message[ mindex ].dwID ) && ( ( message[ mindex ].dwTime > touchstore[ i ].dwTime ) || (message [mindex].dwTime < (touchstore[ i ].dwTime - WrapAroundTimeDelta) )) )

Where WrapAroundTimeDelta is something like 86400000 milliseconds (24 hours) in the past.
C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) ,
fanaticlatic
fanaticlatic
Great answer, I was worried about assuming the timestamp used the whole DWORD before a wrap. Thanks. I may put a request into MS to get the wrap around mentioned in the Touch docs.
"I have more fingers in more pies than a leper at a bakery!"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.