Sign in to follow this  

TouchInput structure

This topic is 1978 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all,

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

I am using the following links:
[url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd562197(v=vs.85"]http://msdn.microsof...d562197(v=vs.85[/url]).aspx
[url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd317321(v=vs.85"]http://msdn.microsof...d317321(v=vs.85[/url]).aspx
[url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd317334(v=vs.85"]http://msdn.microsof...d317334(v=vs.85[/url]).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. Edited by fanaticlatic

Share this post


Link to post
Share on other sites
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:

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

Where WrapAroundTimeDelta is something like 86400000 milliseconds (24 hours) in the past.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 1978 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this