From 19afe159375ce40d232555e263905f7d97da01b5 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Thu, 22 Jun 2017 22:14:58 -0700 Subject: [PATCH] Make lastActive field matter for USB connections again. Related to issue #45. --- DS4Windows/DS4Library/DS4Device.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 820a520..87dc9d7 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -876,26 +876,32 @@ namespace DS4Windows } } - bool ds4Idle = cState.FrameCounter == pState.FrameCounter; - if (!ds4Idle) + bool ds4ActiveFrame = cState.FrameCounter == pState.FrameCounter; + if (!ds4ActiveFrame) { isRemoved = false; } if (conType == ConnectionType.USB) { - lastActive = utcNow; + if (idleTimeout == 0) + { + lastActive = utcNow; + } + else if (!isDS4Idle()) + { + lastActive = utcNow; + } } else { bool shouldDisconnect = false; - int idleTime = idleTimeout; - if (!isRemoved && idleTime > 0) + if (!isRemoved && idleTimeout > 0) { bool idleInput = isDS4Idle(); if (idleInput) { - DateTime timeout = lastActive + TimeSpan.FromSeconds(idleTime); + DateTime timeout = lastActive + TimeSpan.FromSeconds(idleTimeout); if (!charging) shouldDisconnect = utcNow >= timeout; }