diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index e356f52..fd4b2f8 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -191,6 +191,8 @@ namespace DS4Windows if (showlog) LogDebug(Properties.Resources.StoppingX360); + LogDebug("Closing connection to Scp Virtual Bus"); + bool anyUnplugged = false; for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++) { diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index eb8144d..db435cf 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -57,6 +57,8 @@ namespace DS4Windows string logFile = appdatapath + @"\DS4Service.log"; bool turnOffTemp; bool runningBat; + private bool changingService; + public bool ChangingService => changingService; Dictionary hoverTextDict = new Dictionary(); // 0 index is used for application version text. 1 - 4 indices are used for controller status string[] notifyText = new string[5] @@ -943,11 +945,13 @@ namespace DS4Windows private void serviceStartup(bool log) { var uiContext = SynchronizationContext.Current; + changingService = true; TaskRunner.Run(() => { //Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; Program.rootHub.Start(uiContext, log); Invoke((System.Action)(() => { serviceStartupFinish(); })); + changingService = false; }); } @@ -968,10 +972,12 @@ namespace DS4Windows private void serviceShutdown(bool log) { + changingService = true; TaskRunner.Run(() => { Program.rootHub.Stop(log); Invoke((System.Action)(() => { serviceShutdownFinish(); })); + changingService = false; }); } diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index b08a595..b385f99 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -1604,7 +1604,7 @@ namespace DS4Windows if (olddinputcheck != cBDinput.Checked) { root.btnStartStop_Clicked(false); - root.btnStartStop_Clicked(false); + finishDInputChange(); } if (btnRumbleHeavyTest.Text == Properties.Resources.StopText) @@ -2128,10 +2128,23 @@ namespace DS4Windows if (!loading && device < 4) { root.btnStartStop_Clicked(false); - root.btnStartStop_Clicked(false); + finishDInputChange(); } } + private async void finishDInputChange() + { + await System.Threading.Tasks.Task.Factory.StartNew(() => + { + while (root.ChangingService) + { + System.Threading.Thread.Sleep(10); + } + }); + + root.btnStartStop_Clicked(false); + } + private void cbStartTouchpadOff_CheckedChanged(object sender, EventArgs e) { StartTouchpadOff[device] = cbStartTouchpadOff.Checked;