Skip to content

Commit

Permalink
Check for duplicate timestamp. Workaround if duplicate is found
Browse files Browse the repository at this point in the history
Can happen when using the highest BT poll rate for
the DS4. Related to issue Ryochan7#1546
  • Loading branch information
Ryochan7 committed Nov 16, 2020
1 parent dc4e3fc commit 47f4f23
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions DS4Windows/DS4Library/DS4Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,21 @@ protected unsafe void performDs4Input()
deltaTimeCurrent = tempDelta * 16u / 3u;
}

timeStampPrevious = tempStamp;
elapsedDeltaTime = 0.000001 * deltaTimeCurrent; // Convert from microseconds to seconds
// Make sure timestamps don't match
if (deltaTimeCurrent != 0)
{
elapsedDeltaTime = 0.000001 * deltaTimeCurrent; // Convert from microseconds to seconds
cState.totalMicroSec = pState.totalMicroSec + deltaTimeCurrent;
}
else
{
// Duplicate timestamp. Use system clock for elapsed time instead
elapsedDeltaTime = lastTimeElapsedDouble * .001;
cState.totalMicroSec = pState.totalMicroSec + (uint)(elapsedDeltaTime * 1000000);
}

cState.elapsedTime = elapsedDeltaTime;
cState.totalMicroSec = pState.totalMicroSec + deltaTimeCurrent;
timeStampPrevious = tempStamp;

//Simpler touch storing
cState.TrackPadTouch0.Id = (byte)(inputReport[35] & 0x7f);
Expand Down

0 comments on commit 47f4f23

Please sign in to comment.