mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 11:04:21 +01:00
Fixed issue with an unreleased lock blocking device removal. Fixed chance for duplicate log entries for device removal.
Resolves issue #7.
This commit is contained in:
parent
a2fb603d72
commit
a0cff7ba30
@ -422,10 +422,22 @@ namespace DS4Windows
|
||||
if (DS4Controllers[i] != null && device.MacAddress == DS4Controllers[i].MacAddress)
|
||||
ind = i;
|
||||
if (ind != -1)
|
||||
{
|
||||
bool removingStatus = false;
|
||||
lock (device.removeLocker)
|
||||
{
|
||||
if (!DS4Controllers[ind].IsRemoving)
|
||||
{
|
||||
removingStatus = true;
|
||||
DS4Controllers[ind].IsRemoving = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (removingStatus)
|
||||
{
|
||||
CurrentState[ind].Battery = PreviousState[ind].Battery = 0; // Reset for the next connection's initial status change.
|
||||
x360Bus.Unplug(ind);
|
||||
string removed = Properties.Resources.ControllerWasRemoved.Replace("*Mac address*", (ind +1).ToString());
|
||||
string removed = Properties.Resources.ControllerWasRemoved.Replace("*Mac address*", (ind + 1).ToString());
|
||||
if (DS4Controllers[ind].Battery <= 20 &&
|
||||
DS4Controllers[ind].ConnectionType == ConnectionType.BT && !DS4Controllers[ind].Charging)
|
||||
removed += ". " + Properties.Resources.ChargeController;
|
||||
@ -439,6 +451,7 @@ namespace DS4Windows
|
||||
ControllerStatusChanged(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool[] lag = { false, false, false, false };
|
||||
public bool[] inWarnMonitor = { false, false, false, false };
|
||||
//Called every time the new input report has arrived
|
||||
|
@ -153,6 +153,8 @@ namespace DS4Windows
|
||||
public HidDevice HidDevice => hDevice;
|
||||
public bool IsExclusive => HidDevice.IsExclusive;
|
||||
public bool IsDisconnecting { get; private set; }
|
||||
public bool IsRemoving { get; set; }
|
||||
public object removeLocker = new object();
|
||||
|
||||
public string MacAddress => Mac;
|
||||
|
||||
@ -651,6 +653,7 @@ namespace DS4Windows
|
||||
outputReportBuffer[10] = ledFlashOff; //flash off duration
|
||||
outputReportBuffer[19] = outputReportBuffer[20] = Convert.ToByte(audio.Volume);
|
||||
}
|
||||
bool quitOutputThread = false;
|
||||
lock (outputReport)
|
||||
{
|
||||
if (synchronous)
|
||||
@ -662,7 +665,7 @@ namespace DS4Windows
|
||||
if (!writeOutput())
|
||||
{
|
||||
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> encountered synchronous write failure: " + Marshal.GetLastWin32Error());
|
||||
StopOutputUpdate();
|
||||
quitOutputThread = true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
@ -683,6 +686,11 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (quitOutputThread)
|
||||
{
|
||||
StopOutputUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public bool DisconnectBT()
|
||||
|
Loading…
Reference in New Issue
Block a user