Save config upon controller unplug

Used to assist with persisting linked profile setting
This commit is contained in:
Travis Nickles 2020-01-16 07:15:18 -06:00
parent 2b7234873e
commit 164fbd5154
2 changed files with 15 additions and 3 deletions

View File

@ -1284,7 +1284,6 @@ namespace DS4Windows
inWarnMonitor[ind] = false; inWarnMonitor[ind] = false;
useDInputOnly[ind] = true; useDInputOnly[ind] = true;
Global.activeOutDevType[ind] = OutContType.None; Global.activeOutDevType[ind] = OutContType.None;
Global.linkedProfileCheck[ind] = false;
/*uiContext?.Post(new SendOrPostCallback((state) => /*uiContext?.Post(new SendOrPostCallback((state) =>
{ {
OnControllerRemoved(this, ind); OnControllerRemoved(this, ind);

View File

@ -152,17 +152,30 @@ namespace DS4WinWPF.DS4Forms.ViewModels
private void Controller_Removal(object sender, EventArgs e) private void Controller_Removal(object sender, EventArgs e)
{ {
DS4Device currentDev = sender as DS4Device; DS4Device currentDev = sender as DS4Device;
CompositeDeviceModel found = null;
_colListLocker.EnterReadLock(); _colListLocker.EnterReadLock();
foreach (CompositeDeviceModel temp in controllerCol) foreach (CompositeDeviceModel temp in controllerCol)
{ {
if (temp.Device == currentDev) if (temp.Device == currentDev)
{ {
controllerCol.Remove(temp); found = temp;
controllerDict.Remove(temp.DevIndex);
break; break;
} }
} }
_colListLocker.ExitReadLock(); _colListLocker.ExitReadLock();
if (found != null)
{
_colListLocker.EnterWriteLock();
controllerCol.Remove(found);
controllerDict.Remove(found.DevIndex);
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
Global.Save();
});
Global.linkedProfileCheck[found.DevIndex] = false;
_colListLocker.ExitWriteLock();
}
} }
} }