From 8396d07fc3bbd8eae772e937d4492c9c4da8531c Mon Sep 17 00:00:00 2001 From: Yohoki <44595371+Yohoki@users.noreply.github.com> Date: Thu, 4 Nov 2021 23:24:03 -0500 Subject: [PATCH] Add hidhide whitelist function D4W now adds itself to hidhide's whitelist if it is installed. It will add a custom exe name if one is used. --- DS4Windows/DS4Library/DS4Devices.cs | 3 ++- DS4Windows/DS4Library/YohokiUtils.cs | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index 73dc742432..6602b296ff 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -289,9 +289,10 @@ public static void findControllers() { try { + YohokiUtils.AddDS4WindowstoHidHideWhiteList(); // Add DS4W to Whitelist before attempting to add controllers. YohokiUtils.AddHidHideHID(hDevice.DevicePath); // Add DS4HID to HidHide list YohokiUtils.AddHidHideHID(hDevice.ParentPath); // Add BTAdapter connection to HidHide as well (HidHideClient also does this when adding BT devices) - YohokiUtils.NullPrettyHid(); //Meh, Why Not. Prob not important, but might as well just in case. + YohokiUtils.NullHidHideArguments(); //Meh, Why Not. Prob not important, but might as well just in case. } catch { } } diff --git a/DS4Windows/DS4Library/YohokiUtils.cs b/DS4Windows/DS4Library/YohokiUtils.cs index 1e764da128..1d2cc6a7f2 100644 --- a/DS4Windows/DS4Library/YohokiUtils.cs +++ b/DS4Windows/DS4Library/YohokiUtils.cs @@ -16,19 +16,19 @@ class YohokiUtils private static readonly Regex RawUSBHIDPattern = new(@"hid#(?.*)#(?.*)#{"); private static readonly Regex RawBTPattern = new(@"BTHENUM"); private static readonly string HidHideCLI = @"C:\Program Files\Nefarius Software Solutions e.U\HidHideCLI\HidHideCLI.exe"; - private static string PrettyHID; + private static string Arguments; public static void AddHidHideHID(string RawHID) { - PrettyHID = ParseInfoFromRawHID(RawHID); - if (PrettyHID == "") { return; } - sendHIDInftoHidHideCLI(); + Arguments = ParseInfoFromRawHID(RawHID); + if (Arguments == "") { return; } + RunHidHideCLI(); } - public static void NullPrettyHid() - { PrettyHID = null; } + public static void NullHidHideArguments() + { Arguments = null; } - private static void sendHIDInftoHidHideCLI() + private static void RunHidHideCLI() { Process RunHidHideCLI = new(); try @@ -37,19 +37,28 @@ private static void sendHIDInftoHidHideCLI() RunHidHideCLI.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; RunHidHideCLI.StartInfo.UseShellExecute = true; RunHidHideCLI.StartInfo.Verb = "runas"; - RunHidHideCLI.StartInfo.Arguments = $"dev-hide \"{PrettyHID}\""; + RunHidHideCLI.StartInfo.Arguments = Arguments; RunHidHideCLI.Start(); } catch { } } + public static void AddDS4WindowstoHidHideWhiteList() + { + string path = Environment.CurrentDirectory; + string exe = Global.FakeExeName; + if (string.IsNullOrEmpty(exe)) { exe = "DS4Windows.exe"; } + Arguments = $"app-reg \"{path}\\{exe}\""; + RunHidHideCLI(); + } + private static string ParseInfoFromRawHID(string RawHID) { if (RawBTPattern.Match(RawHID).Success) { return RawHID; } if (RawUSBHIDPattern.Match(RawHID).Success) { GroupCollection groups = RawUSBHIDPattern.Match(RawHID).Groups; - return $"HID\\{groups[1]}\\{groups[2]}"; + return $"dev-hide \"HID\\{groups[1]}\\{groups[2]}\""; } return ""; }