From 164fbd5154c167e70369f04c832d8cf29236195a Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Thu, 16 Jan 2020 07:15:18 -0600 Subject: [PATCH] Save config upon controller unplug Used to assist with persisting linked profile setting --- DS4Windows/DS4Control/ControlService.cs | 1 - .../ViewModels/ControllerListViewModel.cs | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index ca00e70..f5758df 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -1284,7 +1284,6 @@ namespace DS4Windows inWarnMonitor[ind] = false; useDInputOnly[ind] = true; Global.activeOutDevType[ind] = OutContType.None; - Global.linkedProfileCheck[ind] = false; /*uiContext?.Post(new SendOrPostCallback((state) => { OnControllerRemoved(this, ind); diff --git a/DS4Windows/DS4Forms/ViewModels/ControllerListViewModel.cs b/DS4Windows/DS4Forms/ViewModels/ControllerListViewModel.cs index b6a3368..350b207 100644 --- a/DS4Windows/DS4Forms/ViewModels/ControllerListViewModel.cs +++ b/DS4Windows/DS4Forms/ViewModels/ControllerListViewModel.cs @@ -152,17 +152,30 @@ namespace DS4WinWPF.DS4Forms.ViewModels private void Controller_Removal(object sender, EventArgs e) { DS4Device currentDev = sender as DS4Device; + CompositeDeviceModel found = null; _colListLocker.EnterReadLock(); foreach (CompositeDeviceModel temp in controllerCol) { if (temp.Device == currentDev) { - controllerCol.Remove(temp); - controllerDict.Remove(temp.DevIndex); + found = temp; break; } } _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(); + } } }