diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 250e82e..d58c1bf 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -231,9 +231,7 @@ namespace DS4Windows public static string appdatapath; public static bool firstRun = false; public static bool multisavespots = false; - public static bool oldappdatafail = false; public static string appDataPpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Windows"; - public static string oldappdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool"; public static bool runHotPlug = false; public const int XINPUT_UNPLUG_SETTLE_TIME = 250; // Inhibit races that occur with the asynchronous teardown of ScpVBus -> X360 driver instance. public static string[] tempprofilename = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; @@ -342,20 +340,6 @@ namespace DS4Windows SaveWhere(exepath); else if (File.Exists(appDataPpath + "\\Auto Profiles.xml")) SaveWhere(appDataPpath); - else if (File.Exists(oldappdatapath + "\\Auto Profiles.xml")) - { - try - { - if (Directory.Exists(appDataPpath)) - Directory.Move(appDataPpath, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Windows Old"); - Directory.Move(oldappdatapath, appDataPpath); - SaveWhere(appDataPpath); - } - catch - { - Global.oldappdatafail = true; - } - } else if (!File.Exists(exepath + "\\Auto Profiles.xml") && !File.Exists(appDataPpath + "\\Auto Profiles.xml")) { @@ -374,7 +358,43 @@ namespace DS4Windows catch { /* Skip setting culture that we cannot set */ } } + public static void CreateStdActions() + { + XmlDocument xDoc = new XmlDocument(); + try + { + string[] profiles = Directory.GetFiles(appdatapath + @"\Profiles\"); + string s = string.Empty; + //foreach (string s in profiles) + for (int i = 0, proflen = profiles.Length; i < proflen; i++) + { + s = profiles[i]; + if (Path.GetExtension(s) == ".xml") + { + xDoc.Load(s); + XmlNode el = xDoc.SelectSingleNode("DS4Windows/ProfileActions"); + if (el != null) + { + if (string.IsNullOrEmpty(el.InnerText)) + el.InnerText = "Disconnect Controller"; + else + el.InnerText += "/Disconnect Controller"; + } + else + { + XmlNode Node = xDoc.SelectSingleNode("DS4Windows"); + el = xDoc.CreateElement("ProfileActions"); + el.InnerText = "Disconnect Controller"; + Node.AppendChild(el); + } + xDoc.Save(s); + LoadActions(); + } + } + } + catch { } + } public static event EventHandler ControllerStatusChange; // called when a controller is added/removed/battery or touchpad mode changes/etc. public static void ControllerStatusChanged(object sender) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 17f371a..fd980fe 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -88,13 +88,6 @@ namespace DS4Windows { new SaveWhere(Global.multisavespots).ShowDialog(); } - else if (Global.oldappdatafail) - { - MessageBox.Show(Properties.Resources.CannotMoveFiles, "DS4Windows"); - Process.Start("explorer.exe", @"/select, " + appDataPpath); - Close(); - return; - } Global.Load(); Global.SetCulture(UseLang); @@ -178,17 +171,15 @@ namespace DS4Windows } catch { } MessageBox.Show("Copy complete, please relaunch DS4Windows and remove settings from Program Directory", "DS4Windows"); - appdatapath = null; - Close(); - return; } else { MessageBox.Show("DS4Windows cannot edit settings here, This will now close", "DS4Windows"); - appdatapath = null; - Close(); - return; } + + appdatapath = null; + Close(); + return; } cBUseWhiteIcon.Checked = UseWhiteIcon; @@ -223,40 +214,7 @@ namespace DS4Windows if (!LoadActions()) //if first no actions have been made yet, create PS+Option to D/C and save it to every profile { - XmlDocument xDoc = new XmlDocument(); - try - { - string[] profiles = Directory.GetFiles(appdatapath + @"\Profiles\"); - string s = string.Empty; - //foreach (string s in profiles) - for (int i = 0, proflen = profiles.Length; i < proflen; i++) - { - s = profiles[i]; - if (Path.GetExtension(s) == ".xml") - { - xDoc.Load(s); - XmlNode el = xDoc.SelectSingleNode("DS4Windows/ProfileActions"); - if (el != null) - { - if (string.IsNullOrEmpty(el.InnerText)) - el.InnerText = "Disconnect Controller"; - else - el.InnerText += "/Disconnect Controller"; - } - else - { - XmlNode Node = xDoc.SelectSingleNode("DS4Windows"); - el = xDoc.CreateElement("ProfileActions"); - el.InnerText = "Disconnect Controller"; - Node.AppendChild(el); - } - - xDoc.Save(s); - LoadActions(); - } - } - } - catch { } + Global.CreateStdActions(); } bool start = true; @@ -317,9 +275,6 @@ namespace DS4Windows hotkeysTimer.Start(); } - if (btnStartStop.Enabled && start) - BtnStartStop_Clicked(); - startToolStripMenuItem.Text = btnStartStop.Text; cBoxNotifications.SelectedIndex = Notifications; cBSwipeProfiles.Checked = SwipeProfiles; @@ -440,6 +395,9 @@ namespace DS4Windows control.MouseHover += ClearLastMessage; } } + + if (btnStartStop.Enabled && start) + TaskRunner.Delay(10).ContinueWith((t) => this.BeginInvoke((System.Action)(() => BtnStartStop_Clicked()))); } private void populateHoverTextDict() @@ -577,22 +535,32 @@ namespace DS4Windows string slide = Program.rootHub.TouchpadSlide(i); if (slide == "left") { - if (cbs[i].SelectedIndex <= 0) - cbs[i].SelectedIndex = cbs[i].Items.Count - 2; - else - cbs[i].SelectedIndex--; - + this.BeginInvoke((System.Action)(() => + { + if (cbs[i].SelectedIndex <= 0) + cbs[i].SelectedIndex = cbs[i].Items.Count - 2; + else + cbs[i].SelectedIndex--; + })); } else if (slide == "right") { - if (cbs[i].SelectedIndex == cbs[i].Items.Count - 2) - cbs[i].SelectedIndex = 0; - else - cbs[i].SelectedIndex++; + this.BeginInvoke((System.Action)(() => + { + if (cbs[i].SelectedIndex == cbs[i].Items.Count - 2) + cbs[i].SelectedIndex = 0; + else + cbs[i].SelectedIndex++; + })); } if (slide.Contains("t")) - ShowNotification(this, Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", cbs[i].Text)); + { + this.BeginInvoke((System.Action)(() => + { + ShowNotification(this, Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", cbs[i].Text)); + })); + } } } diff --git a/DS4Windows/Properties/AssemblyInfo.cs b/DS4Windows/Properties/AssemblyInfo.cs index 6460f97..c360ca1 100644 --- a/DS4Windows/Properties/AssemblyInfo.cs +++ b/DS4Windows/Properties/AssemblyInfo.cs @@ -33,7 +33,7 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.5.5")] -[assembly: AssemblyFileVersion("1.5.5")] +[assembly: AssemblyVersion("1.5.6")] +[assembly: AssemblyFileVersion("1.5.6")] [assembly: NeutralResourcesLanguage("en")] diff --git a/README.md b/README.md index 55de55d..d69283d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ website at [ds4windows.com](http://ds4windows.com). - **[Main builds of DS4Windows](https://github.com/Ryochan7/DS4Windows/releases)** - Alternative builds: - - [UdpServer ViGEm build](http://ryochan7.xyz/ds4windows/test/DS4Windows_1.5.4_ViGEm_UdpServer_x64.zip) + - [UdpServer ViGEm build](http://ryochan7.xyz/ds4windows/test/DS4Windows_1.5.5_ViGEm_UdpServer_x64.zip) ## Requirements diff --git a/TODO.md b/TODO.md index 42660e0..eb8eec2 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,6 @@ # TODO -* Perform some final cleanup and release version 1.5 +* ~~Perform some final cleanup and release version 1.5~~ * Attempt to remove reliance on the main thread when disconnecting a device. Currently used to delay hotplug routine * Look into distributing profile properties around various objects