Added reference check while unplugging virtual device

This commit is contained in:
Travis Nickles 2020-04-05 15:22:08 -05:00
parent 87bba30914
commit 21d65e01e9

View File

@ -487,15 +487,19 @@ namespace DS4Windows
if (!useDInputOnly[index]) if (!useDInputOnly[index])
{ {
//OutContType contType = Global.OutContType[index]; //OutContType contType = Global.OutContType[index];
string tempType = outputDevices[index].GetDeviceType();
LogDebug("Unplugging " + tempType + " Controller for input #" + (index + 1), false);
OutputDevice dev = outputDevices[index]; OutputDevice dev = outputDevices[index];
outputDevices[index] = null; if (dev != null)
activeOutDevType[index] = OutContType.None; {
outputslotMan.DeferredRemoval(dev, index, outputDevices, immediate); string tempType = dev.GetDeviceType();
//dev.Disconnect(); LogDebug("Unplugging " + tempType + " Controller for input #" + (index + 1), false);
//LogDebug(tempType + " Controller # " + (index + 1) + " unplugged");
useDInputOnly[index] = true; outputDevices[index] = null;
activeOutDevType[index] = OutContType.None;
outputslotMan.DeferredRemoval(dev, index, outputDevices, immediate);
//dev.Disconnect();
//LogDebug(tempType + " Controller # " + (index + 1) + " unplugged");
useDInputOnly[index] = true;
}
} }
} }