Added extra delay for ViGEm stop

This commit is contained in:
Travis Nickles 2020-03-29 22:11:42 -05:00
parent 1fd423b663
commit 71ceae1e0c
2 changed files with 8 additions and 1 deletions

View File

@ -718,6 +718,7 @@ namespace DS4Windows
LogDebug("Closing connection to ViGEmBus"); LogDebug("Closing connection to ViGEmBus");
bool anyUnplugged = false;
for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++) for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++)
{ {
DS4Device tempDevice = DS4Controllers[i]; DS4Device tempDevice = DS4Controllers[i];
@ -757,6 +758,7 @@ namespace DS4Windows
if (tempout != null) if (tempout != null)
{ {
UnplugOutDev(i, tempDevice, true); UnplugOutDev(i, tempDevice, true);
anyUnplugged = true;
} }
//outputDevices[i] = null; //outputDevices[i] = null;
@ -787,6 +789,11 @@ namespace DS4Windows
Thread.SpinWait(500); Thread.SpinWait(500);
} }
if (anyUnplugged)
{
Thread.Sleep(OutputSlotManager.DELAY_TIME);
}
stopViGEm(); stopViGEm();
} }

View File

@ -9,7 +9,7 @@ namespace DS4Windows
{ {
public class OutputSlotManager public class OutputSlotManager
{ {
private const int DELAY_TIME = 500; // measured in ms public const int DELAY_TIME = 500; // measured in ms
private Dictionary<int, OutputDevice> deviceDict = new Dictionary<int, OutputDevice>(); private Dictionary<int, OutputDevice> deviceDict = new Dictionary<int, OutputDevice>();
private Dictionary<OutputDevice, int> revDeviceDict = new Dictionary<OutputDevice, int>(); private Dictionary<OutputDevice, int> revDeviceDict = new Dictionary<OutputDevice, int>();