mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-22 01:09:17 +01:00
Changed Welcome dialog to account for ViGEmBus installer program
This commit is contained in:
parent
94eff31290
commit
fb73c19574
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="bnStep1.Text" xml:space="preserve">
|
||||
<value>Step 1: Install the ScpVBus Driver</value>
|
||||
<value>Step 1: Install the ViGEmBus Driver</value>
|
||||
</data>
|
||||
<data name=">>bnStep1.Name" xml:space="preserve">
|
||||
<value>bnStep1</value>
|
||||
|
Loading…
Reference in New Issue
Block a user