From 328b2dc14c73d4d2e9dbba1390605cbfcebb3345 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 19 Jun 2017 08:50:28 -0700 Subject: [PATCH] Attempt to smooth out mouse cursor for analog sticks --- DS4Windows/DS4Control/Mapping.cs | 3 ++- DS4Windows/DS4Library/DS4Device.cs | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index f999c87..3e568a3 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -2322,7 +2322,8 @@ namespace DS4Windows int controlNum = (int)control; DS4StateFieldMapping.ControlType controlType = DS4StateFieldMapping.mappedType[controlNum]; - long timeElapsed = ctrl.DS4Controllers[device].getLastTimeElapsed(); + //long timeElapsed = ctrl.DS4Controllers[device].getLastTimeElapsed(); + double timeElapsed = ctrl.DS4Controllers[device].lastTimeElapsedDouble; //double mouseOffset = 0.025; double tempMouseOffsetX = 0.0, tempMouseOffsetY = 0.0; diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index e38a64b..760a46b 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -264,6 +264,12 @@ namespace DS4Windows return lastTimeElapsed; } + public double lastTimeElapsedDouble = 0.0; + public double getLastTimeElapsedDouble() + { + return lastTimeElapsedDouble; + } + public byte RightLightFastRumble { get { return rightLightFastRumble; } @@ -630,10 +636,12 @@ namespace DS4Windows return synced; } - public double Latency = 0; + public double Latency = 0.0; public string error; public bool firstReport = false; public bool oldCharging = false; + double curTimeDouble = 0.0; + double oldTimeDouble = 0.0; private void performDs4Input() { @@ -656,12 +664,15 @@ namespace DS4Windows { oldCharging = charging; currerror = string.Empty; + curTimeDouble = sw.Elapsed.TotalMilliseconds; curtime = sw.ElapsedMilliseconds; - this.lastTimeElapsed = curtime - oldtime; + lastTimeElapsed = curtime - oldtime; + lastTimeElapsedDouble = (curTimeDouble - oldTimeDouble); //latencyList.Add(this.lastTimeElapsed); latencyQueue.Enqueue(this.lastTimeElapsed); tempLatencyCount++; oldtime = curtime; + oldTimeDouble = curTimeDouble; if (tempLatencyCount > 50) {