Move Quick Charge check to input thread

This commit is contained in:
Travis Nickles 2017-06-09 23:45:19 -07:00
parent e1efb2bb5b
commit ab9c3abe05
2 changed files with 19 additions and 3 deletions

View File

@ -276,7 +276,7 @@ namespace DS4Windows
{ {
// Do first run check for Quick Charge checks. Needed so old device will // Do first run check for Quick Charge checks. Needed so old device will
// be removed before performing another controller scan // be removed before performing another controller scan
if (getQuickCharge()) /*if (getQuickCharge())
{ {
for (int i = 0, devlen = DS4Controllers.Length; i < devlen; i++) for (int i = 0, devlen = DS4Controllers.Length; i < devlen; i++)
{ {
@ -291,6 +291,7 @@ namespace DS4Windows
} }
} }
} }
*/
DS4Devices.findControllers(); DS4Devices.findControllers();
IEnumerable<DS4Device> devices = DS4Devices.getDS4Controllers(); IEnumerable<DS4Device> devices = DS4Devices.getDS4Controllers();

View File

@ -639,6 +639,8 @@ namespace DS4Windows
Queue<long> latencyQueue = new Queue<long>(51); // Set capacity at max + 1 to avoid any resizing Queue<long> latencyQueue = new Queue<long>(51); // Set capacity at max + 1 to avoid any resizing
int tempLatencyCount = 0; int tempLatencyCount = 0;
long oldtime = 0; long oldtime = 0;
string currerror = string.Empty;
long curtime = 0;
Stopwatch sw = new Stopwatch(); Stopwatch sw = new Stopwatch();
sw.Start(); sw.Start();
timeoutEvent = false; timeoutEvent = false;
@ -646,8 +648,8 @@ namespace DS4Windows
while (!exitInputThread) while (!exitInputThread)
{ {
oldCharging = charging; oldCharging = charging;
string currerror = string.Empty; currerror = string.Empty;
long curtime = sw.ElapsedMilliseconds; curtime = sw.ElapsedMilliseconds;
this.lastTimeElapsed = curtime - oldtime; this.lastTimeElapsed = curtime - oldtime;
//latencyList.Add(this.lastTimeElapsed); //latencyList.Add(this.lastTimeElapsed);
latencyQueue.Enqueue(this.lastTimeElapsed); latencyQueue.Enqueue(this.lastTimeElapsed);
@ -888,8 +890,11 @@ namespace DS4Windows
if (conType == ConnectionType.BT) if (conType == ConnectionType.BT)
{ {
if (DisconnectBT(true)) if (DisconnectBT(true))
{
timeoutExecuted = true;
return; // all done return; // all done
} }
}
else if (conType == ConnectionType.SONYWA) else if (conType == ConnectionType.SONYWA)
{ {
DisconnectDongle(); DisconnectDongle();
@ -897,6 +902,16 @@ namespace DS4Windows
} }
} }
if (oldCharging != charging && conType == ConnectionType.BT)
{
if (Global.getQuickCharge() && charging)
{
DisconnectBT(true);
timeoutExecuted = true;
return;
}
}
if (Report != null) if (Report != null)
Report(this, EventArgs.Empty); Report(this, EventArgs.Empty);