Skip to content

Commit

Permalink
Add hidhide whitelist function
Browse files Browse the repository at this point in the history
D4W now adds itself to hidhide's whitelist if it is installed. It will add a custom exe name if one is used.
  • Loading branch information
Yohoki authored Nov 5, 2021
1 parent 2ee1e56 commit 8396d07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion DS4Windows/DS4Library/DS4Devices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
}
Expand Down
27 changes: 18 additions & 9 deletions DS4Windows/DS4Library/YohokiUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class YohokiUtils
private static readonly Regex RawUSBHIDPattern = new(@"hid#(?<HIDStart>.*)#(?<HIDEnd>.*)#{");
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
Expand All @@ -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 "";
}
Expand Down

0 comments on commit 8396d07

Please sign in to comment.