From 3ae386cb7c21812d8a536eb8308f5a3d00a9a111 Mon Sep 17 00:00:00 2001 From: Yuki-nyan Date: Sat, 23 Jun 2018 22:04:29 +0100 Subject: [PATCH 01/17] Add support for the Nacon Revolution Pro Controller 2 & disable SixAxis calibrations for Nacon controllers as a preliminary fix for broken support. --- DS4Windows/DS4Library/DS4Device.cs | 8 +++++++- DS4Windows/DS4Library/DS4Devices.cs | 1 + DS4Windows/DS4Library/DS4Sixaxis.cs | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 9bd6b02..9765dd9 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -150,6 +150,7 @@ namespace DS4Windows public DateTime lastActive = DateTime.UtcNow; public DateTime firstActive = DateTime.UtcNow; private bool charging; + private bool isNacon = false; private bool outputRumble = false; private int warnInterval = WARN_INTERVAL_USB; public int getWarnInterval() @@ -428,6 +429,11 @@ namespace DS4Windows micAudio = new DS4Audio(DS4Library.CoreAudio.DataFlow.Capture); } + else if (tempAttr.VendorId == 0x146B) + { + isNacon = true; + } + synced = true; } else @@ -971,7 +977,7 @@ namespace DS4Windows pbAccel[i-6] = pbInput[i]; } } - sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime); + sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime, isNacon); /* Debug output of incoming HID data: if (cState.L2 == 0xff && cState.R2 == 0xff) diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index d0e7199..ada6904 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -40,6 +40,7 @@ namespace DS4Windows new VidPidInfo(SONY_VID, 0x09CC), new VidPidInfo(RAZER_VID, 0x1000), new VidPidInfo(NACON_VID, 0x0D01), + new VidPidInfo(NACON_VID, 0x0D02), new VidPidInfo(HORI_VID, 0x00EE), // Hori PS4 Mini Wired Gamepad new VidPidInfo(0x7545, 0x0104) }; diff --git a/DS4Windows/DS4Library/DS4Sixaxis.cs b/DS4Windows/DS4Library/DS4Sixaxis.cs index 15b4135..c44e4a2 100644 --- a/DS4Windows/DS4Library/DS4Sixaxis.cs +++ b/DS4Windows/DS4Library/DS4Sixaxis.cs @@ -218,7 +218,7 @@ namespace DS4Windows } public void handleSixaxis(byte[] gyro, byte[] accel, DS4State state, - double elapsedDelta) + double elapsedDelta, bool disableCalibs) { int currentYaw = (short)((ushort)(gyro[3] << 8) | gyro[2]); int currentPitch = (short)((ushort)(gyro[1] << 8) | gyro[0]); @@ -227,7 +227,10 @@ namespace DS4Windows int AccelY = (short)((ushort)(accel[3] << 8) | accel[2]); int AccelZ = (short)((ushort)(accel[5] << 8) | accel[4]); - applyCalibs(ref currentYaw, ref currentPitch, ref currentRoll, ref AccelX, ref AccelY, ref AccelZ); + if (!disableCalibs) + { + applyCalibs(ref currentYaw, ref currentPitch, ref currentRoll, ref AccelX, ref AccelY, ref AccelZ); + } SixAxisEventArgs args = null; if (AccelX != 0 || AccelY != 0 || AccelZ != 0) From 07fe0ab21679888e281da54bdd037d6a1e3e8f76 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sun, 24 Jun 2018 21:26:52 -0500 Subject: [PATCH 02/17] Updated links to alternative builds --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d01c428..c513e0e 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,12 @@ You can find the latest and older versions [here](https://github.com/Ryochan7/DS UdpServer builds for using Gyro motion controls in Cemu. -http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.120_UdpServer_x64.zip -http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.120_ViGEm_UdpServer_x64.zip +http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.121_UdpServer_x64.zip +http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.121_ViGEm_UdpServer_x64.zip ViGEm build. -http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.120_ViGEm_x64.zip +http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.121_ViGEm_x64.zip This project is a fork of the work of Jays2Kings. You can find the old project website at [ds4windows.com](http://ds4windows.com). From 9c6e99ce6c195fd6fdcdfaec8cea6e010e5ae9ad Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 6 Jul 2018 20:09:17 -0500 Subject: [PATCH 03/17] Carry over enhanced precision curve changes to RS New points were only used for LS before --- DS4Windows/DS4Control/Mapping.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 2c6c94d..e2a5146 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -839,28 +839,28 @@ namespace DS4Windows if (absX <= 0.4) { - outputX = 0.414 * absX; + outputX = 0.43 * absX; } else if (absX <= 0.75) { - outputX = absX - 0.24; + outputX = absX - 0.228; } else if (absX > 0.75) { - outputX = (absX * 1.9376) - 0.9376; + outputX = (absX * 1.912) - 0.912; } if (absY <= 0.4) { - outputY = 0.414 * absY; + outputY = 0.43 * absY; } else if (absY <= 0.75) { - outputY = absY - 0.24; + outputY = absY - 0.228; } else if (absY > 0.75) { - outputY = (absY * 1.9376) - 0.9376; + outputY = (absY * 1.912) - 0.912; } dState.RX = (byte)(outputX * signX * 127.5 + 127.5); From cfa2bea4be9c2d03dca9713eaddbde7b46121e12 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 10 Jul 2018 00:46:25 -0500 Subject: [PATCH 04/17] Minor tweak for skipping calibration that .NET likes better Related to issue #330. --- DS4Windows/DS4Library/DS4Device.cs | 10 ++++++---- DS4Windows/DS4Library/DS4Sixaxis.cs | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 9765dd9..daae783 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -150,7 +150,6 @@ namespace DS4Windows public DateTime lastActive = DateTime.UtcNow; public DateTime firstActive = DateTime.UtcNow; private bool charging; - private bool isNacon = false; private bool outputRumble = false; private int warnInterval = WARN_INTERVAL_USB; public int getWarnInterval() @@ -414,6 +413,7 @@ namespace DS4Windows hDevice = hidDevice; conType = HidConnectionType(hDevice); Mac = hDevice.readSerial(); + bool runCalib = true; if (conType == ConnectionType.USB || conType == ConnectionType.SONYWA) { inputReport = new byte[64]; @@ -431,7 +431,7 @@ namespace DS4Windows else if (tempAttr.VendorId == 0x146B) { - isNacon = true; + runCalib = false; } synced = true; @@ -457,7 +457,8 @@ namespace DS4Windows touchpad = new DS4Touchpad(); sixAxis = new DS4SixAxis(); Crc32Algorithm.InitializeTable(DefaultPolynomial); - refreshCalibration(); + if (runCalib) + refreshCalibration(); if (!hDevice.IsFileStreamOpen()) { @@ -977,7 +978,8 @@ namespace DS4Windows pbAccel[i-6] = pbInput[i]; } } - sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime, isNacon); + + sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime); /* Debug output of incoming HID data: if (cState.L2 == 0xff && cState.R2 == 0xff) diff --git a/DS4Windows/DS4Library/DS4Sixaxis.cs b/DS4Windows/DS4Library/DS4Sixaxis.cs index c44e4a2..62353b5 100644 --- a/DS4Windows/DS4Library/DS4Sixaxis.cs +++ b/DS4Windows/DS4Library/DS4Sixaxis.cs @@ -115,6 +115,7 @@ namespace DS4Windows private CalibData[] calibrationData = new CalibData[6] { new CalibData(), new CalibData(), new CalibData(), new CalibData(), new CalibData(), new CalibData() }; + private bool calibrationDone = false; public DS4SixAxis() { @@ -187,6 +188,8 @@ namespace DS4Windows calibrationData[5].bias = accelZPlus - accelRange / 2; calibrationData[5].sensNumer = 2 * SixAxis.ACC_RES_PER_G; calibrationData[5].sensDenom = accelRange; + + calibrationDone = true; } private void applyCalibs(ref int yaw, ref int pitch, ref int roll, @@ -218,7 +221,7 @@ namespace DS4Windows } public void handleSixaxis(byte[] gyro, byte[] accel, DS4State state, - double elapsedDelta, bool disableCalibs) + double elapsedDelta) { int currentYaw = (short)((ushort)(gyro[3] << 8) | gyro[2]); int currentPitch = (short)((ushort)(gyro[1] << 8) | gyro[0]); @@ -227,10 +230,8 @@ namespace DS4Windows int AccelY = (short)((ushort)(accel[3] << 8) | accel[2]); int AccelZ = (short)((ushort)(accel[5] << 8) | accel[4]); - if (!disableCalibs) - { + if (calibrationDone) applyCalibs(ref currentYaw, ref currentPitch, ref currentRoll, ref AccelX, ref AccelY, ref AccelZ); - } SixAxisEventArgs args = null; if (AccelX != 0 || AccelY != 0 || AccelZ != 0) From 1171a56a6b5b0e7384dc5e4eb33fb66545cdaa50 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 10 Jul 2018 00:57:55 -0500 Subject: [PATCH 05/17] Make sure calib routine can be skipped on update serial routine Might not be needed --- DS4Windows/DS4Library/DS4Device.cs | 7 ++++++- DS4Windows/DS4Library/DS4Devices.cs | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index daae783..3a09e05 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -407,13 +407,18 @@ namespace DS4Windows private Thread timeoutCheckThread = null; private bool timeoutExecuted = false; private bool timeoutEvent = false; + private bool runCalib; + public bool ShouldRunCalib() + { + return runCalib; + } public DS4Device(HidDevice hidDevice) { hDevice = hidDevice; conType = HidConnectionType(hDevice); Mac = hDevice.readSerial(); - bool runCalib = true; + runCalib = true; if (conType == ConnectionType.USB || conType == ConnectionType.SONYWA) { inputReport = new byte[64]; diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index ada6904..f570dce 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -234,7 +234,8 @@ namespace DS4Windows deviceSerials.Add(serial); } - device.refreshCalibration(); + if (device.ShouldRunCalib()) + device.refreshCalibration(); } } } From f44cc216882ecec5c3f004fcb89ebfeefb318f16 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 10 Jul 2018 01:18:27 -0500 Subject: [PATCH 06/17] Minor tweak --- DS4Windows/DS4Library/DS4Device.cs | 9 ++++----- DS4Windows/DS4Library/DS4Devices.cs | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 3a09e05..b52444b 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -433,7 +433,6 @@ namespace DS4Windows audio = new DS4Audio(); micAudio = new DS4Audio(DS4Library.CoreAudio.DataFlow.Capture); } - else if (tempAttr.VendorId == 0x146B) { runCalib = false; @@ -463,7 +462,7 @@ namespace DS4Windows sixAxis = new DS4SixAxis(); Crc32Algorithm.InitializeTable(DefaultPolynomial); if (runCalib) - refreshCalibration(); + RefreshCalibration(); if (!hDevice.IsFileStreamOpen()) { @@ -473,7 +472,7 @@ namespace DS4Windows sendOutputReport(true, true); // initialize the output report } - private void timeoutTestThread() + private void TimeoutTestThread() { while (!timeoutExecuted) { @@ -492,7 +491,7 @@ namespace DS4Windows const int DS4_FEATURE_REPORT_5_LEN = 41; const int DS4_FEATURE_REPORT_5_CRC32_POS = DS4_FEATURE_REPORT_5_LEN - 4; - public void refreshCalibration() + public void RefreshCalibration() { byte[] calibration = new byte[41]; calibration[0] = conType == ConnectionType.BT ? (byte)0x05 : (byte)0x02; @@ -543,7 +542,7 @@ namespace DS4Windows ds4Output.IsBackground = true; ds4Output.Start(); - timeoutCheckThread = new Thread(timeoutTestThread); + timeoutCheckThread = new Thread(TimeoutTestThread); timeoutCheckThread.Priority = ThreadPriority.BelowNormal; timeoutCheckThread.Name = "DS4 Timeout thread: " + Mac; timeoutCheckThread.IsBackground = true; diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index f570dce..e3a87f6 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -235,7 +235,7 @@ namespace DS4Windows } if (device.ShouldRunCalib()) - device.refreshCalibration(); + device.RefreshCalibration(); } } } From bf9f476be31789dbbedb834a883968bfba48d644 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 16 Jul 2018 00:21:34 -0500 Subject: [PATCH 07/17] Added placeholder routine to purge old HidGuardian whitelist entries. Have not decided whether this is truly needed so it is not used --- DS4Windows/DS4Control/ControlService.cs | 30 +++++++++++++++++++++++-- DS4Windows/DS4Forms/DS4Form.cs | 2 +- DS4Windows/Program.cs | 3 ++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 3c4ff38..8c6d7fc 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -7,7 +7,8 @@ using System.Media; using System.Threading.Tasks; using static DS4Windows.Global; using System.Threading; -using Registry = Microsoft.Win32.Registry; +using System.Diagnostics; +using Microsoft.Win32; namespace DS4Windows { @@ -83,7 +84,32 @@ namespace DS4Windows } } - public void createHidGuardKey() + public void ScanPurgeHidGuard() + { + RegistryKey tempkey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist"); + string[] subkeys = tempkey.GetSubKeyNames(); + bool processExists = false; + for (int ind = 0, arlen = subkeys.Length; ind < arlen; ind++) + { + processExists = true; + try + { + Process.GetProcessById(Convert.ToInt32(subkeys[ind])); + } + catch { processExists = false; } + + if (!processExists) + { + try + { + Registry.LocalMachine.DeleteSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist\" + subkeys[ind]); + } + catch { } + } + } + } + + public void CreateHidGuardKey() { try { diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 25359e5..5bbd95e 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -2463,7 +2463,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question { Registry.LocalMachine.DeleteSubKeyTree(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist"); Log.LogToGui("Cleared HidGuardian Whitelist", false); - Program.rootHub.createHidGuardKey(); + Program.rootHub.CreateHidGuardKey(); } catch { } } diff --git a/DS4Windows/Program.cs b/DS4Windows/Program.cs index 789393f..b9254bb 100644 --- a/DS4Windows/Program.cs +++ b/DS4Windows/Program.cs @@ -103,7 +103,8 @@ namespace DS4Windows //if (mutex.WaitOne(TimeSpan.Zero, true)) //{ createControlService(); - rootHub.createHidGuardKey(); + //rootHub.ScanPurgeHidGuard(); + rootHub.CreateHidGuardKey(); //rootHub = new ControlService(); Application.EnableVisualStyles(); Application.Run(new DS4Form(args)); From c0b958b43afec87adc09c5426d06d826c3935bd0 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 16 Jul 2018 02:42:08 -0500 Subject: [PATCH 08/17] Updated target framework to .NET 4.6.1 Hopefully this change will not cause problems for some users --- DS4Windows/DS4Windows.csproj | 2 +- DS4Windows/Properties/Settings.Designer.cs | 2 +- DS4Windows/app.config | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index 7e06a21..fdc34aa 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -9,7 +9,7 @@ Properties DS4Windows DS4Windows - v4.5.2 + v4.6.1 512 true diff --git a/DS4Windows/Properties/Settings.Designer.cs b/DS4Windows/Properties/Settings.Designer.cs index ac3f6fb..8249a9b 100644 --- a/DS4Windows/Properties/Settings.Designer.cs +++ b/DS4Windows/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace DS4Windows.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/DS4Windows/app.config b/DS4Windows/app.config index 4b7b07e..d23be82 100644 --- a/DS4Windows/app.config +++ b/DS4Windows/app.config @@ -1,7 +1,7 @@ - + From d246a5d9ee3be400f5c3c3f3d2b7dcc990b72483 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 16 Jul 2018 02:42:40 -0500 Subject: [PATCH 09/17] Updated TODO file --- TODO.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/TODO.md b/TODO.md index ae89e3e..42660e0 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,6 @@ # TODO * Perform some final cleanup and release version 1.5 -* ~~Attempt to work out BT disconnect issues by looking at older versions~~ * Attempt to remove reliance on the main thread when disconnecting a device. Currently used to delay hotplug routine * Look into distributing profile properties around various objects @@ -10,6 +9,3 @@ It will complicate the architecture a little bit but hopefully any speed difference will make up for it. * Remove old welcome dialog and make new driver installer executable. Use newer standards (WPF) and bundle app with DS4Windows -* ~~Attempt to no longer disable service when changing dinput only option -in profiles -* ~~Update Task Scheduler to latest version~~ From f643c95463fb9de320502568b39c4683c0ff422f Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 16 Jul 2018 02:45:10 -0500 Subject: [PATCH 10/17] Updated README regarding new .NET target framework version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c513e0e..d176060 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ website at [ds4windows.com](http://ds4windows.com). ## Requirements -- Windows 7 or newer -- [Microsoft .NET 4.5.2 or higher (needed to unzip the driver and for macros to work properly)](http://www.microsoft.com/en-us/download/details.aspx?id=42642) +- Windows 7 SP1 or newer +- [Microsoft .NET 4.6.1 or higher (needed to unzip the driver and for macros to work properly)](https://www.microsoft.com/en-us/download/details.aspx?id=49982) - SCP Virtual Bus Driver (Downloaded & Installed with DS4Windows) - Microsoft 360 Driver (link inside DS4Windows, already installed on Windows 7 SP1 and higher or if you've used a 360 controller before) - Sony DualShock 4 (This should be obvious) From f686b9711e5d80837499b7a6b6b5e961c44ceb28 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 16 Jul 2018 04:16:58 -0500 Subject: [PATCH 11/17] Loosened enhanced precision curves more --- DS4Windows/DS4Control/Mapping.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index e2a5146..c751a6e 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -779,28 +779,28 @@ namespace DS4Windows if (absX <= 0.4) { - outputX = 0.43 * absX; + outputX = 0.45 * absX; } else if (absX <= 0.75) { - outputX = absX - 0.228; + outputX = absX - 0.22; } else if (absX > 0.75) { - outputX = (absX * 1.912) - 0.912; + outputX = (absX * 1.88) - 0.88; } if (absY <= 0.4) { - outputY = 0.43 * absY; + outputY = 0.45 * absY; } else if (absY <= 0.75) { - outputY = absY - 0.228; + outputY = absY - 0.22; } else if (absY > 0.75) { - outputY = (absY * 1.912) - 0.912; + outputY = (absY * 1.88) - 0.88; } dState.LX = (byte)(outputX * signX * 127.5 + 127.5); @@ -839,28 +839,28 @@ namespace DS4Windows if (absX <= 0.4) { - outputX = 0.43 * absX; + outputX = 0.45 * absX; } else if (absX <= 0.75) { - outputX = absX - 0.228; + outputX = absX - 0.22; } else if (absX > 0.75) { - outputX = (absX * 1.912) - 0.912; + outputX = (absX * 1.88) - 0.88; } if (absY <= 0.4) { - outputY = 0.43 * absY; + outputY = 0.45 * absY; } else if (absY <= 0.75) { - outputY = absY - 0.228; + outputY = absY - 0.22; } else if (absY > 0.75) { - outputY = (absY * 1.912) - 0.912; + outputY = (absY * 1.88) - 0.88; } dState.RX = (byte)(outputX * signX * 127.5 + 127.5); From a7b5b2ff35ef815961fba71800c770e506b6e232 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 16 Jul 2018 12:21:54 -0500 Subject: [PATCH 12/17] Enabled HidGuardian whitelist scan --- DS4Windows/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DS4Windows/Program.cs b/DS4Windows/Program.cs index b9254bb..a957344 100644 --- a/DS4Windows/Program.cs +++ b/DS4Windows/Program.cs @@ -103,7 +103,7 @@ namespace DS4Windows //if (mutex.WaitOne(TimeSpan.Zero, true)) //{ createControlService(); - //rootHub.ScanPurgeHidGuard(); + rootHub.ScanPurgeHidGuard(); rootHub.CreateHidGuardKey(); //rootHub = new ControlService(); Application.EnableVisualStyles(); From a3943728e37de931c01d74f3522659a6f6a1256f Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 16 Jul 2018 17:29:05 -0500 Subject: [PATCH 13/17] Trimmed WndProc method --- DS4Windows/DS4Forms/DS4Form.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 5bbd95e..f01d2c8 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -991,15 +991,16 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question private bool inHotPlug = false; private int hotplugCounter = 0; private object hotplugCounterLock = new object(); + private const int DBT_DEVNODES_CHANGED = 0x0007; protected override void WndProc(ref Message m) { - try + if (m.Msg == ScpDevice.WM_DEVICECHANGE) { - if (m.Msg == ScpDevice.WM_DEVICECHANGE) + if (runHotPlug) { - if (runHotPlug) + Int32 Type = m.WParam.ToInt32(); + if (Type == DBT_DEVNODES_CHANGED) { - Int32 Type = m.WParam.ToInt32(); lock (hotplugCounterLock) { hotplugCounter++; @@ -1009,19 +1010,18 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question if (!inHotPlug) { inHotPlug = true; - TaskRunner.Run(() => { Thread.Sleep(1500); InnerHotplug2(uiContext); }); + TaskRunner.Run(() => { Thread.Sleep(1500); InnerHotplug2(uiContext); }); } } } } - catch { } + if (m.Msg == WM_QUERYENDSESSION) systemShutdown = true; // If this is WM_QUERYENDSESSION, the closing event should be // raised in the base WndProc. - try { base.WndProc(ref m); } - catch { } + base.WndProc(ref m); } private void InnerHotplug2(SynchronizationContext uiContext) From add73e0b4983821099f3e26d545ad3bc3bb9c96c Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 16 Jul 2018 19:20:28 -0500 Subject: [PATCH 14/17] Removed unused Settings class --- DS4Windows/DS4Forms/Settings.cs | 28 ---------------------------- DS4Windows/DS4Windows.csproj | 1 - 2 files changed, 29 deletions(-) delete mode 100644 DS4Windows/DS4Forms/Settings.cs diff --git a/DS4Windows/DS4Forms/Settings.cs b/DS4Windows/DS4Forms/Settings.cs deleted file mode 100644 index ac0570e..0000000 --- a/DS4Windows/DS4Forms/Settings.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace DS4Windows.Properties { - - - // This class allows you to handle specific events on the settings class: - // The SettingChanging event is raised before a setting's value is changed. - // The PropertyChanged event is raised after a setting's value is changed. - // The SettingsLoaded event is raised after the setting values are loaded. - // The SettingsSaving event is raised before the setting values are saved. - internal sealed partial class Settings { - - public Settings() { - // // To add event handlers for saving and changing settings, uncomment the lines below: - // - // this.SettingChanging += this.SettingChangingEventHandler; - // - // this.SettingsSaving += this.SettingsSavingEventHandler; - // - } - - private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { - // Add code to handle the SettingChangingEvent event here. - } - - private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { - // Add code to handle the SettingsSaving event here. - } - } -} diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index fdc34aa..f027649 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -229,7 +229,6 @@ SaveWhere.cs - Form From f641b7f11ce86e988518e169ba5776a5252bea2b Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 17 Jul 2018 02:30:03 -0500 Subject: [PATCH 15/17] Removed unused component --- DS4Windows/DS4Control/ScpHub.Designer.cs | 36 ---------- DS4Windows/DS4Control/ScpHub.cs | 87 ------------------------ DS4Windows/DS4Windows.csproj | 6 -- 3 files changed, 129 deletions(-) delete mode 100644 DS4Windows/DS4Control/ScpHub.Designer.cs delete mode 100644 DS4Windows/DS4Control/ScpHub.cs diff --git a/DS4Windows/DS4Control/ScpHub.Designer.cs b/DS4Windows/DS4Control/ScpHub.Designer.cs deleted file mode 100644 index ed08d0c..0000000 --- a/DS4Windows/DS4Control/ScpHub.Designer.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace DS4Windows -{ - partial class ScpHub - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - } - - #endregion - } -} diff --git a/DS4Windows/DS4Control/ScpHub.cs b/DS4Windows/DS4Control/ScpHub.cs deleted file mode 100644 index fd7031a..0000000 --- a/DS4Windows/DS4Control/ScpHub.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.ComponentModel; - -namespace DS4Windows -{ - public partial class ScpHub : Component - { - protected IntPtr m_Reference = IntPtr.Zero; - protected volatile Boolean m_Started = false; - - public event EventHandler Debug = null; - - public event EventHandler Report = null; - - protected virtual Boolean LogDebug(String Data, bool warning) - { - DebugEventArgs args = new DebugEventArgs(Data, warning); - - On_Debug(this, args); - - return true; - } - - public Boolean Active - { - get { return m_Started; } - } - - - public ScpHub() - { - InitializeComponent(); - } - - public ScpHub(IContainer container) - { - container.Add(this); - - InitializeComponent(); - } - - - public virtual Boolean Open() - { - return true; - } - - public virtual Boolean Start() - { - return m_Started; - } - - public virtual Boolean Stop() - { - return !m_Started; - } - - public virtual Boolean Close() - { - if (m_Reference != IntPtr.Zero) ScpDevice.UnregisterNotify(m_Reference); - - return !m_Started; - } - - - public virtual Boolean Suspend() - { - return true; - } - - public virtual Boolean Resume() - { - return true; - } - - protected virtual void On_Debug(object sender, DebugEventArgs e) - { - if (Debug != null) Debug(sender, e); - } - - - protected virtual void On_Report(object sender, ReportEventArgs e) - { - if (Report != null) Report(sender, e); - } - } -} diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index f027649..43bdf25 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -151,12 +151,6 @@ ScpDevice.cs - - Component - - - ScpHub.cs - Component From 2cc8236e02ff9975781b6dc9e952cde75f23c00b Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 17 Jul 2018 04:07:32 -0500 Subject: [PATCH 16/17] Removed an unused control --- DS4Windows/DS4Forms/AdvancedComboBox.cs | 93 ------------------------- DS4Windows/DS4Windows.csproj | 1 - 2 files changed, 94 deletions(-) delete mode 100644 DS4Windows/DS4Forms/AdvancedComboBox.cs diff --git a/DS4Windows/DS4Forms/AdvancedComboBox.cs b/DS4Windows/DS4Forms/AdvancedComboBox.cs deleted file mode 100644 index 1731713..0000000 --- a/DS4Windows/DS4Forms/AdvancedComboBox.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace ScpServer -{ - [System.ComponentModel.DesignerCategory("")] - public class AdvancedComboBox : ComboBox - { - public Label Label { get; set; } - - public AdvancedComboBox() - { - base.Visible = false; - Label = new Label(); - Label.Tag = this; - Label.ForeColor = Color.Blue; - Label.TextAlign = ContentAlignment.MiddleCenter; - Label.BackColor = Color.Transparent; - Label.MouseDown += Label_MouseDown; - } - - public Color Color - { - get - { - return Label.ForeColor; - } - set - { - Label.ForeColor = value; - } - } - - public new bool Visible - { - get - { - return Label.Visible; - } - set - { - Label.Visible = value; - } - } - - private void Label_MouseDown(object sender, MouseEventArgs e) - { - if (e.Button == System.Windows.Forms.MouseButtons.Left) - DroppedDown = true; - } - - protected override void OnParentChanged(EventArgs e) - { - base.OnParentChanged(e); - - if (Parent != null) - { - Label.Location = this.Location; - Label.Size = this.Size; - Label.Dock = this.Dock; - Label.Anchor = this.Anchor; - Label.Enabled = this.Enabled; - Label.Visible = this.Visible; - Label.RightToLeft = this.RightToLeft; - Label.Font = this.Font; - Label.Text = this.Text - .Replace("Right Click", "Right-Click") - .Replace(" Button", string.Empty) - .Replace("Left ", string.Empty) - .Replace("Right ", string.Empty); - Label.TabStop = this.TabStop; - Label.TabIndex = this.TabIndex; - } - Label.Parent = this.Parent; - } - - protected override void OnSelectedIndexChanged(EventArgs e) - { - base.OnSelectedIndexChanged(e); - - Label.Text = this.Text - .Replace("Right Click", "Right-Click") - .Replace(" Button", string.Empty) - .Replace("Left ", string.Empty) - .Replace("Right ", string.Empty); - } - - } -} diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index 43bdf25..cae3727 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -173,7 +173,6 @@ - Form From b8d60e8aa6961b0cd926faa079a4a0ea07764ebc Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 17 Jul 2018 18:11:32 -0500 Subject: [PATCH 17/17] Change warning level for build settings It seems to matter in the final build even though it seems like it should not --- DS4Windows/DS4Windows.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index cae3727..e4141a1 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -94,6 +94,7 @@ 6 false true + 1 true @@ -118,6 +119,7 @@ 6 On true + 1