Skip to content

Commit

Permalink
Check for device removal status before adding device to main view list
Browse files Browse the repository at this point in the history
Fixes initial Switch Pro disconnect on hotplug
  • Loading branch information
Ryochan7 committed Aug 15, 2021
1 parent 5f0920c commit a72d9cb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions DS4Windows/DS4Forms/ViewModels/ControllerListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ private void Service_HotplugController(ControlService sender,
// Engage write lock pre-maturely
using (WriteLocker readLock = new WriteLocker(_colListLocker))
{
if (!controllerDict.ContainsKey(index))
// Look if device exists. Also, check if disconnect might be occurring
if (!controllerDict.ContainsKey(index) && !device.IsRemoving)
{
CompositeDeviceModel temp = new CompositeDeviceModel(device,
index, Global.ProfilePath[index], profileListHolder);
Expand Down Expand Up @@ -136,8 +137,8 @@ private void ControllersChanged(object sender, EventArgs e)
}
_colListLocker.ExitReadLock();


if (!found)
// Check for new device. Also, check if disconnect might be occurring
if (!found && !currentDev.IsRemoving)
{
//int idx = controllerCol.Count;
_colListLocker.EnterWriteLock();
Expand Down

0 comments on commit a72d9cb

Please sign in to comment.