Fixes for Quick Charge mode

Resolves issue #19.
This commit is contained in:
Travis Nickles 2017-04-22 07:49:01 -07:00
parent ecb271cfb1
commit 3e4a5c0562
4 changed files with 22 additions and 10 deletions

View File

@ -216,7 +216,7 @@ namespace DS4Windows
if (showlog) if (showlog)
LogDebug(Properties.Resources.StoppedDS4Windows); LogDebug(Properties.Resources.StoppedDS4Windows);
ControllerStatusChanged(this); ControllerStatusChanged(this);
} }
return true; return true;
} }
@ -231,6 +231,13 @@ namespace DS4Windows
for (int i = 0, devlen = devices.Count(); i < devlen; i++) for (int i = 0, devlen = devices.Count(); i < devlen; i++)
{ {
DS4Device device = devices.ElementAt<DS4Device>(i); DS4Device device = devices.ElementAt<DS4Device>(i);
if (QuickCharge && device?.getConnectionType() == ConnectionType.BT && (bool)device?.isCharging())
{
device.DisconnectBT();
continue;
}
if (device.isDisconnectingStatus()) if (device.isDisconnectingStatus())
continue; continue;
@ -278,6 +285,7 @@ namespace DS4Windows
} }
} }
} }
return true; return true;
} }

View File

@ -1572,7 +1572,7 @@ namespace DS4Windows
ConnectionType deviceConn = d.getConnectionType(); ConnectionType deviceConn = d.getConnectionType();
if (deviceConn == ConnectionType.BT) if (deviceConn == ConnectionType.BT)
{ {
d.DisconnectBT(); d.DisconnectBT(false);
} }
//foreach (DS4Controls dc in action.trigger) //foreach (DS4Controls dc in action.trigger)

View File

@ -877,11 +877,6 @@ namespace DS4Windows
{ {
Pads[Index].Text = Program.rootHub.getDS4MacAddress(Index); Pads[Index].Text = Program.rootHub.getDS4MacAddress(Index);
DS4Device d = Program.rootHub.DS4Controllers[Index]; DS4Device d = Program.rootHub.DS4Controllers[Index];
if (QuickCharge && d?.getConnectionType() == ConnectionType.BT && (bool)d?.isCharging())
{
d.DisconnectBT();
return;
}
switch (Program.rootHub.getDS4Status(Index)) switch (Program.rootHub.getDS4Status(Index))
{ {

View File

@ -410,6 +410,7 @@ namespace DS4Windows
Console.WriteLine(e.Message); Console.WriteLine(e.Message);
} }
} }
StopOutputUpdate(); StopOutputUpdate();
} }
@ -705,7 +706,7 @@ namespace DS4Windows
{ {
if (conType == ConnectionType.BT) if (conType == ConnectionType.BT)
{ {
if (DisconnectBT()) if (DisconnectBT(false))
return; // all done return; // all done
} }
else if (conType == ConnectionType.SONYWA) else if (conType == ConnectionType.SONYWA)
@ -814,7 +815,7 @@ namespace DS4Windows
} }
} }
public bool DisconnectBT() public bool DisconnectBT(bool allThreadsQuit = true)
{ {
if (Mac != null) if (Mac != null)
{ {
@ -851,7 +852,15 @@ namespace DS4Windows
if(success) if(success)
{ {
IsDisconnecting = true; IsDisconnecting = true;
StopOutputUpdate(); if (allThreadsQuit)
{
StopUpdate();
}
else
{
StopOutputUpdate();
}
if (Removal != null) if (Removal != null)
Removal(this, EventArgs.Empty); Removal(this, EventArgs.Empty);
} }