Make sure controller reading can be started when switching auto profiles

Related to issue #325.
This commit is contained in:
Travis Nickles 2018-06-19 00:04:30 -05:00
parent 600818a3c0
commit e0d7f1ed14

View File

@ -449,7 +449,8 @@ namespace DS4Windows
{ {
if (Index < ControlService.DS4_CONTROLLER_COUNT) if (Index < ControlService.DS4_CONTROLLER_COUNT)
{ {
statPB[Index].Visible = false; toolTip1.SetToolTip(statPB[Index], ""); statPB[Index].Visible = false;
toolTip1.SetToolTip(statPB[Index], "");
Batteries[Index].Text = Properties.Resources.NA; Batteries[Index].Text = Properties.Resources.NA;
Pads[Index].Text = Properties.Resources.Disconnected; Pads[Index].Text = Properties.Resources.Disconnected;
Enable_Controls(Index, false); Enable_Controls(Index, false);
@ -594,10 +595,24 @@ namespace DS4Windows
turnOffTemp = true; turnOffTemp = true;
if (btnStartStop.Text == Properties.Resources.StopText) if (btnStartStop.Text == Properties.Resources.StopText)
{ {
BtnStartStop_Clicked(); autoProfilesTimer.Stop();
hotkeysTimer.Start(); hotkeysTimer.Stop();
autoProfilesTimer.Start();
btnStartStop.Text = Properties.Resources.StartText; this.Invoke((System.Action)(() => {
this.changingService = true;
BtnStartStop_Clicked();
}));
while (this.changingService)
{
Thread.SpinWait(500);
}
this.Invoke((System.Action)(() =>
{
hotkeysTimer.Start();
autoProfilesTimer.Start();
}));
} }
} }
@ -620,8 +635,10 @@ namespace DS4Windows
turnOffTemp = false; turnOffTemp = false;
if (btnStartStop.Text == Properties.Resources.StartText) if (btnStartStop.Text == Properties.Resources.StartText)
{ {
BtnStartStop_Clicked(); this.BeginInvoke((System.Action)(() =>
btnStartStop.Text = Properties.Resources.StopText; {
BtnStartStop_Clicked();
}));
} }
} }
} }