From ee5ff50e79cf57a8dfe7da9f90c5b0cb2d1ea70a Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 22 Apr 2019 18:51:21 -0500 Subject: [PATCH] Changed ViGEm Bus Driver check Related to issue #667 --- DS4Windows/DS4Control/ScpUtil.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index f4b4176..e733a23 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -301,6 +301,27 @@ namespace DS4Windows return principal.IsInRole(WindowsBuiltInRole.Administrator); } + public static bool CheckForDevice(string guid) + { + bool result = false; + Guid deviceGuid = Guid.Parse(guid); + NativeMethods.SP_DEVINFO_DATA deviceInfoData = + new NativeMethods.SP_DEVINFO_DATA(); + deviceInfoData.cbSize = + System.Runtime.InteropServices.Marshal.SizeOf(deviceInfoData); + + IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(ref deviceGuid, null, 0, + NativeMethods.DIGCF_DEVICEINTERFACE); + result = NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, 0, ref deviceInfoData); + + if (deviceInfoSet.ToInt64() != NativeMethods.INVALID_HANDLE_VALUE) + { + NativeMethods.SetupDiDestroyDeviceInfoList(deviceInfoSet); + } + + return result; + } + private static bool CheckForSysDevice(string searchHardwareId) { bool result = false; @@ -342,8 +363,7 @@ namespace DS4Windows public static bool IsViGEmBusInstalled() { - return CheckForSysDevice(@"Root\ViGEmBus") || - CheckForSysDevice(@"Nefarius\ViGEmBus\Gen1"); + return CheckForDevice("{96E42B22-F5E9-42F8-B043-ED0F932F014F}"); } public static void FindConfigLocation()