Time Stamps and Sequence Numbers

When DirectInput input data is buffered (see Buffered and Immediate Data), each DIDEVICEOBJECTDATA structure contains not only information about the type of event and the device object associated with it, but also a time stamp and a sequence number.

The dwTimeStamp member contains the system time in milliseconds at the time the event took place. This is equivalent to the value that would have been returned by the Win32 GetTickCount function.

The dwSequence member contains a sequence number assigned by DirectInput. The DirectInput system keeps a single sequence counter, which is incremented by each non-simultaneous buffered event from any device. You can use this number to compare events from different devices and see which came first. The DISEQUENCE_COMPARE macro takes wraparound into account.

Simultaneous events are assigned the same sequence number. If a mouse or joystick is moved diagonally, for example, the changes in the x-axis and the y-axis have the same sequence number.

Note  Events are always placed in the buffer in chronological order, so you don't need to check the sequence numbers just to sort the events from a single device.