Minor changes to exclusive mode routine

This commit is contained in:
Travis Nickles 2017-08-04 06:10:48 -05:00
parent 22babe9ded
commit 315797fe53

View File

@ -13,6 +13,7 @@ namespace DS4Windows
private static HashSet<string> DevicePaths = new HashSet<string>();
// Keep instance of opened exclusive mode devices not in use (Charging while using BT connection)
private static List<HidDevice> DisabledDevices = new List<HidDevice>();
private static Stopwatch sw = new Stopwatch();
public static bool isExclusiveMode = false;
private static string devicePathToInstanceId(string devicePath)
@ -249,7 +250,6 @@ namespace DS4Windows
public static void reEnableDevice(string deviceInstanceId)
{
Stopwatch sw = new Stopwatch();
bool success;
Guid hidGuid = new Guid();
NativeMethods.HidD_GetHidGuid(ref hidGuid);
@ -285,7 +285,7 @@ namespace DS4Windows
}
//System.Threading.Thread.Sleep(50);
sw.Start();
sw.Restart();
while (sw.ElapsedMilliseconds < 50)
{
// Use SpinWait to keep control of current thread. Using Sleep could potentially
@ -306,15 +306,6 @@ 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);
}
}