Opt to use high resolution counter

This commit is contained in:
Travis Nickles 2020-02-12 12:38:07 -06:00
parent fc249a6a5e
commit af5d06c42b

View File

@ -770,6 +770,7 @@ namespace DS4Windows
long oldtime = 0; long oldtime = 0;
string currerror = string.Empty; string currerror = string.Empty;
long curtime = 0; long curtime = 0;
long testelapsed = 0;
Stopwatch sw = new Stopwatch(); Stopwatch sw = new Stopwatch();
sw.Start(); sw.Start();
timeoutEvent = false; timeoutEvent = false;
@ -895,14 +896,20 @@ namespace DS4Windows
} }
} }
curTimeDouble = sw.Elapsed.TotalMilliseconds; curtime = Stopwatch.GetTimestamp();
curtime = sw.ElapsedMilliseconds; testelapsed = curtime - oldtime;
lastTimeElapsedDouble = testelapsed * (1.0 / Stopwatch.Frequency) * 1000.0;
lastTimeElapsed = curtime - oldtime; lastTimeElapsed = (long)lastTimeElapsedDouble;
lastTimeElapsedDouble = (curTimeDouble - oldTimeDouble);
oldtime = curtime; oldtime = curtime;
oldTimeDouble = curTimeDouble;
//curTimeDouble = sw.Elapsed.TotalMilliseconds;
//curtime = sw.ElapsedMilliseconds;
//lastTimeElapsed = curtime - oldtime;
//lastTimeElapsedDouble = (curTimeDouble - oldTimeDouble);
//oldtime = curtime;
//oldTimeDouble = curTimeDouble;
if (conType == ConnectionType.BT && btInputReport[0] != 0x11) if (conType == ConnectionType.BT && btInputReport[0] != 0x11)
{ {