diff --git a/DS4Windows/DS4Forms/WelcomeDialog.cs b/DS4Windows/DS4Forms/WelcomeDialog.cs index 5d9d61c..fe42e8d 100644 --- a/DS4Windows/DS4Forms/WelcomeDialog.cs +++ b/DS4Windows/DS4Forms/WelcomeDialog.cs @@ -37,17 +37,14 @@ namespace DS4Windows { Process.Start("control", "bthprops.cpl"); } - bool driverinstalling = false; + private void bnStep1_Click(object sender, EventArgs e) { WebClient wb = new WebClient(); - if (!driverinstalling) - { - wb.DownloadFileAsync(new Uri("https://github.com/Ryochan7/DS4Windows/raw/jay/extras/Virtual Bus Driver.zip"), exepath + "\\VBus.zip"); - wb.DownloadProgressChanged += wb_DownloadProgressChanged; - wb.DownloadFileCompleted += wb_DownloadFileCompleted; - driverinstalling = true; - } + wb.DownloadFileAsync(new Uri("https://github.com/Ryochan7/DS4Windows/raw/jay/extras/ViGEmBusInstaller_DS4Win.zip"), + exepath + "\\ViGEmBusInstaller_DS4Win.zip"); + wb.DownloadProgressChanged += wb_DownloadProgressChanged; + wb.DownloadFileCompleted += wb_DownloadFileCompleted; } private void wb_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) @@ -57,82 +54,47 @@ namespace DS4Windows private void wb_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { - bnStep1.Text = Properties.Resources.OpeningInstaller; - try + if (Directory.Exists(exepath + "\\ViGEmBusInstaller")) { - File.Delete(exepath + "\\ScpDriver.exe"); - File.Delete(exepath + "\\ScpDriver.log"); - Directory.Delete(exepath + "\\System", true); - Directory.Delete(exepath + "\\DIFxAPI", true); + 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")) + { + bnStep1.Text = Properties.Resources.OpeningInstaller; + Process.Start(exepath + "\\ViGEmBusInstaller\\ViGEmBusInstaller.exe", "--silent"); + bnStep1.Text = Properties.Resources.Installing; } - catch { } - Directory.CreateDirectory(exepath + "\\Virtual Bus Driver"); - try { ZipFile.ExtractToDirectory(exepath + "\\VBus.zip", exepath + "\\Virtual Bus Driver"); } //Saved so the user can uninstall later - catch { } - try { ZipFile.ExtractToDirectory(exepath + "\\VBus.zip", exepath); } - //Made here as starting the scpdriver.exe via process.start, the program looks for file from where it was called, not where the exe is - catch { } - if (File.Exists(exepath + "\\ScpDriver.exe")) - try - { - Process.Start(exepath + "\\ScpDriver.exe", "si"); - bnStep1.Text = Properties.Resources.Installing; - } - catch { Process.Start(exepath + "\\Virtual Bus Driver"); } - /*Timer timer = new Timer(); - timer.Start(); - timer.Tick += timer_Tick; - */ NonFormTimer timer = new NonFormTimer(); timer.Elapsed += timer_Tick; timer.Start(); } - bool waitForFile; - DateTime waitFileCheck; private void timer_Tick(object sender, EventArgs e) { - Process[] processes = Process.GetProcessesByName("ScpDriver"); + Process[] processes = Process.GetProcessesByName("ViGEmBusInstaller"); if (processes.Length < 1) { - if (!File.Exists(exepath + "\\ScpDriver.log") && !waitForFile) + if (Global.IsScpVBusInstalled()) { - waitForFile = true; - waitFileCheck = DateTime.UtcNow; - return; - } - - if (waitForFile && waitFileCheck + TimeSpan.FromMinutes(2) < DateTime.UtcNow) - { - Process.Start(exepath + "\\Virtual Bus Driver"); - File.Delete(exepath + "\\VBus.zip"); - ((NonFormTimer)sender).Stop(); - this.BeginInvoke((Action)(() => { bnStep1.Text = Properties.Resources.InstallFailed; }), null); - return; - } - else if (waitForFile) - return; - - string log = File.ReadAllText(exepath + "\\ScpDriver.log"); - if (log.Contains("Install Succeeded")) this.BeginInvoke((Action)(() => { bnStep1.Text = Properties.Resources.InstallComplete; })); + } else { - this.BeginInvoke((Action)(() => { bnStep1.Text = Properties.Resources.InstallFailed; })); - Process.Start(exepath + "\\Virtual Bus Driver"); + this.BeginInvoke((Action)(() => { bnStep1.Text = Properties.Resources.InstallFailed; }), null); } + - try - { - File.Delete(exepath + "\\ScpDriver.exe"); - File.Delete(exepath + "\\ScpDriver.log"); - Directory.Delete(exepath + "\\System", true); - Directory.Delete(exepath + "\\DIFxAPI", true); - } - catch { } - - File.Delete(exepath + "\\VBus.zip"); + File.Delete(exepath + "\\ViGEmBusInstaller_DS4Win.zip"); ((NonFormTimer)sender).Stop(); } } diff --git a/DS4Windows/DS4Forms/WelcomeDialog.resx b/DS4Windows/DS4Forms/WelcomeDialog.resx index 2633d7b..cff69e1 100644 --- a/DS4Windows/DS4Forms/WelcomeDialog.resx +++ b/DS4Windows/DS4Forms/WelcomeDialog.resx @@ -129,7 +129,7 @@ 1 - Step 1: Install the ScpVBus Driver + Step 1: Install the ViGEmBus Driver bnStep1