From 38e6b0e2e1e6aeb6e435690030f7480c8be6964b Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 22 Apr 2019 17:26:51 -0500 Subject: [PATCH 1/2] Link to newer ViGEmBus installer --- DS4Windows/DS4Forms/WelcomeDialog.cs | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/DS4Windows/DS4Forms/WelcomeDialog.cs b/DS4Windows/DS4Forms/WelcomeDialog.cs index f738f61..a497236 100644 --- a/DS4Windows/DS4Forms/WelcomeDialog.cs +++ b/DS4Windows/DS4Forms/WelcomeDialog.cs @@ -15,6 +15,10 @@ namespace DS4Windows { public partial class WelcomeDialog : Form { + private const string InstallerDL = + "https://github.com/ViGEm/ViGEmBus/releases/download/v1.16.112/ViGEmBus_Setup_1.16.112.exe"; + private const string InstFileName = "ViGEmBus_Setup_1.16.112.exe"; + public WelcomeDialog(bool loadConfig=false) { if (loadConfig) @@ -40,9 +44,14 @@ namespace DS4Windows private void bnStep1_Click(object sender, EventArgs e) { + if (File.Exists(exepath + $"\\{InstFileName}")) + { + File.Delete(exepath + $"\\{InstFileName}"); + } + WebClient wb = new WebClient(); - wb.DownloadFileAsync(new Uri("https://github.com/Ryochan7/DS4Windows/raw/jay/extras/ViGEmBusInstaller_DS4Win.zip"), - exepath + "\\ViGEmBusInstaller_DS4Win.zip"); + wb.DownloadFileAsync(new Uri(InstallerDL), exepath + $"\\{InstFileName}"); + wb.DownloadProgressChanged += wb_DownloadProgressChanged; wb.DownloadFileCompleted += wb_DownloadFileCompleted; } @@ -59,18 +68,10 @@ namespace DS4Windows Directory.Delete(exepath + "\\ViGEmBusInstaller", true); } - if (File.Exists(exepath + "\\ViGEmBusInstaller_DS4Win.zip")) - { - Directory.CreateDirectory(exepath + "\\ViGEmBusInstaller"); - try { ZipFile.ExtractToDirectory(exepath + "\\ViGEmBusInstaller_DS4Win.zip", - exepath + "\\ViGEmBusInstaller"); } //Saved so the user can uninstall later - catch { } - } - - if (File.Exists(exepath + "\\ViGEmBusInstaller\\ViGEmBusInstaller.exe")) + if (File.Exists(exepath + $"\\{InstFileName}")) { bnStep1.Text = Properties.Resources.OpeningInstaller; - Process.Start(exepath + "\\ViGEmBusInstaller\\ViGEmBusInstaller.exe", "--silent"); + Process.Start(exepath + $"\\{InstFileName}", "/quiet"); bnStep1.Text = Properties.Resources.Installing; } @@ -81,7 +82,7 @@ namespace DS4Windows private void timer_Tick(object sender, EventArgs e) { - Process[] processes = Process.GetProcessesByName("ViGEmBusInstaller"); + Process[] processes = Process.GetProcessesByName("ViGEmBus_Setup_1.16.112"); if (processes.Length < 1) { if (Global.IsViGEmBusInstalled()) @@ -92,9 +93,8 @@ namespace DS4Windows { this.BeginInvoke((Action)(() => { bnStep1.Text = Properties.Resources.InstallFailed; }), null); } - - File.Delete(exepath + "\\ViGEmBusInstaller_DS4Win.zip"); + File.Delete(exepath + $"\\{InstFileName}"); ((NonFormTimer)sender).Stop(); } } From ee5ff50e79cf57a8dfe7da9f90c5b0cb2d1ea70a Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 22 Apr 2019 18:51:21 -0500 Subject: [PATCH 2/2] 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()