From f042120edee7b8bc15e72b571e9fa29cef30d63b Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 1 Aug 2017 02:42:16 -0500 Subject: [PATCH] Add wait period after device is enabled. Seems to be needed for exclusive mode to behave better with recent Windows 10 update --- DS4Windows/DS4Library/DS4Devices.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index ba7b2fc..c478df7 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -284,6 +284,7 @@ namespace DS4Windows throw new Exception("Error disabling device, error code = " + Marshal.GetLastWin32Error()); } + //System.Threading.Thread.Sleep(50); sw.Start(); while (sw.ElapsedMilliseconds < 50) { @@ -305,6 +306,15 @@ namespace DS4Windows throw new Exception("Error enabling device, error code = " + Marshal.GetLastWin32Error()); } + //System.Threading.Thread.Sleep(10); + sw.Restart(); + while (sw.ElapsedMilliseconds < 10) + { + // Use SpinWait to keep control of current thread. Using Sleep could potentially + // cause other events to get run out of order + System.Threading.Thread.SpinWait(20); + } + sw.Stop(); NativeMethods.SetupDiDestroyDeviceInfoList(deviceInfoSet); } }