Sign in to follow this  

Direct Input Order of Input

This topic is 4731 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

In Direct Input buffered mode, when using both keyboard and mouse, how do I figure out which inputs go in which order? That is, when GetDeviceData is called (once for mouse and once for keyboard), the arrays are filled with the buffered data, in the order which they occured. The problem is that how can I decide if the mouse events came before or after the keyboard events, or if some mouse events came before and some after the keyboard events? When processing the data it becomes necessary to know the order of events. For example, Player1 has a bolt gun equipped. Player2 just got shot, and Player1 presses "2" to switch to a repair box and clicks to repair Player2's armor, all faster than a frame. Now wait- I don't know how to order the processing so I have mouse processing before keyboard, so instead of switching to a repair box and healing Player2, Player1 fires once with his bolt gun and kills Player2, then switches to a repair box. You see my problem?

Share this post


Link to post
Share on other sites
Just compare the input events' dwTimeStamp fields (in the DIDEVICEOBJECTDATA structure). However since you're probably retrieving any new input within a couple of milliseconds this shouldn't really be necessary.

Share this post


Link to post
Share on other sites
Quote:
Original post by jtmerchant
Would it be faster to compare the dwTimeStamp member or the dwSequence member of the DIDEVICEOBJECTDATA structure?
It really doesn't matter. You won't be processing more than an event or two per frame anyway.
However I guess comparing the sequence numbers would be safer since you can rely on DISEQUENCE_COMPARE to handle wrapping for you.

Share this post


Link to post
Share on other sites

This topic is 4731 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