Explicitly close HID device when stopping service

Do not wait for runtime to close the HID device
This commit is contained in:
Travis Nickles 2018-02-21 12:46:08 -06:00
parent 2dd9cb78a1
commit fece01e9e5
2 changed files with 7 additions and 1 deletions

View File

@ -253,6 +253,7 @@ namespace DS4Windows
DS4LightBar.updateLightBar(DS4Controllers[i], i);
tempDevice.IsRemoved = true;
tempDevice.StopUpdate();
DS4Devices.RemoveDevice(tempDevice);
Thread.Sleep(50);
}

View File

@ -186,10 +186,15 @@ namespace DS4Windows
// Called when devices is diconnected, timed out or has input reading failure
public static void On_Removal(object sender, EventArgs e)
{
DS4Device device = (DS4Device)sender;
RemoveDevice(device);
}
public static void RemoveDevice(DS4Device device)
{
lock (Devices)
{
DS4Device device = (DS4Device)sender;
if (device != null)
{
device.HidDevice.CloseDevice();