Only attempt device removal on exit when using Sony dongle

This commit is contained in:
Travis Nickles 2017-04-06 08:30:41 -07:00
parent 51cbe22a90
commit a65dfa0624
2 changed files with 5 additions and 3 deletions

View File

@ -180,7 +180,7 @@ namespace DS4Windows
}
else if (DS4Controllers[i].ConnectionType == ConnectionType.SONYWA)
{
DS4Controllers[i].DisconnectDongle();
DS4Controllers[i].DisconnectDongle(true);
}
}
else

View File

@ -498,6 +498,7 @@ namespace DS4Windows
else
{
//HidDevice.ReadStatus res = hDevice.ReadFile(inputReport);
//Array.Clear(inputReport, 0, inputReport.Length);
HidDevice.ReadStatus res = hDevice.ReadAsyncWithFileStream(inputReport, READ_STREAM_TIMEOUT);
readTimeout.Enabled = false;
if (res != HidDevice.ReadStatus.Success)
@ -759,7 +760,7 @@ namespace DS4Windows
return false;
}
public bool DisconnectDongle()
public bool DisconnectDongle(bool remove=false)
{
bool result = false;
byte[] disconnectReport = new byte[65];
@ -767,8 +768,9 @@ namespace DS4Windows
disconnectReport[1] = 0x02;
for (int i = 2; i < 65; i++)
disconnectReport[i] = 0;
result = hDevice.WriteFeatureReport(disconnectReport);
if (result)
if (result && remove)
{
IsDisconnecting = true;
StopOutputUpdate();