Added new field array for specifying active controller types

Related to issue #871
This commit is contained in:
Travis Nickles 2019-10-25 01:48:56 -05:00
parent bf86b891bb
commit a871e750ee
3 changed files with 20 additions and 5 deletions

View File

@ -442,6 +442,7 @@ namespace DS4Windows
if (contType == OutContType.X360)
{
LogDebug("Plugging in X360 Controller #" + (i + 1));
Global.activeOutDevType[i] = OutContType.X360;
Xbox360OutDevice tempXbox = new Xbox360OutDevice(vigemTestClient);
outputDevices[i] = tempXbox;
int devIndex = i;
@ -456,6 +457,7 @@ namespace DS4Windows
else if (contType == OutContType.DS4)
{
LogDebug("Plugging in DS4 Controller #" + (i + 1));
Global.activeOutDevType[i] = OutContType.DS4;
DS4OutDevice tempDS4 = new DS4OutDevice(vigemTestClient);
outputDevices[i] = tempDS4;
int devIndex = i;
@ -471,6 +473,7 @@ namespace DS4Windows
else
{
useDInputOnly[i] = true;
Global.activeOutDevType[i] = OutContType.None;
}
int tempIdx = i;
@ -606,6 +609,7 @@ namespace DS4Windows
outputDevices[i]?.Disconnect();
outputDevices[i] = null;
useDInputOnly[i] = true;
Global.activeOutDevType[i] = OutContType.None;
DS4Controllers[i] = null;
touchPad[i] = null;
lag[i] = false;
@ -723,6 +727,7 @@ namespace DS4Windows
if (contType == OutContType.X360)
{
LogDebug("Plugging in X360 Controller #" + (Index + 1));
Global.activeOutDevType[Index] = OutContType.X360;
Xbox360OutDevice tempXbox = new Xbox360OutDevice(vigemTestClient);
outputDevices[Index] = tempXbox;
int devIndex = Index;
@ -737,6 +742,7 @@ namespace DS4Windows
else if (contType == OutContType.DS4)
{
LogDebug("Plugging in DS4 Controller #" + (Index + 1));
Global.activeOutDevType[Index] = OutContType.DS4;
DS4OutDevice tempDS4 = new DS4OutDevice(vigemTestClient);
outputDevices[Index] = tempDS4;
int devIndex = Index;
@ -753,6 +759,7 @@ namespace DS4Windows
else
{
useDInputOnly[Index] = true;
Global.activeOutDevType[Index] = OutContType.None;
}
TouchPadOn(Index, device);
@ -1225,6 +1232,7 @@ namespace DS4Windows
lag[ind] = false;
inWarnMonitor[ind] = false;
useDInputOnly[ind] = true;
Global.activeOutDevType[ind] = OutContType.None;
uiContext?.Post(new SendOrPostCallback((state) =>
{
OnControllerRemoved(this, ind);

View File

@ -250,9 +250,14 @@ namespace DS4Windows
public static bool[] useDInputOnly = new bool[5] { true, true, true, true, true };
public static bool[] linkedProfileCheck = new bool[4] { true, true, true, true };
public static bool[] touchpadActive = new bool[5] { true, true, true, true, true };
// Used to hold device type desired from Profile Editor
public static OutContType[] outDevTypeTemp = new OutContType[5] { DS4Windows.OutContType.X360, DS4Windows.OutContType.X360,
DS4Windows.OutContType.X360, DS4Windows.OutContType.X360,
DS4Windows.OutContType.X360 };
// Used to hold the currently active controller output type in use for a slot
public static OutContType[] activeOutDevType = new OutContType[5] { DS4Windows.OutContType.None, DS4Windows.OutContType.None,
DS4Windows.OutContType.None, DS4Windows.OutContType.None,
DS4Windows.OutContType.None };
public static bool vigemInstalled = IsViGEmBusInstalled();
public static string vigembusVersion = ViGEmBusVersion();
@ -1973,6 +1978,7 @@ namespace DS4Windows
public bool[] trackballMode = new bool[5] { false, false, false, false, false };
public double[] trackballFriction = new double[5] { 10.0, 10.0, 10.0, 10.0, 10.0 };
// Used to hold the controller type desired in a profile
public OutContType[] outputDevType = new OutContType[5] { OutContType.X360,
OutContType.X360, OutContType.X360,
OutContType.X360, OutContType.X360 };
@ -2800,7 +2806,7 @@ namespace DS4Windows
DS4LightBar.forcedFlash[device] = 0;
}
OutContType oldContType = outputDevType[device];
OutContType oldContType = Global.activeOutDevType[device];
// Make sure to reset currently set profile values before parsing
ResetProfile(device);
@ -3641,11 +3647,13 @@ namespace DS4Windows
tempOutDev.Disconnect();
tempOutDev = null;
control.outputDevices[device] = null;
Global.activeOutDevType[device] = OutContType.None;
}
OutContType tempContType = outputDevType[device];
if (tempContType == OutContType.X360)
{
Global.activeOutDevType[device] = OutContType.X360;
Xbox360OutDevice tempXbox = new Xbox360OutDevice(control.vigemTestClient);
control.outputDevices[device] = tempXbox;
tempXbox.cont.FeedbackReceived += (eventsender, args) =>
@ -3658,6 +3666,7 @@ namespace DS4Windows
}
else if (tempContType == OutContType.DS4)
{
Global.activeOutDevType[device] = OutContType.DS4;
DS4OutDevice tempDS4 = new DS4OutDevice(control.vigemTestClient);
control.outputDevices[device] = tempDS4;
tempDS4.cont.FeedbackReceived += (eventsender, args) =>
@ -3679,6 +3688,7 @@ namespace DS4Windows
control.outputDevices[device] = null;
Global.useDInputOnly[device] = true;
AppLogger.LogToGui(tempType + " Controller #" + (device + 1) + " unplugged", false);
Global.activeOutDevType[device] = OutContType.None;
}
tempDev.setRumble(0, 0);

View File

@ -1758,10 +1758,7 @@ namespace DS4Windows.Forms
default: break;
}
if (Global.outDevTypeTemp[device] != tempType)
{
Global.OutContType[device] = tempType;
}
Global.OutContType[device] = tempType;
switch (gyroOutputMode.SelectedIndex)
{