..:: PCSX2 Forums ::..

Full Version: DS4Windows -- yet another DualShock 4 driver! (No longer under active development)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(05-16-2014, 12:31 PM)jhebbel Wrote: [ -> ]ran it on a win 7 VM
Should do a process scan to make sure all instances of ds4tool are closed prior to running, firs time I ran it it seemed to download ok but didnt really give any indication that things were actually updated, perhaps should have a msgbox "Updated to vx.x" then self close.

2nd Time I ran t on a already up to date ver it just sits in "fetching download" state, not sure if this is the programs response if I am already up to date but if so it should signify this with a msgbox as well and again auto close.

The sitting in "fetching download" state appears to just be from network congestion your end, appears there is no internal version check to back up the one that happens inside DS4Tool, so if the Updater.exe is run independently it will download every time, this could add unneeded stress to your server. If your host has SQL capabilities it may be best to perform the version check using this to save further http get requests, these can really start to stack up if not careful and can lead to among other things suspended accounts from unhappy providers.

Slapping this in the constructor should do the trick
Code:
Process[] processes = Process.GetProcessesByName("DS4Tool"); //This may actually be "DS4 Tool" with space, not sure how it is identified.
            if (processes.Length > 0)
            {
                if (MessageBox.Show("All instances of DS4Tool must be closed prior to running update. Do you wish to close them and continue?", "Close DS4Tool to continue", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    processes[0].CloseMainWindow();
                } else {
                    Application.Exit();
                }
            }

Also here is a snipit to get it to start with windows, just create this bool and bind a checkbox to it, rest should be automatic;
Code:
bool StartWithWindows {
            get {
                RegistryKey KeyLoc = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
                if (KeyLoc.GetValue("DS4Tool") != null)
                { return true; }
                else
                { return false; }
            }
            set {
                RegistryKey KeyLoc = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",true);

                if (value)
                {
                    KeyLoc.SetValue("DS4Tool", "\"" + Application.ExecutablePath.ToString() + "\"");
                }
                else
                {
                    KeyLoc.DeleteSubKey("DS4Tool", false);
                }
            }
        }

The debug updater is made to download every time. I want it to so I can see if all goes well without .net 4.5 installed on the client PC. The way the real updater works is by checking if version.text exists in appdata, the d/L's the version number in that file. Ds4tool downloads the version.text to get the latest version, and deletes it if the tool is up to date, but keeps it for the updater to read if there is a new version, then updater updates using it and deletes the txt after that. So the ds4tool uses my server every time it starts up, but since the txt is only 3 bytes it's not a (major) problem, if my version gets too popular for my dropbox to manage I'll switch it to another server.

Though I will take your advice on checking if the ds4tool is running.
(05-16-2014, 01:40 PM)Jays2Kings Wrote: [ -> ]The debug updater is made to download every time. I want it to so I can see if all goes well without .net 4.5 installed on the client PC. The way the real updater works is by checking if version.text exists in appdata, the d/L's the version number in that file. Ds4tool downloads the version.text to get the latest version, and deletes it if the tool is up to date, but keeps it for the updater to read if there is a new version, then updater updates using it and deletes the txt after that. So the ds4tool uses my server every time it starts up, but since the txt is only 3 bytes it's not a (major) problem, if my version gets too popular for my dropbox to manage I'll switch it to another server.

Though I will take your advice on checking if the ds4tool is running.

Gotcha, I was more worried about the number of requests than the size of the file though, like I said I had a hangup when trying this morning and your tool hasn't even hit mainstream yet really.

If you want some webspace or want a dev page on our site http://dsdcs.com id have no problem setting you up with some, we have a software development portion of our site that is unused because our clients all have embargos built into our NDA which prohibits us from talking about any software projects, and I rarely have time for off the book projects anymore lol.
(05-16-2014, 02:03 PM)jhebbel Wrote: [ -> ]Gotcha, I was more worried about the number of requests than the size of the file though, like I said I had a hangup when trying this morning and your tool hasn't even hit mainstream yet really.

If you want some webspace or want a dev page on our site http://dsdcs.com id have no problem setting you up with some, we have a software development portion of our site that is unused because our clients all have embargos built into our NDA which prohibits us from talking about any software projects, and I rarely have time for off the book projects anymore lol.

Thanks for the offer, but I rather not have to have you host my stuff. I'll look in to more options later as well as upload the new updater later as the ds4tool doesn't need an update right now.
And so I found a windows 7 laptop, and tested out the updater more extensively, and now I can say it's working well and without flaw.

I used WPF instead of Windows form so I can use the taskbar progress bar in the updater. If you have the newest version of my branch (6.8) just download the updater below and replace it in wherever you run the ds4 tool from. NOW auto-updates will work. If you on an older version prior to 6.8, make sure to get the latest version below.

And with that ends the troubleshooting.

Also I uploaded the Updater source code for all to use/see: https://code.google.com/p/ds4tool-updater/
How to use the updater ?

Always I run Udpater in admin, I have this message

[Image: ZydJncv.png]

I run DS4Tool but I don't have version.txt file
(05-17-2014, 11:59 AM)DirtyShady Wrote: [ -> ]How to use the updater ?

Always I run Udpater in admin, I have this message

[Image: ZydJncv.png]

I run DS4Tool but I don't have version.txt file

The way he has it set up it looks like the version.txt file is created by the DS4Tool app, thus the updater cannot be run independently.
(05-17-2014, 06:58 AM)Jays2Kings Wrote: [ -> ]And so I found a windows 7 laptop, and tested out the updater more extensively, and now I can say it's working well and without flaw.

I used WPF instead of Windows form so I can use the taskbar progress bar in the updater. If you have the newest version of my branch (6.8) just download the updater below and replace it in wherever you run the ds4 tool from. NOW auto-updates will work. If you on an older version prior to 6.8, make sure to get the latest version below.

And with that ends the troubleshooting.

Also I uploaded the Updater source code for all to use/see: https://code.google.com/p/ds4tool-updater/

(05-17-2014, 11:59 AM)DirtyShady Wrote: [ -> ]How to use the updater ?

Always I run Udpater in admin, I have this message

[Image: ZydJncv.png]

I run DS4Tool but I don't have version.txt file

I modified the updater to be self runnable, but since the application version is not stored in the manifest it is not publicly accessible thus this app will not know if the server version is truly newer than the local and will just replace it every time. On the plus side this can sort of be used as a deployer now since it will always DL the app no matter what.

-Edit-
Also j2k, the .CloseMainWindow() had to be replaced with kill() is the tool does not seem to listen to friendly close requests, so that works now aswell.

the code for MainWindow.xaml.cs as I didnt want to fork just for this.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;

namespace Updater2
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        WebClient wc = new WebClient();
        protected string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool";
        Process[] processes = Process.GetProcessesByName("DS4Tool");
        public MainWindow()
        {
            InitializeComponent();
            //double newversion;
            DLUpdate();

          
            if (processes.Length > 0)
            {
                if (MessageBox.Show("It must be closed to update.", "DS4Tool is still running", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation) == MessageBoxResult.OK)
                    for (int i = processes.Length - 1; i >= 0; i--)
                        processes[i].Kill();
                else
                    this.Close();
            }
        }
        public class Global
        {
            public static string appdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool";
        }

        private void DLUpdate()
        {
            try
            {
                if (GetNewestVerNum()!=null)
                {

                    Uri url = new Uri("https://dl.dropboxusercontent.com/u/16364552/DS4Tool/DS4Tool%20-%20J2K%20%28v" + GetNewestVerNum().ToString() + "%29.zip");//Sorry other devs, gonna have to find your own server
                    sw.Start();
                    if (!Directory.Exists(path))
                        Directory.CreateDirectory(path);
                    try { wc.DownloadFileAsync(url, path + "\\Update.zip"); }
                    catch (Exception e) { label1.Content = e.Message; }
                    wc.DownloadFileCompleted += wc_DownloadFileCompleted;
                    wc.DownloadProgressChanged += wc_DownloadProgressChanged;
                }
            }
            catch
            {
                label1.Content = "version.txt not found, please re-run DS4Tool";
            }
        }
        private void DLVerDoc()
        {
            Uri url = new Uri("https://dl.dropboxusercontent.com/u/16364552/DS4Tool/newest%20version.txt"); //Sorry other devs, gonna have to find your own server
            Directory.CreateDirectory(Global.appdatapath);
            wc.DownloadFile(url, Global.appdatapath + "\\version.txt");
            //wc.DownloadFileCompleted += Check_Version; Not needed in this app
        }
        private double? GetNewestVerNum()
        {
            double returnVer;
            if (!File.Exists(Global.appdatapath + "\\version.txt"))
            {

                DLVerDoc();
            }
            
            if (double.TryParse(File.ReadAllText(path + "\\version.txt"), out returnVer))
            {
                return returnVer;
            }
            else
            {
                return null;
            }
        }
        Stopwatch sw = new Stopwatch();
        private void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            label2.Opacity = 1;
            double speed = e.BytesReceived / sw.Elapsed.TotalSeconds;
            double timeleft = (e.TotalBytesToReceive - e.BytesReceived) / speed;
            if (timeleft > 3660)
                label2.Content = (int)timeleft / 3600 + "h left";
            else if (timeleft > 90)
                label2.Content = (int)timeleft / 60 + "m left";
            else
                label2.Content = (int)timeleft + "s left";
            UpdaterBar.Value = e.ProgressPercentage;
            TaskbarItemInfo.ProgressValue = UpdaterBar.Value / 106d;
            string convertedrev, convertedtotal;
            if (e.BytesReceived > 1024 * 1024 * 5) convertedrev = (int)(e.BytesReceived / 1024d / 1024d) + "MB";
            else convertedrev = (int)(e.BytesReceived / 1024d) + "kB";
            if (e.TotalBytesToReceive > 1024 * 1024 * 5) convertedtotal = (int)(e.TotalBytesToReceive / 1024d / 1024d) + "MB";
            else convertedtotal = (int)(e.TotalBytesToReceive / 1024d) + "kB";
            label1.Content = "Downloading update: " + convertedrev + " / " + convertedtotal;

        }

        private void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            sw.Reset();
            label2.Opacity = 0;
            label1.Content = "Deleting old files";
            UpdaterBar.Value = 102;
            TaskbarItemInfo.ProgressValue = UpdaterBar.Value / 106d;
            File.Delete("DS4Tool.exe");
            File.Delete("DS4Control.dll");
            File.Delete("DS4Library.dll");
            File.Delete("HidLibrary.dll");
            label1.Content = "Installing new files";
            UpdaterBar.Value = 104;
            TaskbarItemInfo.ProgressValue = UpdaterBar.Value / 106d;
            try { ZipFile.ExtractToDirectory(path + "\\Update.zip", Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName); }
            catch (IOException) { } //Since profiles may be in the zip ignore them if already exists
            File.Delete(path + "\\version.txt");
            File.Delete(path + "\\Update.zip");
            if (File.Exists("Updater NEW.exe"))
                label1.Content = "New Updater in program folder, replace to finish update";
            else
                label1.Content = "Update complete";
            UpdaterBar.Value = 106;
            TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
            btnOpenDS4.IsEnabled = true;
        }


        private void btnChangelog_Click(object sender, RoutedEventArgs e)
        {
            Process.Start("https://docs.google.com/document/d/1l4xcgVQkGUskc5CQ0p069yW22Cd5WAH_yE3Fz2hXo0E/edit?usp=sharing");
        }

        private void btnOpenDS4_Click(object sender, RoutedEventArgs e)
        {
            Process.Start("DS4Tool.exe");
            this.Close();
        }
    }
}
for me the updater crashes every time. i'm on win8.1 (Update 1) x64

Problemsignatur:
Problemereignisname: CLR20r3
Problemsignatur 01: Updater.exe
Problemsignatur 02: 1.0.0.0
Problemsignatur 03: 5377511b
Problemsignatur 04: mscorlib
Problemsignatur 05: 4.0.30319.34014
Problemsignatur 06: 52e0b679
Problemsignatur 07: 451e
Problemsignatur 08: 23b
Problemsignatur 09: System.Windows.Markup.XamlParse
Betriebsystemversion: 6.3.9600.2.0.0.256.103
Gebietsschema-ID: 1031
Zusatzinformation 1: 5861
Zusatzinformation 2: 5861822e1919d7c014bbb064c64908b2
Zusatzinformation 3: d1d9
Zusatzinformation 4: d1d94a13d3609d6b740644c12508f581
(05-17-2014, 03:31 PM)jusTiC3 Wrote: [ -> ]for me the updater crashes every time. i'm on win8.1 (Update 1) x64

Problemsignatur:
Problemereignisname: CLR20r3
Problemsignatur 01: Updater.exe
Problemsignatur 02: 1.0.0.0
Problemsignatur 03: 5377511b
Problemsignatur 04: mscorlib
Problemsignatur 05: 4.0.30319.34014
Problemsignatur 06: 52e0b679
Problemsignatur 07: 451e
Problemsignatur 08: 23b
Problemsignatur 09: System.Windows.Markup.XamlParse
Betriebsystemversion: 6.3.9600.2.0.0.256.103
Gebietsschema-ID: 1031
Zusatzinformation 1: 5861
Zusatzinformation 2: 5861822e1919d7c014bbb064c64908b2
Zusatzinformation 3: d1d9
Zusatzinformation 4: d1d94a13d3609d6b740644c12508f581

Is there any trace information in the crash dialog? I too am on 8.1.

-Edit-
Actually that may be my bad, due to the DL running in async (even though not needed) its trying to update before files are closed, gimme a sec for a new upload.

-Edit2-
Attached updater should fix that issue.
j2k updated code (closing of apps moved inside event to get rid of errors cause by async, wait command added after kill command (may need a timeout feature at some point));
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;

namespace Updater2
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        WebClient wc = new WebClient();
        protected string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool";

        public MainWindow()
        {
            InitializeComponent();
            //double newversion;
            DLUpdate();

        }
        public class Global
        {
            public static string appdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool";
        }
        private void CheckIfRunning()
        {
            Process[] processes = Process.GetProcessesByName("DS4Tool");
            if (processes.Length > 0)
            {
                if (MessageBox.Show("It must be closed to update.", "DS4Tool is still running", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation) == MessageBoxResult.OK)
                    for (int i = processes.Length - 1; i >= 0; i--)
                    {
                        processes[i].Kill();
                        processes[i].WaitForExit();
                    }
                else
                    this.Close();
            }
        }
        
        private void DLUpdate()
        {
            try
            {
                if (GetNewestVerNum()!=null)
                {

                    Uri url = new Uri("https://dl.dropboxusercontent.com/u/16364552/DS4Tool/DS4Tool%20-%20J2K%20%28v" + GetNewestVerNum().ToString() + "%29.zip");//Sorry other devs, gonna have to find your own server
                    sw.Start();
                    if (!Directory.Exists(path))
                        Directory.CreateDirectory(path);
                    try { wc.DownloadFileAsync(url, path + "\\Update.zip"); }
                    catch (Exception e) { label1.Content = e.Message; }
                    wc.DownloadFileCompleted += wc_DownloadFileCompleted;
                    wc.DownloadProgressChanged += wc_DownloadProgressChanged;
                }
            }
            catch
            {
                label1.Content = "version.txt not found, please re-run DS4Tool";
            }
        }
        private void DLVerDoc()
        {
            Uri url = new Uri("https://dl.dropboxusercontent.com/u/16364552/DS4Tool/newest%20version.txt"); //Sorry other devs, gonna have to find your own server
            Directory.CreateDirectory(Global.appdatapath);
            wc.DownloadFile(url, Global.appdatapath + "\\version.txt");
            //wc.DownloadFileCompleted += Check_Version; Not needed in this app
        }
        private double? GetNewestVerNum()
        {
            double returnVer;
            if (!File.Exists(Global.appdatapath + "\\version.txt"))
            {

                DLVerDoc();
            }
            
            if (double.TryParse(File.ReadAllText(path + "\\version.txt"), out returnVer))
            {
                return returnVer;
            }
            else
            {
                return null;
            }
        }
        Stopwatch sw = new Stopwatch();
        private void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            label2.Opacity = 1;
            double speed = e.BytesReceived / sw.Elapsed.TotalSeconds;
            double timeleft = (e.TotalBytesToReceive - e.BytesReceived) / speed;
            if (timeleft > 3660)
                label2.Content = (int)timeleft / 3600 + "h left";
            else if (timeleft > 90)
                label2.Content = (int)timeleft / 60 + "m left";
            else
                label2.Content = (int)timeleft + "s left";
            UpdaterBar.Value = e.ProgressPercentage;
            TaskbarItemInfo.ProgressValue = UpdaterBar.Value / 106d;
            string convertedrev, convertedtotal;
            if (e.BytesReceived > 1024 * 1024 * 5) convertedrev = (int)(e.BytesReceived / 1024d / 1024d) + "MB";
            else convertedrev = (int)(e.BytesReceived / 1024d) + "kB";
            if (e.TotalBytesToReceive > 1024 * 1024 * 5) convertedtotal = (int)(e.TotalBytesToReceive / 1024d / 1024d) + "MB";
            else convertedtotal = (int)(e.TotalBytesToReceive / 1024d) + "kB";
            label1.Content = "Downloading update: " + convertedrev + " / " + convertedtotal;

        }

        private void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            CheckIfRunning();

            sw.Reset();
            label2.Opacity = 0;
            label1.Content = "Deleting old files";
            UpdaterBar.Value = 102;
            TaskbarItemInfo.ProgressValue = UpdaterBar.Value / 106d;
            File.Delete("DS4Tool.exe");
            File.Delete("DS4Control.dll");
            File.Delete("DS4Library.dll");
            File.Delete("HidLibrary.dll");
            label1.Content = "Installing new files";
            UpdaterBar.Value = 104;
            TaskbarItemInfo.ProgressValue = UpdaterBar.Value / 106d;
            try { ZipFile.ExtractToDirectory(path + "\\Update.zip", Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName); }
            catch (IOException) { } //Since profiles may be in the zip ignore them if already exists
            File.Delete(path + "\\version.txt");
            File.Delete(path + "\\Update.zip");
            if (File.Exists("Updater NEW.exe"))
                label1.Content = "New Updater in program folder, replace to finish update";
            else
                label1.Content = "Update complete";
            UpdaterBar.Value = 106;
            TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
            btnOpenDS4.IsEnabled = true;
        }


        private void btnChangelog_Click(object sender, RoutedEventArgs e)
        {
            Process.Start("https://docs.google.com/document/d/1l4xcgVQkGUskc5CQ0p069yW22Cd5WAH_yE3Fz2hXo0E/edit?usp=sharing");
        }

        private void btnOpenDS4_Click(object sender, RoutedEventArgs e)
        {
            Process.Start("DS4Tool.exe");
            this.Close();
        }
    }
}
#zspwmw41-30362

here is the information you have requested.