From dedb1c9ad97d9b2980b3277667f024aff8175286 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 16 Nov 2018 05:24:47 -0600 Subject: [PATCH] Manually calculate device latency average --- DS4Windows/DS4Library/DS4Device.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 69e7fd8..aba9179 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -741,6 +741,7 @@ namespace DS4Windows CRC32_POS_3 = BT_INPUT_REPORT_CRC32_POS + 3; int crcpos = BT_INPUT_REPORT_CRC32_POS; int crcoffset = 0; + long latencySum = 0; while (!exitInputThread) { @@ -749,14 +750,16 @@ namespace DS4Windows if (tempLatencyCount >= 20) { - latencyQueue.Dequeue(); + latencySum -= latencyQueue.Dequeue(); tempLatencyCount--; } + latencySum += this.lastTimeElapsed; latencyQueue.Enqueue(this.lastTimeElapsed); tempLatencyCount++; - Latency = latencyQueue.Average(); + //Latency = latencyQueue.Average(); + Latency = latencySum / tempLatencyCount; if (conType == ConnectionType.BT) {