Make lastActive field matter for USB connections again. Related to issue #45.

This commit is contained in:
Travis Nickles 2017-06-22 22:14:58 -07:00
parent 9f554cf6c1
commit 19afe15937

View File

@ -876,26 +876,32 @@ namespace DS4Windows
} }
} }
bool ds4Idle = cState.FrameCounter == pState.FrameCounter; bool ds4ActiveFrame = cState.FrameCounter == pState.FrameCounter;
if (!ds4Idle) if (!ds4ActiveFrame)
{ {
isRemoved = false; isRemoved = false;
} }
if (conType == ConnectionType.USB) if (conType == ConnectionType.USB)
{
if (idleTimeout == 0)
{ {
lastActive = utcNow; lastActive = utcNow;
} }
else if (!isDS4Idle())
{
lastActive = utcNow;
}
}
else else
{ {
bool shouldDisconnect = false; bool shouldDisconnect = false;
int idleTime = idleTimeout; if (!isRemoved && idleTimeout > 0)
if (!isRemoved && idleTime > 0)
{ {
bool idleInput = isDS4Idle(); bool idleInput = isDS4Idle();
if (idleInput) if (idleInput)
{ {
DateTime timeout = lastActive + TimeSpan.FromSeconds(idleTime); DateTime timeout = lastActive + TimeSpan.FromSeconds(idleTimeout);
if (!charging) if (!charging)
shouldDisconnect = utcNow >= timeout; shouldDisconnect = utcNow >= timeout;
} }