Do not restart service when changing dinput option in profile

Only plug or unplug an xinput device as needed. Only perform
when saving a profile.
This commit is contained in:
Travis Nickles 2018-03-21 17:31:22 -05:00
parent d91f696b66
commit 18bb83ceef
3 changed files with 38 additions and 8 deletions

View File

@ -101,6 +101,27 @@ namespace DS4Windows
catch { }
}
public bool PlugXInputController(int index)
{
int xinputIndex = x360Bus.FirstController + index;
LogDebug("Plugging in X360 Controller #" + xinputIndex);
bool xinputResult = x360Bus.Plugin(index);
useDInputOnly[index] = false;
LogDebug("X360 Controller # " + xinputIndex + " connected");
return xinputResult;
}
public bool UnplugXInputController(int index)
{
bool unplugResult = x360Bus.Unplug(index);
int xinputIndex = x360Bus.FirstController + index;
useDInputOnly[index] = true;
LogDebug("X360 Controller # " + xinputIndex + " unplugged");
return unplugResult;
}
public bool Start(object tempui, bool showlog = true)
{
if (x360Bus.Open() && x360Bus.Start())

View File

@ -1366,7 +1366,7 @@
resources.ApplyResources(this.cBDinput, "cBDinput");
this.cBDinput.Name = "cBDinput";
this.cBDinput.UseVisualStyleBackColor = true;
this.cBDinput.CheckedChanged += new System.EventHandler(this.cBDinput_CheckedChanged);
this.cBDinput.CheckedChanged += new System.EventHandler(this.CBDinput_CheckedChanged);
//
// pBProgram
//

View File

@ -1637,11 +1637,12 @@ namespace DS4Windows
for (int i = 0; i < 4; i++)
LoadProfile(i, false, Program.rootHub); // Refreshes all profiles in case other controllers are using the same profile
if (olddinputcheck != cBDinput.Checked)
/*if (olddinputcheck != cBDinput.Checked)
{
root.BtnStartStop_Clicked(false);
finishDInputChange();
}
*/
if (btnRumbleHeavyTest.Text == Properties.Resources.StopText)
Program.rootHub.setRumble(0, 0, (int)nUDSixaxis.Value - 1);
@ -1655,6 +1656,7 @@ namespace DS4Windows
{
int discon = getIdleDisconnectTimeout(device);
int btCurrentIndex = btPollRateComboBox.SelectedIndex;
tempDev.queueEvent(() =>
{
tempDev.setIdleTimeout(discon);
@ -1662,6 +1664,18 @@ namespace DS4Windows
{
tempDev.setBTPollRate(btCurrentIndex);
}
if (olddinputcheck != cBDinput.Checked)
{
if (cBDinput.Checked)
{
Program.rootHub.UnplugXInputController(device);
}
else
{
Program.rootHub.PlugXInputController(device);
}
}
});
}
}
@ -2161,14 +2175,9 @@ namespace DS4Windows
}
}
private void cBDinput_CheckedChanged(object sender, EventArgs e)
private void CBDinput_CheckedChanged(object sender, EventArgs e)
{
DinputOnly[device] = cBDinput.Checked;
if (!loading && device < 4)
{
root.BtnStartStop_Clicked(false);
finishDInputChange();
}
}
private async void finishDInputChange()