From 49d24fce7d5ad82fbacb662f7bd66652e98c4f7f Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 26 Oct 2018 20:58:43 -0500 Subject: [PATCH] Testing new output report copying thread for USB and SONYWA --- DS4Windows/DS4Library/DS4Device.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 0e62794..f8732c8 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -539,6 +539,14 @@ namespace DS4Windows timeoutCheckThread.IsBackground = true; timeoutCheckThread.Start(); } + else + { + ds4Output = new Thread(OutReportCopy); + ds4Output.Priority = ThreadPriority.AboveNormal; + ds4Output.Name = "DS4 Arr Copy thread: " + Mac; + ds4Output.IsBackground = true; + ds4Output.Start(); + } ds4Input = new Thread(performDs4Input); ds4Input.Priority = ThreadPriority.AboveNormal; @@ -1203,6 +1211,10 @@ namespace DS4Windows { Monitor.Exit(outputReport); } + else + { + Monitor.Pulse(outReportBuffer); + } } } else @@ -1229,6 +1241,22 @@ namespace DS4Windows } } + public void OutReportCopy() + { + try + { + while (!exitOutputThread) + { + lock (outReportBuffer) + { + outReportBuffer.CopyTo(outputReport, 0); + Monitor.Wait(outReportBuffer); + } + } + } + catch (ThreadInterruptedException) { } + } + public bool DisconnectBT(bool callRemoval = false) { if (Mac != null)