Fixed issue with xinput unplug routine on device removal

Related to issue #554
This commit is contained in:
Travis Nickles 2019-02-07 16:40:24 -06:00
parent 4d989bb5f0
commit 3dd88e481c

View File

@ -2602,7 +2602,6 @@ namespace DS4Windows
catch { dinputOnly[device] = false; missingSetting = true; } catch { dinputOnly[device] = false; missingSetting = true; }
bool oldUseDInputOnly = Global.useDInputOnly[device]; bool oldUseDInputOnly = Global.useDInputOnly[device];
Global.useDInputOnly[device] = dinputOnly[device];
// Only change xinput devices under certain conditions. Avoid // Only change xinput devices under certain conditions. Avoid
// performing this upon program startup before loading devices. // performing this upon program startup before loading devices.
@ -2618,20 +2617,14 @@ namespace DS4Windows
{ {
if (dinputOnly[device] == true) if (dinputOnly[device] == true)
{ {
Global.useDInputOnly[device] = true;
xinputPlug = false; xinputPlug = false;
xinputStatus = true; xinputStatus = true;
} }
else if (synced && isAlive) else if (synced && isAlive)
{ {
Global.useDInputOnly[device] = false;
xinputPlug = true; xinputPlug = true;
xinputStatus = true; xinputStatus = true;
} }
else if (!synced)
{
Global.useDInputOnly[device] = true;
}
} }
} }
} }
@ -2995,12 +2988,12 @@ namespace DS4Windows
int xinputIndex = control.x360Bus.FirstController + device; int xinputIndex = control.x360Bus.FirstController + device;
if (xinputResult) if (xinputResult)
{ {
dinputOnly[device] = false; Global.useDInputOnly[device] = false;
AppLogger.LogToGui("X360 Controller # " + xinputIndex + " connected", false); AppLogger.LogToGui("X360 Controller # " + xinputIndex + " connected", false);
} }
else else
{ {
dinputOnly[device] = true; Global.useDInputOnly[device] = true;
AppLogger.LogToGui("X360 Controller # " + xinputIndex + " failed. Using DInput only mode", true); AppLogger.LogToGui("X360 Controller # " + xinputIndex + " failed. Using DInput only mode", true);
} }
} }
@ -3010,11 +3003,12 @@ namespace DS4Windows
int xinputIndex = control.x360Bus.FirstController + device; int xinputIndex = control.x360Bus.FirstController + device;
if (xinputResult) if (xinputResult)
{ {
dinputOnly[device] = true; Global.useDInputOnly[device] = true;
AppLogger.LogToGui("X360 Controller # " + xinputIndex + " unplugged", false); AppLogger.LogToGui("X360 Controller # " + xinputIndex + " unplugged", false);
} }
else else
{ {
Global.useDInputOnly[device] = false;
AppLogger.LogToGui("X360 Controller # " + xinputIndex + " failed to unplug", true); AppLogger.LogToGui("X360 Controller # " + xinputIndex + " failed to unplug", true);
} }
} }