From 18335e06c31485136f475fd705aefb31614c7dda Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 24 Aug 2018 18:11:33 -0500 Subject: [PATCH 1/8] Updated url of alt ViGEm build --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e0ca3cc..e25f773 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ website at [ds4windows.com](http://ds4windows.com). - **[Main builds of DS4Windows](https://github.com/Ryochan7/DS4Windows/releases)** - Alternative builds: - - [UdpServer ViGEm build](http://ryochan7.xyz/ds4windows/test/DS4Windows_1.5.6_ViGEm_UdpServer_x64.zip) + - [UdpServer ViGEm build](http://ryochan7.xyz/ds4windows/test/DS4Windows_1.5.8_ViGEm_UdpServer_x64.zip) ## Requirements From 55764919db8e863b9281262fe543558b5e13b09f Mon Sep 17 00:00:00 2001 From: Hannele Ruiz Date: Tue, 28 Aug 2018 07:44:26 -0300 Subject: [PATCH 2/8] Fixed out of range while checking the selected index --- DS4Windows/DS4Forms/RecordBox.cs | 124 ++++++++++++++++--------------- 1 file changed, 63 insertions(+), 61 deletions(-) diff --git a/DS4Windows/DS4Forms/RecordBox.cs b/DS4Windows/DS4Forms/RecordBox.cs index 07040ea..225fcc0 100644 --- a/DS4Windows/DS4Forms/RecordBox.cs +++ b/DS4Windows/DS4Forms/RecordBox.cs @@ -1225,70 +1225,72 @@ namespace DS4Windows private void lVMacros_MouseDoubleClick(object sender, MouseEventArgs e) { - if (lVMacros.SelectedIndices[0] >= 0) + if (lVMacros.SelectedIndices.Count == 0) { - if (lVMacros.SelectedItems[0].ImageIndex == 2) - { - TextBox tb = new TextBox(); - tb.MaxLength = 5; - tb.KeyDown += nud_KeyDown; - tb.LostFocus += nud_LostFocus; - selection = lVMacros.SelectedIndices[0]; - Controls.Add(tb); - changingDelay = true; - tb.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); - tb.BringToFront(); - lVMacros.MouseHover -= lVMacros_MouseHover; - tb.TextChanged += tb_TextChanged; - tb.Focus(); - } - else if (macros[lVMacros.SelectedIndices[0]] > 1000000000) - { - selection = lVMacros.SelectedIndices[0]; - string lb = macros[lVMacros.SelectedIndices[0]].ToString().Substring(1); - byte r = (byte)(int.Parse(lb[0].ToString()) * 100 + int.Parse(lb[1].ToString()) * 10 + int.Parse(lb[2].ToString())); - byte g = (byte)(int.Parse(lb[3].ToString()) * 100 + int.Parse(lb[4].ToString()) * 10 + int.Parse(lb[5].ToString())); - byte b = (byte)(int.Parse(lb[6].ToString()) * 100 + int.Parse(lb[7].ToString()) * 10 + int.Parse(lb[8].ToString())); - AdvancedColorDialog advColorDialog = new AdvancedColorDialog(); - advColorDialog.Color = Color.FromArgb(r, g, b); - advColorDialog.OnUpdateColor += advColorDialog_OnUpdateColor; - if (advColorDialog.ShowDialog() == DialogResult.OK) - { - macros[selection] = 1000000000 + advColorDialog.Color.R * 1000000 + advColorDialog.Color.G * 1000 + advColorDialog.Color.B; - } - lVMacros.Items[selection].Text = ($"Lightbar Color: {advColorDialog.Color.R},{advColorDialog.Color.G},{advColorDialog.Color.B}"); - } - else if (macros[lVMacros.SelectedIndices[0]] > 1000000 && macros[lVMacros.SelectedIndices[0]] != 1000000000) - { + return; + } - lVMacros.MouseHover -= lVMacros_MouseHover; - string r = macros[lVMacros.SelectedIndices[0]].ToString().Substring(1); - byte heavy = (byte)(int.Parse(r[0].ToString()) * 100 + int.Parse(r[1].ToString()) * 10 + int.Parse(r[2].ToString())); - byte light = (byte)(int.Parse(r[3].ToString()) * 100 + int.Parse(r[4].ToString()) * 10 + int.Parse(r[5].ToString())); - selection = lVMacros.SelectedIndices[0]; - tb1 = new TextBox(); - tb2 = new TextBox(); - tb1.Name = "tBHeavy"; - tb1.Name = "tBLight"; - tb1.MaxLength = 3; - tb2.MaxLength = 3; - tb1.KeyDown += nud_KeyDown; - tb2.KeyDown += nud_KeyDown; - Controls.Add(tb1); - Controls.Add(tb2); - changingDelay = false; - tb1.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); - tb1.Size = new Size(tb1.Size.Width / 2, tb1.Size.Height); - tb2.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X + tb1.Size.Width, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); - tb2.Size = tb1.Size; - tb1.BringToFront(); - tb2.BringToFront(); - tb1.Text = heavy.ToString(); - tb2.Text = light.ToString(); - tb1.TextChanged += tb_TextChanged; - tb2.TextChanged += tb_TextChanged; - tb1.Focus(); + if (lVMacros.SelectedItems[0].ImageIndex == 2) + { + TextBox tb = new TextBox(); + tb.MaxLength = 5; + tb.KeyDown += nud_KeyDown; + tb.LostFocus += nud_LostFocus; + selection = lVMacros.SelectedIndices[0]; + Controls.Add(tb); + changingDelay = true; + tb.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); + tb.BringToFront(); + lVMacros.MouseHover -= lVMacros_MouseHover; + tb.TextChanged += tb_TextChanged; + tb.Focus(); + } + else if (macros[lVMacros.SelectedIndices[0]] > 1000000000) + { + selection = lVMacros.SelectedIndices[0]; + string lb = macros[lVMacros.SelectedIndices[0]].ToString().Substring(1); + byte r = (byte)(int.Parse(lb[0].ToString()) * 100 + int.Parse(lb[1].ToString()) * 10 + int.Parse(lb[2].ToString())); + byte g = (byte)(int.Parse(lb[3].ToString()) * 100 + int.Parse(lb[4].ToString()) * 10 + int.Parse(lb[5].ToString())); + byte b = (byte)(int.Parse(lb[6].ToString()) * 100 + int.Parse(lb[7].ToString()) * 10 + int.Parse(lb[8].ToString())); + AdvancedColorDialog advColorDialog = new AdvancedColorDialog(); + advColorDialog.Color = Color.FromArgb(r, g, b); + advColorDialog.OnUpdateColor += advColorDialog_OnUpdateColor; + if (advColorDialog.ShowDialog() == DialogResult.OK) + { + macros[selection] = 1000000000 + advColorDialog.Color.R * 1000000 + advColorDialog.Color.G * 1000 + advColorDialog.Color.B; } + lVMacros.Items[selection].Text = ($"Lightbar Color: {advColorDialog.Color.R},{advColorDialog.Color.G},{advColorDialog.Color.B}"); + } + else if (macros[lVMacros.SelectedIndices[0]] > 1000000 && macros[lVMacros.SelectedIndices[0]] != 1000000000) + { + + lVMacros.MouseHover -= lVMacros_MouseHover; + string r = macros[lVMacros.SelectedIndices[0]].ToString().Substring(1); + byte heavy = (byte)(int.Parse(r[0].ToString()) * 100 + int.Parse(r[1].ToString()) * 10 + int.Parse(r[2].ToString())); + byte light = (byte)(int.Parse(r[3].ToString()) * 100 + int.Parse(r[4].ToString()) * 10 + int.Parse(r[5].ToString())); + selection = lVMacros.SelectedIndices[0]; + tb1 = new TextBox(); + tb2 = new TextBox(); + tb1.Name = "tBHeavy"; + tb1.Name = "tBLight"; + tb1.MaxLength = 3; + tb2.MaxLength = 3; + tb1.KeyDown += nud_KeyDown; + tb2.KeyDown += nud_KeyDown; + Controls.Add(tb1); + Controls.Add(tb2); + changingDelay = false; + tb1.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); + tb1.Size = new Size(tb1.Size.Width / 2, tb1.Size.Height); + tb2.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X + tb1.Size.Width, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); + tb2.Size = tb1.Size; + tb1.BringToFront(); + tb2.BringToFront(); + tb1.Text = heavy.ToString(); + tb2.Text = light.ToString(); + tb1.TextChanged += tb_TextChanged; + tb2.TextChanged += tb_TextChanged; + tb1.Focus(); } } From 53ec1e2eef4d7a74fab93177788c200b5b209caa Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 14 Sep 2018 03:35:54 -0500 Subject: [PATCH 3/8] Test using stack of SocketAsyncEventArgs --- DS4Windows/DS4Control/UdpServer.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/DS4Windows/DS4Control/UdpServer.cs b/DS4Windows/DS4Control/UdpServer.cs index 7e87fd8..1dd6820 100644 --- a/DS4Windows/DS4Control/UdpServer.cs +++ b/DS4Windows/DS4Control/UdpServer.cs @@ -69,6 +69,7 @@ namespace DS4Windows private uint serverId; private bool running; private byte[] recvBuffer = new byte[1024]; + private Stack argsStack; public delegate void GetPadDetail(int padIdx, ref DualShockPadMeta meta); @@ -77,6 +78,13 @@ namespace DS4Windows public UdpServer(GetPadDetail getPadDetailDel) { portInfoGet = getPadDetailDel; + argsStack = new Stack(20); + for (int num = 0; num <= 19; num++) + { + SocketAsyncEventArgs args = new SocketAsyncEventArgs(); + args.Completed += ClearSentData; + argsStack.Push(args); + } } enum MessageType @@ -174,10 +182,9 @@ namespace DS4Windows FinishPacket(packetData); //try { udpSock.SendTo(packetData, clientEP); } - SocketAsyncEventArgs args = new SocketAsyncEventArgs(); + SocketAsyncEventArgs args = argsStack.Pop(); args.RemoteEndPoint = clientEP; args.SetBuffer(packetData, 0, packetData.Length); - args.Completed += ClearSentData; try { udpSock.SendToAsync(args); } catch (Exception e) { } } @@ -632,11 +639,10 @@ namespace DS4Windows foreach (var cl in clientsList) { //try { udpSock.SendTo(outputData, cl); } - SocketAsyncEventArgs args = new SocketAsyncEventArgs(); + SocketAsyncEventArgs args = argsStack.Pop(); args.RemoteEndPoint = cl; args.SetBuffer(outputData, 0, outputData.Length); - args.Completed += ClearSentData; - try { udpSock.SendToAsync(args); } + try { bool result = udpSock.SendToAsync(args); if (!result) argsStack.Push(args); } catch (SocketException ex) { } } } @@ -647,8 +653,9 @@ namespace DS4Windows private void ClearSentData(object sender, SocketAsyncEventArgs args) { - args.Dispose(); - args = null; + argsStack.Push(args); + //args.Dispose(); + //args = null; } } } From 13005458f146c2cbd783a5a2153dc28d91772401 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 18 Sep 2018 03:39:59 -0500 Subject: [PATCH 4/8] Increase timeout for exclusive attempt process --- DS4Windows/DS4Library/DS4Devices.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index e3a87f6..2636744 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -104,7 +104,7 @@ namespace DS4Windows startInfo.Arguments = "re-enabledevice " + devicePathToInstanceId(hDevice.DevicePath); Process child = Process.Start(startInfo); - if (!child.WaitForExit(5000)) + if (!child.WaitForExit(15000)) { child.Kill(); } From 9b36f73ed528fb3e1813b31cb3ce8f247ecfc670 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sat, 29 Sep 2018 04:18:25 -0500 Subject: [PATCH 5/8] Minor tweak to contribution that .NET wanted Related to #406 --- DS4Windows/DS4Forms/RecordBox.cs | 122 +++++++++++++++---------------- 1 file changed, 60 insertions(+), 62 deletions(-) diff --git a/DS4Windows/DS4Forms/RecordBox.cs b/DS4Windows/DS4Forms/RecordBox.cs index 225fcc0..112e12b 100644 --- a/DS4Windows/DS4Forms/RecordBox.cs +++ b/DS4Windows/DS4Forms/RecordBox.cs @@ -1225,72 +1225,70 @@ namespace DS4Windows private void lVMacros_MouseDoubleClick(object sender, MouseEventArgs e) { - if (lVMacros.SelectedIndices.Count == 0) + if (lVMacros.SelectedIndices.Count != 0) { - return; - } - - if (lVMacros.SelectedItems[0].ImageIndex == 2) - { - TextBox tb = new TextBox(); - tb.MaxLength = 5; - tb.KeyDown += nud_KeyDown; - tb.LostFocus += nud_LostFocus; - selection = lVMacros.SelectedIndices[0]; - Controls.Add(tb); - changingDelay = true; - tb.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); - tb.BringToFront(); - lVMacros.MouseHover -= lVMacros_MouseHover; - tb.TextChanged += tb_TextChanged; - tb.Focus(); - } - else if (macros[lVMacros.SelectedIndices[0]] > 1000000000) - { - selection = lVMacros.SelectedIndices[0]; - string lb = macros[lVMacros.SelectedIndices[0]].ToString().Substring(1); - byte r = (byte)(int.Parse(lb[0].ToString()) * 100 + int.Parse(lb[1].ToString()) * 10 + int.Parse(lb[2].ToString())); - byte g = (byte)(int.Parse(lb[3].ToString()) * 100 + int.Parse(lb[4].ToString()) * 10 + int.Parse(lb[5].ToString())); - byte b = (byte)(int.Parse(lb[6].ToString()) * 100 + int.Parse(lb[7].ToString()) * 10 + int.Parse(lb[8].ToString())); - AdvancedColorDialog advColorDialog = new AdvancedColorDialog(); - advColorDialog.Color = Color.FromArgb(r, g, b); - advColorDialog.OnUpdateColor += advColorDialog_OnUpdateColor; - if (advColorDialog.ShowDialog() == DialogResult.OK) + if (lVMacros.SelectedItems[0].ImageIndex == 2) { - macros[selection] = 1000000000 + advColorDialog.Color.R * 1000000 + advColorDialog.Color.G * 1000 + advColorDialog.Color.B; + TextBox tb = new TextBox(); + tb.MaxLength = 5; + tb.KeyDown += nud_KeyDown; + tb.LostFocus += nud_LostFocus; + selection = lVMacros.SelectedIndices[0]; + Controls.Add(tb); + changingDelay = true; + tb.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); + tb.BringToFront(); + lVMacros.MouseHover -= lVMacros_MouseHover; + tb.TextChanged += tb_TextChanged; + tb.Focus(); } - lVMacros.Items[selection].Text = ($"Lightbar Color: {advColorDialog.Color.R},{advColorDialog.Color.G},{advColorDialog.Color.B}"); - } - else if (macros[lVMacros.SelectedIndices[0]] > 1000000 && macros[lVMacros.SelectedIndices[0]] != 1000000000) - { + else if (macros[lVMacros.SelectedIndices[0]] > 1000000000) + { + selection = lVMacros.SelectedIndices[0]; + string lb = macros[lVMacros.SelectedIndices[0]].ToString().Substring(1); + byte r = (byte)(int.Parse(lb[0].ToString()) * 100 + int.Parse(lb[1].ToString()) * 10 + int.Parse(lb[2].ToString())); + byte g = (byte)(int.Parse(lb[3].ToString()) * 100 + int.Parse(lb[4].ToString()) * 10 + int.Parse(lb[5].ToString())); + byte b = (byte)(int.Parse(lb[6].ToString()) * 100 + int.Parse(lb[7].ToString()) * 10 + int.Parse(lb[8].ToString())); + AdvancedColorDialog advColorDialog = new AdvancedColorDialog(); + advColorDialog.Color = Color.FromArgb(r, g, b); + advColorDialog.OnUpdateColor += advColorDialog_OnUpdateColor; + if (advColorDialog.ShowDialog() == DialogResult.OK) + { + macros[selection] = 1000000000 + advColorDialog.Color.R * 1000000 + advColorDialog.Color.G * 1000 + advColorDialog.Color.B; + } + lVMacros.Items[selection].Text = ($"Lightbar Color: {advColorDialog.Color.R},{advColorDialog.Color.G},{advColorDialog.Color.B}"); + } + else if (macros[lVMacros.SelectedIndices[0]] > 1000000 && macros[lVMacros.SelectedIndices[0]] != 1000000000) + { - lVMacros.MouseHover -= lVMacros_MouseHover; - string r = macros[lVMacros.SelectedIndices[0]].ToString().Substring(1); - byte heavy = (byte)(int.Parse(r[0].ToString()) * 100 + int.Parse(r[1].ToString()) * 10 + int.Parse(r[2].ToString())); - byte light = (byte)(int.Parse(r[3].ToString()) * 100 + int.Parse(r[4].ToString()) * 10 + int.Parse(r[5].ToString())); - selection = lVMacros.SelectedIndices[0]; - tb1 = new TextBox(); - tb2 = new TextBox(); - tb1.Name = "tBHeavy"; - tb1.Name = "tBLight"; - tb1.MaxLength = 3; - tb2.MaxLength = 3; - tb1.KeyDown += nud_KeyDown; - tb2.KeyDown += nud_KeyDown; - Controls.Add(tb1); - Controls.Add(tb2); - changingDelay = false; - tb1.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); - tb1.Size = new Size(tb1.Size.Width / 2, tb1.Size.Height); - tb2.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X + tb1.Size.Width, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); - tb2.Size = tb1.Size; - tb1.BringToFront(); - tb2.BringToFront(); - tb1.Text = heavy.ToString(); - tb2.Text = light.ToString(); - tb1.TextChanged += tb_TextChanged; - tb2.TextChanged += tb_TextChanged; - tb1.Focus(); + lVMacros.MouseHover -= lVMacros_MouseHover; + string r = macros[lVMacros.SelectedIndices[0]].ToString().Substring(1); + byte heavy = (byte)(int.Parse(r[0].ToString()) * 100 + int.Parse(r[1].ToString()) * 10 + int.Parse(r[2].ToString())); + byte light = (byte)(int.Parse(r[3].ToString()) * 100 + int.Parse(r[4].ToString()) * 10 + int.Parse(r[5].ToString())); + selection = lVMacros.SelectedIndices[0]; + tb1 = new TextBox(); + tb2 = new TextBox(); + tb1.Name = "tBHeavy"; + tb1.Name = "tBLight"; + tb1.MaxLength = 3; + tb2.MaxLength = 3; + tb1.KeyDown += nud_KeyDown; + tb2.KeyDown += nud_KeyDown; + Controls.Add(tb1); + Controls.Add(tb2); + changingDelay = false; + tb1.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); + tb1.Size = new Size(tb1.Size.Width / 2, tb1.Size.Height); + tb2.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X + tb1.Size.Width, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y); + tb2.Size = tb1.Size; + tb1.BringToFront(); + tb2.BringToFront(); + tb1.Text = heavy.ToString(); + tb2.Text = light.ToString(); + tb1.TextChanged += tb_TextChanged; + tb2.TextChanged += tb_TextChanged; + tb1.Focus(); + } } } From 10194996129ed2b0bf395de0c670b4166e835738 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sat, 29 Sep 2018 04:42:22 -0500 Subject: [PATCH 6/8] Resolve name collision with Log class and Diagnostics namespace Makes app snappier --- DS4Windows/DS4Control/ControlService.cs | 28 ++++++++++++------------- DS4Windows/DS4Control/Log.cs | 2 +- DS4Windows/DS4Control/Mapping.cs | 2 +- DS4Windows/DS4Control/ScpUtil.cs | 14 ++++++------- DS4Windows/DS4Forms/DS4Form.cs | 10 ++++----- DS4Windows/DS4Library/DS4Device.cs | 8 +++---- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index bf12f13..933b78f 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -198,7 +198,7 @@ namespace DS4Windows var errMsg = String.Format("Couldn't start UDP server on port {0}, outside applications won't be able to access pad data ({1})", UDP_SERVER_PORT, ex.SocketErrorCode); LogDebug(errMsg, true); - Log.LogToTray(errMsg, true, true); + AppLogger.LogToTray(errMsg, true, true); } udpChangeStatus = false; @@ -211,7 +211,7 @@ namespace DS4Windows udpChangeStatus = true; _udpServer.Stop(); _udpServer = null; - Log.LogToGui("Closed UDP server", false); + AppLogger.LogToGui("Closed UDP server", false); udpChangeStatus = false; }); } @@ -276,7 +276,7 @@ namespace DS4Windows var errMsg = String.Format("Couldn't start UDP server on port {0}, outside applications won't be able to access pad data ({1})", UDP_SERVER_PORT, ex.SocketErrorCode); LogDebug(errMsg, true); - Log.LogToTray(errMsg, true, true); + AppLogger.LogToTray(errMsg, true, true); } changingUDPPort = false; @@ -289,7 +289,7 @@ namespace DS4Windows string message = Properties.Resources.CouldNotOpenDS4.Replace("*Mac address*", device.getMacAddress()) + " " + Properties.Resources.QuitOtherPrograms; LogDebug(message, true); - Log.LogToTray(message, true); + AppLogger.LogToTray(message, true); } } @@ -490,13 +490,13 @@ namespace DS4Windows { string prolog = Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", ProfilePath[i]); LogDebug(prolog); - Log.LogToTray(prolog); + AppLogger.LogToTray(prolog); } else { string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (i + 1).ToString()); LogDebug(prolog); - Log.LogToTray(prolog); + AppLogger.LogToTray(prolog); } } @@ -507,7 +507,7 @@ namespace DS4Windows catch (Exception e) { LogDebug(e.Message); - Log.LogToTray(e.Message); + AppLogger.LogToTray(e.Message); } running = true; @@ -527,7 +527,7 @@ namespace DS4Windows var errMsg = String.Format("Couldn't start UDP server on port {0}, outside applications won't be able to access pad data ({1})", UDP_SERVER_PORT, ex.SocketErrorCode); LogDebug(errMsg, true); - Log.LogToTray(errMsg, true, true); + AppLogger.LogToTray(errMsg, true, true); } } } @@ -535,7 +535,7 @@ namespace DS4Windows { 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); + AppLogger.LogToTray(logMessage); } runHotPlug = true; @@ -719,13 +719,13 @@ namespace DS4Windows { string prolog = Properties.Resources.UsingProfile.Replace("*number*", (Index + 1).ToString()).Replace("*Profile name*", ProfilePath[Index]); LogDebug(prolog); - Log.LogToTray(prolog); + AppLogger.LogToTray(prolog); } else { string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (Index + 1).ToString()); LogDebug(prolog); - Log.LogToTray(prolog); + AppLogger.LogToTray(prolog); } break; @@ -1028,7 +1028,7 @@ namespace DS4Windows } LogDebug(removed); - Log.LogToTray(removed); + AppLogger.LogToTray(removed); /*Stopwatch sw = new Stopwatch(); sw.Start(); while (sw.ElapsedMilliseconds < XINPUT_UNPLUG_SETTLE_TIME) @@ -1291,7 +1291,7 @@ namespace DS4Windows getTouchSensitivity()[deviceID] = 0; getScrollSensitivity()[deviceID] = 0; LogDebug(Properties.Resources.TouchpadMovementOff); - Log.LogToTray(Properties.Resources.TouchpadMovementOff); + AppLogger.LogToTray(Properties.Resources.TouchpadMovementOff); touchreleased[deviceID] = false; } else if (touchreleased[deviceID]) @@ -1299,7 +1299,7 @@ namespace DS4Windows getTouchSensitivity()[deviceID] = oldtouchvalue[deviceID]; getScrollSensitivity()[deviceID] = oldscrollvalue[deviceID]; LogDebug(Properties.Resources.TouchpadMovementOn); - Log.LogToTray(Properties.Resources.TouchpadMovementOn); + AppLogger.LogToTray(Properties.Resources.TouchpadMovementOn); touchreleased[deviceID] = false; } } diff --git a/DS4Windows/DS4Control/Log.cs b/DS4Windows/DS4Control/Log.cs index 1eef330..a2d8815 100644 --- a/DS4Windows/DS4Control/Log.cs +++ b/DS4Windows/DS4Control/Log.cs @@ -2,7 +2,7 @@ namespace DS4Windows { - public class Log + public class AppLogger { public static event EventHandler TrayIconLog; public static event EventHandler GuiLog; diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 2fe70c0..c7614c5 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -1940,7 +1940,7 @@ namespace DS4Windows dets = action.details.Split(','); if (bool.Parse(dets[1]) && !actionDone[index].dev[device]) { - Log.LogToTray("Controller " + (device + 1) + ": " + + AppLogger.LogToTray("Controller " + (device + 1) + ": " + ctrl.getDS4Battery(device), true); } if (bool.Parse(dets[2])) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 604c8c2..b968a33 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -2900,12 +2900,12 @@ namespace DS4Windows if (xinputResult) { dinputOnly[device] = false; - Log.LogToGui("X360 Controller # " + xinputIndex + " connected", false); + AppLogger.LogToGui("X360 Controller # " + xinputIndex + " connected", false); } else { dinputOnly[device] = true; - Log.LogToGui("X360 Controller # " + xinputIndex + " failed. Using DInput only mode", true); + AppLogger.LogToGui("X360 Controller # " + xinputIndex + " failed. Using DInput only mode", true); } } else if (xinputStatus && !xinputPlug) @@ -2915,11 +2915,11 @@ namespace DS4Windows if (xinputResult) { dinputOnly[device] = true; - Log.LogToGui("X360 Controller # " + xinputIndex + " unplugged", false); + AppLogger.LogToGui("X360 Controller # " + xinputIndex + " unplugged", false); } else { - Log.LogToGui("X360 Controller # " + xinputIndex + " failed to unplug", true); + AppLogger.LogToGui("X360 Controller # " + xinputIndex + " failed to unplug", true); } } @@ -3355,7 +3355,7 @@ namespace DS4Windows m_Xdoc.AppendChild(Node); try { m_Xdoc.Save(m_linkedProfiles); } - catch (UnauthorizedAccessException) { Log.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } + catch (UnauthorizedAccessException) { AppLogger.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } return saved; } @@ -3386,7 +3386,7 @@ namespace DS4Windows } else { - Log.LogToGui("LinkedProfiles.xml can't be found.", false); + AppLogger.LogToGui("LinkedProfiles.xml can't be found.", false); loaded = false; } @@ -3424,7 +3424,7 @@ namespace DS4Windows } try { linkedXdoc.Save(m_linkedProfiles); } - catch (UnauthorizedAccessException) { Log.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } + catch (UnauthorizedAccessException) { AppLogger.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } } else { diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 21f57cf..68e5189 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -149,8 +149,8 @@ namespace DS4Windows Program.rootHub.Debug += On_Debug; - Log.GuiLog += On_Debug; - Log.TrayIconLog += ShowNotification; + AppLogger.GuiLog += On_Debug; + AppLogger.TrayIconLog += ShowNotification; Directory.CreateDirectory(appdatapath); if (!Save()) //if can't write to file @@ -252,7 +252,7 @@ namespace DS4Windows FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); string version = fvi.FileVersion; - Log.LogToGui("DS4Windows version " + version, false); + AppLogger.LogToGui("DS4Windows version " + version, false); LoadP(); LoadLinkedProfiles(); @@ -2493,7 +2493,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question { RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters"); key.SetValue("AffectedDevices", Program.rootHub.affectedDevs.ToArray(), RegistryValueKind.MultiString); - Log.LogToGui("Wrote HidGuardian Device List to Registry", false); + AppLogger.LogToGui("Wrote HidGuardian Device List to Registry", false); } catch { } } @@ -2503,7 +2503,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question try { Registry.LocalMachine.DeleteSubKeyTree(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist"); - Log.LogToGui("Cleared HidGuardian Whitelist", false); + AppLogger.LogToGui("Cleared HidGuardian Whitelist", false); Program.rootHub.CreateHidGuardKey(); } catch { } diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 4a58fc8..bc603a1 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -503,7 +503,7 @@ namespace DS4Windows bool validCrc = recvCrc32 == calcCrc32; if (!validCrc && tries >= 5) { - Log.LogToGui("Gyro Calibration Failed", true); + AppLogger.LogToGui("Gyro Calibration Failed", true); continue; } else if (validCrc) @@ -786,7 +786,7 @@ namespace DS4Windows { if (res == HidDevice.ReadStatus.WaitTimedOut) { - Log.LogToGui(Mac.ToString() + " disconnected due to timeout", true); + AppLogger.LogToGui(Mac.ToString() + " disconnected due to timeout", true); } else { @@ -814,7 +814,7 @@ namespace DS4Windows { if (res == HidDevice.ReadStatus.WaitTimedOut) { - Log.LogToGui(Mac.ToString() + " disconnected due to timeout", true); + AppLogger.LogToGui(Mac.ToString() + " disconnected due to timeout", true); } else { @@ -1051,7 +1051,7 @@ namespace DS4Windows if (shouldDisconnect) { - Log.LogToGui(Mac.ToString() + " disconnecting due to idle disconnect", false); + AppLogger.LogToGui(Mac.ToString() + " disconnecting due to idle disconnect", false); if (conType == ConnectionType.BT) { From 3aa558c85f4786a5e484af9130294c04b5bc03b8 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sat, 29 Sep 2018 21:54:25 -0500 Subject: [PATCH 7/8] Version of different gyro trigger conditional Related to issue #431 --- DS4Windows/DS4Control/Mouse.cs | 14 +++- DS4Windows/DS4Control/ScpUtil.cs | 40 +++++++++ DS4Windows/DS4Forms/DS4Form.cs | 2 +- DS4Windows/DS4Forms/Options.Designer.cs | 23 ++++- DS4Windows/DS4Forms/Options.cs | 14 ++++ DS4Windows/DS4Forms/Options.resx | 106 +++++++++++++++++++----- 6 files changed, 170 insertions(+), 29 deletions(-) diff --git a/DS4Windows/DS4Control/Mouse.cs b/DS4Windows/DS4Control/Mouse.cs index 126eeb5..23d2057 100644 --- a/DS4Windows/DS4Control/Mouse.cs +++ b/DS4Windows/DS4Control/Mouse.cs @@ -66,20 +66,26 @@ namespace DS4Windows { s = dev.getCurrentStateRef(); - triggeractivated = true; useReverseRatchet = Global.getGyroTriggerTurns(deviceNum); int i = 0; string[] ss = Global.getSATriggers(deviceNum).Split(','); + bool andCond = Global.getSATriggerCond(deviceNum); + triggeractivated = andCond ? true : false; if (!string.IsNullOrEmpty(ss[0])) { string s = string.Empty; - for (int index = 0, arlen = ss.Length; - triggeractivated && index < arlen; index++) + for (int index = 0, arlen = ss.Length; index < arlen; index++) { s = ss[index]; - if (!(int.TryParse(s, out i) && getDS4ControlsByName(i))) + if (andCond && !(int.TryParse(s, out i) && getDS4ControlsByName(i))) { triggeractivated = false; + break; + } + else if (!andCond && int.TryParse(s, out i) && getDS4ControlsByName(i)) + { + triggeractivated = true; + break; } } } diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index b968a33..380a2ed 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -707,6 +707,16 @@ namespace DS4Windows return m_Config.sATriggers[index]; } + public static bool[] SATriggerCond => m_Config.sATriggerCond; + public static bool getSATriggerCond(int index) + { + return m_Config.sATriggerCond[index]; + } + public static void SetSaTriggerCond(int index, string text) + { + m_Config.SetSaTriggerCond(index, text); + } + public static int[][] TouchDisInvertTriggers => m_Config.touchDisInvertTriggers; public static int[] getTouchDisInvertTriggers(int index) { @@ -1470,6 +1480,7 @@ namespace DS4Windows public bool[] useTPforControls = new bool[5] { false, false, false, false, false }; public bool[] useSAforMouse = new bool[5] { false, false, false, false, false }; public string[] sATriggers = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + public bool[] sATriggerCond = new bool[5] { true, true, true, true, true }; public int[][] touchDisInvertTriggers = new int[5][] { new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 } }; public int[] lsCurve = new int[5] { 0, 0, 0, 0, 0 }; @@ -1604,6 +1615,30 @@ namespace DS4Windows return id; } + private bool SaTriggerCondValue(string text) + { + bool result = true; + switch (text) + { + case "and": result = true; break; + case "or": result = false; break; + default: result = true; break; + } + + return result; + } + + private string SaTriggerCondString(bool value) + { + string result = value ? "and" : "or"; + return result; + } + + public void SetSaTriggerCond(int index, string text) + { + sATriggerCond[index] = SaTriggerCondValue(text); + } + public bool SaveProfile(int device, string propath) { bool Saved = true; @@ -1691,6 +1726,7 @@ namespace DS4Windows XmlNode xmlUseTPforControls = m_Xdoc.CreateNode(XmlNodeType.Element, "UseTPforControls", null); xmlUseTPforControls.InnerText = useTPforControls[device].ToString(); Node.AppendChild(xmlUseTPforControls); XmlNode xmlUseSAforMouse = m_Xdoc.CreateNode(XmlNodeType.Element, "UseSAforMouse", null); xmlUseSAforMouse.InnerText = useSAforMouse[device].ToString(); Node.AppendChild(xmlUseSAforMouse); XmlNode xmlSATriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "SATriggers", null); xmlSATriggers.InnerText = sATriggers[device].ToString(); Node.AppendChild(xmlSATriggers); + XmlNode xmlSATriggerCond = m_Xdoc.CreateNode(XmlNodeType.Element, "SATriggerCond", null); xmlSATriggerCond.InnerText = SaTriggerCondString(sATriggerCond[device]); Node.AppendChild(xmlSATriggerCond); XmlNode xmlTouchDisInvTriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "TouchDisInvTriggers", null); string tempTouchDisInv = string.Join(",", touchDisInvertTriggers[device]); @@ -2571,6 +2607,9 @@ namespace DS4Windows try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SATriggers"); sATriggers[device] = Item.InnerText; } catch { sATriggers[device] = ""; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SATriggerCond"); sATriggerCond[device] = SaTriggerCondValue(Item.InnerText); } + catch { sATriggerCond[device] = true; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/TouchDisInvTriggers"); string[] triggers = Item.InnerText.Split(','); @@ -3747,6 +3786,7 @@ namespace DS4Windows useTPforControls[device] = false; useSAforMouse[device] = false; sATriggers[device] = string.Empty; + sATriggerCond[device] = true; touchDisInvertTriggers[device] = new int[1] { -1 }; lsCurve[device] = rsCurve[device] = 0; gyroSensitivity[device] = 100; diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 68e5189..e9c6dbe 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -398,7 +398,7 @@ namespace DS4Windows } if (btnStartStop.Enabled && start) - TaskRunner.Delay(10).ContinueWith((t) => this.BeginInvoke((System.Action)(() => BtnStartStop_Clicked()))); + TaskRunner.Delay(50).ContinueWith((t) => this.BeginInvoke((System.Action)(() => BtnStartStop_Clicked()))); } private void populateHoverTextDict() diff --git a/DS4Windows/DS4Forms/Options.Designer.cs b/DS4Windows/DS4Forms/Options.Designer.cs index 6c5bedb..cd9742a 100644 --- a/DS4Windows/DS4Forms/Options.Designer.cs +++ b/DS4Windows/DS4Forms/Options.Designer.cs @@ -386,6 +386,8 @@ this.optionsTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.shareTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.psTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.triggerCondAndCombo = new System.Windows.Forms.ComboBox(); + this.label26 = new System.Windows.Forms.Label(); this.advColorDialog = new DS4Windows.AdvancedColorDialog(); ((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit(); @@ -3360,8 +3362,8 @@ this.gBGyro.BackColor = System.Drawing.SystemColors.Control; this.gBGyro.Controls.Add(this.rBSAControls); this.gBGyro.Controls.Add(this.rBSAMouse); - this.gBGyro.Controls.Add(this.fLPTiltControls); this.gBGyro.Controls.Add(this.pnlSAMouse); + this.gBGyro.Controls.Add(this.fLPTiltControls); resources.ApplyResources(this.gBGyro, "gBGyro"); this.gBGyro.Name = "gBGyro"; this.gBGyro.TabStop = false; @@ -3384,6 +3386,8 @@ // // pnlSAMouse // + this.pnlSAMouse.Controls.Add(this.label26); + this.pnlSAMouse.Controls.Add(this.triggerCondAndCombo); this.pnlSAMouse.Controls.Add(this.cBGyroMouseXAxis); this.pnlSAMouse.Controls.Add(this.label16); this.pnlSAMouse.Controls.Add(this.lbGyroSmooth); @@ -4106,6 +4110,21 @@ resources.ApplyResources(this.psTouchInvStripMenuItem, "psTouchInvStripMenuItem"); this.psTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); // + // triggerCondAndCombo + // + this.triggerCondAndCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.triggerCondAndCombo.FormattingEnabled = true; + this.triggerCondAndCombo.Items.AddRange(new object[] { + resources.GetString("triggerCondAndCombo.Items"), + resources.GetString("triggerCondAndCombo.Items1")}); + resources.ApplyResources(this.triggerCondAndCombo, "triggerCondAndCombo"); + this.triggerCondAndCombo.Name = "triggerCondAndCombo"; + // + // label26 + // + resources.ApplyResources(this.label26, "label26"); + this.label26.Name = "label26"; + // // Options // resources.ApplyResources(this, "$this"); @@ -4593,5 +4612,7 @@ private System.Windows.Forms.Label trackFrictionLb; private System.Windows.Forms.NumericUpDown trackFrictionNUD; private System.Windows.Forms.CheckBox trackballCk; + private System.Windows.Forms.Label label26; + private System.Windows.Forms.ComboBox triggerCondAndCombo; } } \ No newline at end of file diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 6fe5f3d..7c9aa91 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -126,6 +126,8 @@ namespace DS4Windows sixaxisTimer.Tick += ControllerReadout_Tick; sixaxisTimer.Interval = 1000 / 60; + triggerCondAndCombo.SelectedIndexChanged += TriggerCondAndCombo_SelectedIndexChanged; + bnGyroZN.Text = Properties.Resources.TiltUp; bnGyroZP.Text = Properties.Resources.TiltDown; bnGyroXP.Text = Properties.Resources.TiltLeft; @@ -142,6 +144,15 @@ namespace DS4Windows populateHoverLabelDict(); } + private void TriggerCondAndCombo_SelectedIndexChanged(object sender, EventArgs e) + { + if (!loading) + { + string temp = triggerCondAndCombo.SelectedItem.ToString().ToLower(); + SetSaTriggerCond(device, triggerCondAndCombo.SelectedItem.ToString().ToLower()); + } + } + public void SetFlowAutoScroll() { fLPSettings.AutoScroll = false; @@ -706,6 +717,7 @@ namespace DS4Windows cBGyroSmooth.Checked = nUDGyroSmoothWeight.Enabled = GyroSmoothing[device]; nUDGyroSmoothWeight.Value = (decimal)(GyroSmoothingWeight[device]); cBGyroMouseXAxis.SelectedIndex = GyroMouseHorizontalAxis[device]; + triggerCondAndCombo.SelectedIndex = SATriggerCond[device] ? 0 : 1; } else { @@ -823,6 +835,7 @@ namespace DS4Windows cBGyroSmooth.Checked = false; nUDGyroSmoothWeight.Value = 0.5m; cBGyroMouseXAxis.SelectedIndex = 0; + triggerCondAndCombo.SelectedIndex = 0; Set(); } @@ -1342,6 +1355,7 @@ namespace DS4Windows ints.Add(-1); SATriggers[device] = string.Join(",", ints); + SetSaTriggerCond(device, triggerCondAndCombo.SelectedItem.ToString().ToLower()); ints.Clear(); for (int i = 0, trigLen = cMTouchDisableInvert.Items.Count; i < trigLen; i++) diff --git a/DS4Windows/DS4Forms/Options.resx b/DS4Windows/DS4Forms/Options.resx index 5ab8b82..dc50f18 100644 --- a/DS4Windows/DS4Forms/Options.resx +++ b/DS4Windows/DS4Forms/Options.resx @@ -4058,7 +4058,7 @@ with profile 7 - 6, 51 + 4, 43 271, 167 @@ -4076,7 +4076,7 @@ with profile gBGyro - 2 + 3 True @@ -7717,6 +7717,63 @@ with profile 1 + + True + + + NoControl + + + 184, 43 + + + 59, 13 + + + 273 + + + Eval Cond: + + + label26 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pnlSAMouse + + + 0 + + + And + + + Or + + + 165, 67 + + + 73, 21 + + + 272 + + + triggerCondAndCombo + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pnlSAMouse + + + 1 + Yaw @@ -7724,7 +7781,7 @@ with profile Roll - 170, 93 + 170, 114 74, 21 @@ -7742,7 +7799,7 @@ with profile pnlSAMouse - 0 + 2 True @@ -7751,7 +7808,7 @@ with profile NoControl - 167, 74 + 167, 95 39, 13 @@ -7772,7 +7829,7 @@ with profile pnlSAMouse - 1 + 3 True @@ -7802,7 +7859,7 @@ with profile pnlSAMouse - 2 + 4 True @@ -7832,7 +7889,7 @@ with profile pnlSAMouse - 3 + 5 True @@ -7862,7 +7919,7 @@ with profile pnlSAMouse - 4 + 6 False @@ -7886,7 +7943,7 @@ with profile pnlSAMouse - 5 + 7 True @@ -7916,7 +7973,7 @@ with profile pnlSAMouse - 6 + 8 96, 93 @@ -7937,7 +7994,7 @@ with profile pnlSAMouse - 7 + 9 True @@ -7967,7 +8024,7 @@ with profile pnlSAMouse - 8 + 10 True @@ -8000,7 +8057,7 @@ with profile pnlSAMouse - 9 + 11 True @@ -8033,7 +8090,7 @@ with profile pnlSAMouse - 10 + 12 True @@ -8066,7 +8123,7 @@ with profile pnlSAMouse - 11 + 13 True @@ -8099,7 +8156,7 @@ with profile pnlSAMouse - 12 + 14 True @@ -8132,7 +8189,7 @@ with profile pnlSAMouse - 13 + 15 NoControl @@ -8162,7 +8219,7 @@ with profile pnlSAMouse - 14 + 16 96, 67 @@ -8183,7 +8240,7 @@ with profile pnlSAMouse - 15 + 17 True @@ -8216,7 +8273,7 @@ with profile pnlSAMouse - 16 + 18 6, 43 @@ -8240,7 +8297,7 @@ with profile gBGyro - 3 + 2 3, 253 @@ -8914,6 +8971,9 @@ with profile 1011, 481 + + NoControl + 4, 4, 4, 4 @@ -9332,7 +9392,7 @@ with profile advColorDialog - DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null + DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.8.0, Culture=neutral, PublicKeyToken=null Options From 3bbdbe3a0f312899c2937a98f53c62ddfb2b9e9d Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 1 Oct 2018 19:18:52 -0500 Subject: [PATCH 8/8] Attempt to reset KB+M controls after unplugging controller Related to issue #438. --- DS4Windows/DS4Control/ControlService.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 933b78f..31217d0 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -1020,6 +1020,13 @@ namespace DS4Windows LogDebug("X360 Controller # " + xinputIndex + " unplugged"); } + // Use Task to reset device synth state and commit it + Task.Run(() => + { + Mapping.deviceState[ind].SavePrevious(true); + Mapping.Commit(ind); + }).Wait(); + string removed = Properties.Resources.ControllerWasRemoved.Replace("*Mac address*", (ind + 1).ToString()); if (device.getBattery() <= 20 && device.getConnectionType() == ConnectionType.BT && !device.isCharging()) @@ -1163,14 +1170,6 @@ namespace DS4Windows } } - /*if (_udpServer != null) - { - DualShockPadMeta padDetail = new DualShockPadMeta(); - GetPadDetailForIdx(ind, ref padDetail); - _udpServer.NewReportIncoming(ref padDetail, CurrentState[ind]); - } - */ - // Output any synthetic events. Mapping.Commit(ind);