From 3e4a5c05628bd3d92d0834a394ada6029db3e57d Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sat, 22 Apr 2017 07:49:01 -0700 Subject: [PATCH] Fixes for Quick Charge mode Resolves issue #19. --- DS4Windows/DS4Control/ControlSerivce.cs | 10 +++++++++- DS4Windows/DS4Control/Mapping.cs | 2 +- DS4Windows/DS4Forms/DS4Form.cs | 5 ----- DS4Windows/DS4Library/DS4Device.cs | 15 ++++++++++++--- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/DS4Windows/DS4Control/ControlSerivce.cs b/DS4Windows/DS4Control/ControlSerivce.cs index 5aa99b4..7329ff2 100644 --- a/DS4Windows/DS4Control/ControlSerivce.cs +++ b/DS4Windows/DS4Control/ControlSerivce.cs @@ -216,7 +216,7 @@ namespace DS4Windows if (showlog) LogDebug(Properties.Resources.StoppedDS4Windows); - ControllerStatusChanged(this); + ControllerStatusChanged(this); } return true; } @@ -231,6 +231,13 @@ namespace DS4Windows for (int i = 0, devlen = devices.Count(); i < devlen; i++) { DS4Device device = devices.ElementAt(i); + + if (QuickCharge && device?.getConnectionType() == ConnectionType.BT && (bool)device?.isCharging()) + { + device.DisconnectBT(); + continue; + } + if (device.isDisconnectingStatus()) continue; @@ -278,6 +285,7 @@ namespace DS4Windows } } } + return true; } diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index f90dcf3..be2a8f5 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -1572,7 +1572,7 @@ namespace DS4Windows ConnectionType deviceConn = d.getConnectionType(); if (deviceConn == ConnectionType.BT) { - d.DisconnectBT(); + d.DisconnectBT(false); } //foreach (DS4Controls dc in action.trigger) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 5281984..d376581 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -877,11 +877,6 @@ namespace DS4Windows { Pads[Index].Text = Program.rootHub.getDS4MacAddress(Index); DS4Device d = Program.rootHub.DS4Controllers[Index]; - if (QuickCharge && d?.getConnectionType() == ConnectionType.BT && (bool)d?.isCharging()) - { - d.DisconnectBT(); - return; - } switch (Program.rootHub.getDS4Status(Index)) { diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 650799f..a2ff7c7 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -410,6 +410,7 @@ namespace DS4Windows Console.WriteLine(e.Message); } } + StopOutputUpdate(); } @@ -705,7 +706,7 @@ namespace DS4Windows { if (conType == ConnectionType.BT) { - if (DisconnectBT()) + if (DisconnectBT(false)) return; // all done } else if (conType == ConnectionType.SONYWA) @@ -814,7 +815,7 @@ namespace DS4Windows } } - public bool DisconnectBT() + public bool DisconnectBT(bool allThreadsQuit = true) { if (Mac != null) { @@ -851,7 +852,15 @@ namespace DS4Windows if(success) { IsDisconnecting = true; - StopOutputUpdate(); + if (allThreadsQuit) + { + StopUpdate(); + } + else + { + StopOutputUpdate(); + } + if (Removal != null) Removal(this, EventArgs.Empty); }