cemu-DS4Windows/DS4Tool/WelcomeDialog.cs
jays2kings b4a6249fa3 Version 1.4.156
Significant CPU usage decrease by reworking how single instances work,
on a mobile i7 for example with a single controller connected usage went
from 4-6% to .5-1.5%. With no controllers connected the usage went from
2.5-4.5% to 0%!
As mentioned before, single instances has been reworked, so trying to
relaunch DS4W more reliably opens the previous instance
Fixed Shift modifier not working if main controls were not modified
Fixed Tilt Left for Shift modifier
Fixed default text of shift controls
Remove touchpad movement notification when swipe for controls is enabled
Can test the rumble motors separately via Heavy and Light
Truly implemented Flush HID (I think)
Slight change in profiles, when loading profiles in for the first time
in this new version, there may be a slight delay
Updated French Translations
Removed mouse moving as an option for touch swipes controls, as they
weren't implemented nor have a purpose to be
2014-11-18 16:23:41 -05:00

150 lines
5.7 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using DS4Control;
using System.IO;
using System.IO.Compression;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Security.Permissions;
using System.Reflection;
namespace DS4Windows
{
public partial class WelcomeDialog : Form
{
public WelcomeDialog()
{
InitializeComponent();
Icon = Properties.Resources.DS4;
}
private void bnFinish_Click(object sender, EventArgs e)
{
this.Close();
}
private void linkBluetoothSettings_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("control", "bthprops.cpl");
}
private void bnStep1_Click(object sender, EventArgs e)
{
WebClient wb = new WebClient();
if (bnStep1.Text == Properties.Resources.Step1)
{
wb.DownloadFileAsync(new Uri("http://ds4windows.com/Files/Virtual Bus Driver.zip"), Global.appdatapath + "\\VBus.zip");
wb.DownloadProgressChanged += wb_DownloadProgressChanged;
wb.DownloadFileCompleted += wb_DownloadFileCompleted;
}
}
private void wb_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
bnStep1.Text = Properties.Resources.Downloading.Replace("*number*", e.ProgressPercentage.ToString());
}
string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
private void wb_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
if (!Global.AdminNeeded())
{
bnStep1.Text = Properties.Resources.OpeningInstaller;
try
{
File.Delete(exepath + "\\ScpDriver.exe");
File.Delete(exepath + "\\ScpDriver.log");
Directory.Delete(exepath + "\\System", true);
Directory.Delete(exepath + "\\DIFxAPI", true);
}
catch { }
Directory.CreateDirectory(Global.appdatapath + "\\Virtual Bus Driver");
try { ZipFile.ExtractToDirectory(Global.appdatapath + "\\VBus.zip", Global.appdatapath + "\\Virtual Bus Driver"); } //Saved so the user can uninstall later
catch { }
try { ZipFile.ExtractToDirectory(Global.appdatapath + "\\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(Global.appdatapath + "\\Virtual Bus Driver"); }
Timer timer = new Timer();
timer.Start();
timer.Tick += timer_Tick;
}
else
{
bnStep1.Text = Properties.Resources.OpenScpDriver;
Directory.CreateDirectory(Global.appdatapath + "\\Virtual Bus Driver");
try { ZipFile.ExtractToDirectory(Global.appdatapath + "\\VBus.zip", Global.appdatapath + "\\Virtual Bus Driver"); }
catch { }
Process.Start(Global.appdatapath + "\\Virtual Bus Driver");
Timer timer = new Timer();
timer.Start();
timer.Tick += timer_Tick;
}
}
bool running = false;
private void timer_Tick(object sender, EventArgs e)
{
Process[] processes = Process.GetProcessesByName("ScpDriver");
if (!Global.AdminNeeded())
{
if (processes.Length < 1)
{
string log = File.ReadAllText(exepath + "\\ScpDriver.log");
if (log.Contains("Install Succeeded"))
bnStep1.Text = Properties.Resources.InstallComplete;
else
{
bnStep1.Text = Properties.Resources.InstallFailed;
Process.Start(Global.appdatapath + "\\Virtual Bus Driver");
}
try
{
File.Delete(exepath + "\\ScpDriver.exe");
File.Delete(exepath + "\\ScpDriver.log");
Directory.Delete(exepath + "\\System", true);
Directory.Delete(exepath + "\\DIFxAPI", true);
}
catch { }
File.Delete(Global.appdatapath + "\\VBus.zip");
((Timer)sender).Stop();
}
}
else
{
if (processes.Length > 0)
running = true;
if (running)
if (processes.Length < 1)
{
bnStep1.Text = Properties.Resources.InstallComplete;
File.Delete(Global.appdatapath + "\\VBus.zip");
((Timer)sender).Stop();
}
}
}
private void button2_Click(object sender, EventArgs e)
{
Process.Start("http://www.microsoft.com/hardware/en-us/d/xbox-360-controller-for-windows");
}
}
}