From a871e750ee1d35a7033965527cb3ed6905e52fdb Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 25 Oct 2019 01:48:56 -0500 Subject: [PATCH] Added new field array for specifying active controller types Related to issue #871 --- DS4Windows/DS4Control/ControlService.cs | 8 ++++++++ DS4Windows/DS4Control/ScpUtil.cs | 12 +++++++++++- DS4Windows/DS4Forms/Options.cs | 5 +---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 4eba2de..0fe05b1 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -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); diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 16bf835..564a934 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -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); diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 7bab1c0..41241e5 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -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) {