diff --git a/DS4Windows/DS4Control/ControlSerivce.cs b/DS4Windows/DS4Control/ControlSerivce.cs index 9066b59..2979ef5 100644 --- a/DS4Windows/DS4Control/ControlSerivce.cs +++ b/DS4Windows/DS4Control/ControlSerivce.cs @@ -110,7 +110,7 @@ namespace DS4Windows if (showlog) { LogDebug(Properties.Resources.SearchingController); - LogDebug(DS4Devices.isExclusiveMode ? Properties.Resources.UsingExclusive: Properties.Resources.UsingShared); + LogDebug(DS4Devices.isExclusiveMode ? Properties.Resources.UsingExclusive : Properties.Resources.UsingShared); } try @@ -145,13 +145,13 @@ namespace DS4Windows { if (System.IO.File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[i] + ".xml")) { - string prolog = Properties.Resources.UsingProfile.Replace("*number*", (i+1).ToString()).Replace("*Profile name*", ProfilePath[i]); + string prolog = Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", ProfilePath[i]); LogDebug(prolog); Log.LogToTray(prolog); } else { - string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (i+1).ToString()); + string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (i + 1).ToString()); LogDebug(prolog); Log.LogToTray(prolog); } @@ -169,8 +169,15 @@ namespace DS4Windows running = true; } + else + { + string logMessage = "Could not connect to Scp Virtual Bus Driver. Please check the status of the System device in Device Manager"; + LogDebug(logMessage); + Log.LogToTray(logMessage); + } ControllerStatusChanged(this); + runHotPlug = true; return true; } @@ -180,6 +187,8 @@ namespace DS4Windows if (running) { running = false; + runHotPlug = false; + if (showlog) LogDebug(Properties.Resources.StoppingX360); @@ -231,6 +240,7 @@ namespace DS4Windows ControllerStatusChanged(this); } + runHotPlug = false; return true; } diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 6f403fe..d6b83dc 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -1229,15 +1229,18 @@ namespace DS4Windows case DS4Controls.LXNeg: case DS4Controls.LXPos: { - if (dc == DS4Controls.LXNeg) + if (MappedState.LX == 127) { - byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping); - MappedState.LX = axisMapping; - } - else - { - byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true); - MappedState.LX = axisMapping; + if (dc == DS4Controls.LXNeg) + { + byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping); + MappedState.LX = axisMapping; + } + else + { + byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true); + MappedState.LX = axisMapping; + } } break; @@ -1245,15 +1248,18 @@ namespace DS4Windows case DS4Controls.LYNeg: case DS4Controls.LYPos: { - if (dc == DS4Controls.LYNeg) + if (MappedState.LY == 127) { - byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping); - MappedState.LY = axisMapping; - } - else - { - byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true); - MappedState.LY = axisMapping; + if (dc == DS4Controls.LYNeg) + { + byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping); + MappedState.LY = axisMapping; + } + else + { + byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true); + MappedState.LY = axisMapping; + } } break; @@ -1261,15 +1267,18 @@ namespace DS4Windows case DS4Controls.RXNeg: case DS4Controls.RXPos: { - if (dc == DS4Controls.RXNeg) + if (MappedState.RX == 127) { - byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping); - MappedState.RX = axisMapping; - } - else - { - byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true); - MappedState.RX = axisMapping; + if (dc == DS4Controls.RXNeg) + { + byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping); + MappedState.RX = axisMapping; + } + else + { + byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true); + MappedState.RX = axisMapping; + } } break; @@ -1277,15 +1286,18 @@ namespace DS4Windows case DS4Controls.RYNeg: case DS4Controls.RYPos: { - if (dc == DS4Controls.RYNeg) + if (MappedState.RY == 127) { - byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping); - MappedState.RY = axisMapping; - } - else - { - byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true); - MappedState.RY = axisMapping; + if (dc == DS4Controls.RYNeg) + { + byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping); + MappedState.RY = axisMapping; + } + else + { + byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true); + MappedState.RY = axisMapping; + } } break; diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 0c703ad..e30ca6e 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -185,6 +185,7 @@ namespace DS4Windows protected static Int32 m_IdleTimeout = 600000; static string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName; public static string appdatapath; + public static bool runHotPlug = false; public static string[] tempprofilename = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; public static bool[] tempprofileDistance = new bool[5] { false, false, false, false, false }; diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 2c43743..bfd59db 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -894,20 +894,24 @@ namespace DS4Windows protected override void WndProc(ref Message m) { - try + if (runHotPlug) { - if (m.Msg == ScpDevice.WM_DEVICECHANGE) + try { - Int32 Type = m.WParam.ToInt32(); - lock (this) + if (m.Msg == ScpDevice.WM_DEVICECHANGE) { - Program.rootHub.HotPlug(); + Int32 Type = m.WParam.ToInt32(); + + lock (this) + { + Program.rootHub.HotPlug(); + } } } + catch { } + if (m.Msg == WM_QUERYENDSESSION) + systemShutdown = true; } - catch { } - if (m.Msg == WM_QUERYENDSESSION) - systemShutdown = true; // If this is WM_QUERYENDSESSION, the closing event should be // raised in the base WndProc. diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index 2cdfdd8..5354ab5 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -36,7 +36,11 @@ namespace DS4Windows // Sort Bluetooth first in case USB is also connected on the same controller. hDevices = hDevices.OrderBy((HidDevice d) => { return DS4Device.HidConnectionType(d); }); - for (int i = 0, devCount = hDevices.Count(); i < devCount; i++) + int devCount = hDevices.Count(); + string devicePlural = "device" + (devCount == 0 || devCount > 1 ? "s" : ""); + //Log.LogToGui("Found " + devCount + " possible " + devicePlural + ". Examining " + devicePlural + ".", false); + + for (int i = 0; i < devCount; i++) //foreach (HidDevice hDevice in hDevices) { HidDevice hDevice = hDevices.ElementAt(i); diff --git a/DS4Windows/DS4Library/DS4State.cs b/DS4Windows/DS4Library/DS4State.cs index 0da4963..921a4fa 100644 --- a/DS4Windows/DS4Library/DS4State.cs +++ b/DS4Windows/DS4Library/DS4State.cs @@ -19,6 +19,7 @@ namespace DS4Windows public byte Battery; // 0 for charging, 10/20/30/40/50/60/70/80/90/100 for percentage of full public double LSAngle; // Calculated bearing of the LS X,Y coordinates public double RSAngle; // Calculated bearing of the RS X,Y coordinates + public static readonly int DEFAULT_AXISDIR_VALUE = 127; public DS4State() {