Use suspending flag rather than using a parameter

This commit is contained in:
Travis Nickles 2018-02-26 03:51:24 -06:00
parent 0ebfa8b96e
commit 01e5246c61
2 changed files with 10 additions and 7 deletions

View File

@ -37,6 +37,7 @@ namespace DS4Windows
@"HID\{00001124-0000-1000-8000-00805f9b34fb}_VID&0002054c_PID&05c4", @"HID\{00001124-0000-1000-8000-00805f9b34fb}_VID&0002054c_PID&05c4",
@"HID\{00001124-0000-1000-8000-00805f9b34fb}_VID&0002054c_PID&09cc", @"HID\{00001124-0000-1000-8000-00805f9b34fb}_VID&0002054c_PID&09cc",
}; };
public bool suspending;
//SoundPlayer sp = new SoundPlayer(); //SoundPlayer sp = new SoundPlayer();
private class X360Data private class X360Data
@ -214,7 +215,7 @@ namespace DS4Windows
return true; return true;
} }
public bool Stop(bool showlog = true, bool suspend = false) public bool Stop(bool showlog = true)
{ {
if (running) if (running)
{ {
@ -232,7 +233,7 @@ namespace DS4Windows
DS4Device tempDevice = DS4Controllers[i]; DS4Device tempDevice = DS4Controllers[i];
if (tempDevice != null) if (tempDevice != null)
{ {
if ((DCBTatStop && !tempDevice.isCharging()) || suspend) if ((DCBTatStop && !tempDevice.isCharging()) || suspending)
{ {
if (tempDevice.getConnectionType() == ConnectionType.BT) if (tempDevice.getConnectionType() == ConnectionType.BT)
{ {

View File

@ -507,6 +507,7 @@ namespace DS4Windows
{ {
DS4LightBar.shuttingdown = false; DS4LightBar.shuttingdown = false;
wasrunning = false; wasrunning = false;
Program.rootHub.suspending = false;
BtnStartStop_Clicked(); BtnStartStop_Clicked();
} }
break; break;
@ -516,7 +517,8 @@ namespace DS4Windows
if (btnStartStop.Text == Properties.Resources.StopText) if (btnStartStop.Text == Properties.Resources.StopText)
{ {
DS4LightBar.shuttingdown = true; DS4LightBar.shuttingdown = true;
BtnStartStop_Clicked(true, true); Program.rootHub.suspending = true;
BtnStartStop_Clicked();
wasrunning = true; wasrunning = true;
} }
break; break;
@ -919,12 +921,12 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
startToolStripMenuItem.Text = btnStartStop.Text = Properties.Resources.StopText; startToolStripMenuItem.Text = btnStartStop.Text = Properties.Resources.StopText;
} }
private void ServiceShutdown(bool log, bool suspend = false) private void ServiceShutdown(bool log)
{ {
changingService = true; changingService = true;
TaskRunner.Run(() => TaskRunner.Run(() =>
{ {
Program.rootHub.Stop(log, suspend); Program.rootHub.Stop(log);
Invoke((System.Action)(() => { ServiceShutdownFinish(); })); Invoke((System.Action)(() => { ServiceShutdownFinish(); }));
changingService = false; changingService = false;
}); });
@ -939,7 +941,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
populateFullNotifyText(); populateFullNotifyText();
} }
public void BtnStartStop_Clicked(bool log = true, bool suspend = false) public void BtnStartStop_Clicked(bool log = true)
{ {
if (btnStartStop.Text == Properties.Resources.StartText) if (btnStartStop.Text == Properties.Resources.StartText)
{ {
@ -948,7 +950,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
else if (btnStartStop.Text == Properties.Resources.StopText) else if (btnStartStop.Text == Properties.Resources.StopText)
{ {
blankControllerTab(); blankControllerTab();
ServiceShutdown(log, suspend); ServiceShutdown(log);
} }
} }