From 3065353b63390d6c8633c69761afef1ff87ff61d Mon Sep 17 00:00:00 2001 From: SergueiFedorov Date: Thu, 5 Feb 2015 22:51:54 -0600 Subject: [PATCH 01/20] Started work on a WPF version. Right now it's just a skeleton application to test data extraction from the DS4Control API --- DS4Tool/DS4Windows.csproj | 8 +++++--- DS4Tool/DS4Windows_TemporaryKey.pfx | Bin 0 -> 1692 bytes 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 DS4Tool/DS4Windows_TemporaryKey.pfx diff --git a/DS4Tool/DS4Windows.csproj b/DS4Tool/DS4Windows.csproj index adcd04eefe..cfde576b79 100644 --- a/DS4Tool/DS4Windows.csproj +++ b/DS4Tool/DS4Windows.csproj @@ -62,10 +62,10 @@ DS4Windows.Program - 5F2A5A97E42A73158D79996F7F3BE738271F5047 + CE06663A796157539135CFA51C654D2E3422F0D9 - DS4Tool_TemporaryKey.pfx + DS4Windows_TemporaryKey.pfx true @@ -411,6 +411,7 @@ + SettingsSingleFileGenerator Settings.Designer.cs @@ -535,7 +536,8 @@ - ilmerge /targetplatform:"v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319" /out:Build\DS4Windows.exe DS4Windows.exe HidLibrary.dll DS4Control.dll DS4Library.dll + + + \ No newline at end of file diff --git a/DS4WCF/MainWindow.xaml b/DS4WCF/MainWindow.xaml new file mode 100644 index 0000000000..3cc096312e --- /dev/null +++ b/DS4WCF/MainWindow.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/DS4WCF/MainWindow.xaml.cs b/DS4WCF/MainWindow.xaml.cs new file mode 100644 index 0000000000..b31f86c7db --- /dev/null +++ b/DS4WCF/MainWindow.xaml.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +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; + +namespace DS4WCF +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + //Window does not own control + private DS4Control.Control _control; + List _controllerGrids = new List(); + + public MainWindow( DS4Control.Control control ) + { + _control = control; + + InitializeComponent(); + GetAllControllerPanels(); + GetAllControllers(); + } + + private void GetAllControllerPanels() + { + _controllerGrids.Add(FindName("ControllerPanel0") as ControllerInputGrid); + _controllerGrids.Add(FindName("ControllerPanel1") as ControllerInputGrid); + _controllerGrids.Add(FindName("ControllerPanel2") as ControllerInputGrid); + _controllerGrids.Add(FindName("ControllerPanel3") as ControllerInputGrid); + } + + private void GetAllControllers() + { + DS4Library.DS4Device[] devices = this._control.DS4Controllers; + for (int deviceIndex = 0; deviceIndex < devices.Count(); deviceIndex++) + { + if (devices[deviceIndex] != null) + { + _controllerGrids[deviceIndex].InitializeWithDS4Device(devices[deviceIndex]); + } + } + } + + } +} diff --git a/DS4WCF/Properties/AssemblyInfo.cs b/DS4WCF/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..4d2642b535 --- /dev/null +++ b/DS4WCF/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DS4WCF")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DS4WCF")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DS4WCF/Properties/Resources.Designer.cs b/DS4WCF/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..d3f77d23ab --- /dev/null +++ b/DS4WCF/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34014 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DS4WCF.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DS4WCF.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/DS4WCF/Properties/Resources.resx b/DS4WCF/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/DS4WCF/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DS4WCF/Properties/Settings.Designer.cs b/DS4WCF/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..9be19726f2 --- /dev/null +++ b/DS4WCF/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34014 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DS4WCF.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/DS4WCF/Properties/Settings.settings b/DS4WCF/Properties/Settings.settings new file mode 100644 index 0000000000..033d7a5e9e --- /dev/null +++ b/DS4WCF/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/DS4WCF/UI Components/ControllerInputGrid.xaml b/DS4WCF/UI Components/ControllerInputGrid.xaml new file mode 100644 index 0000000000..c135ca849e --- /dev/null +++ b/DS4WCF/UI Components/ControllerInputGrid.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + diff --git a/DS4WCF/UI Components/ControllerInputGrid.xaml.cs b/DS4WCF/UI Components/ControllerInputGrid.xaml.cs new file mode 100644 index 0000000000..0c0850d842 --- /dev/null +++ b/DS4WCF/UI Components/ControllerInputGrid.xaml.cs @@ -0,0 +1,77 @@ +using DS4Library; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +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; + +namespace DS4WCF +{ + /// + /// Interaction logic for ControllerInputGrid.xaml + /// + public partial class ControllerInputGrid : UserControl, INotifyPropertyChanged + { + private void OnPropertyChanged(string name) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(name)); + } + } + + string _batteryLevel; + public string BatteryLevel + { + get + { + return _batteryLevel; + } + set + { + + _batteryLevel = value; + OnPropertyChanged("BatteryLevel"); + } + } + + Brush _barColor; + public Brush BarColor + { + get + { + return _barColor; + } + set + { + _barColor = value; + OnPropertyChanged("barColor"); + } + } + + public ControllerInputGrid() + { + InitializeComponent(); + this.DataContext = this; + } + + public void InitializeWithDS4Device(DS4Device device) + { + this.BatteryLevel = device.Battery.ToString() + "%"; + this.BarColor = new SolidColorBrush(Color.FromRgb(device.LightBarColor.red, device.LightBarColor.green, device.LightBarColor.blue)); + } + + + public event PropertyChangedEventHandler PropertyChanged; + } +} From b1d0a398cef394ff78fbc995707bcc090a8c64e4 Mon Sep 17 00:00:00 2001 From: SergueiFedorov Date: Fri, 6 Feb 2015 09:44:21 -0600 Subject: [PATCH 03/20] Starting the cleanup process --- DS4Tool/Options.cs | 84 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 19 deletions(-) diff --git a/DS4Tool/Options.cs b/DS4Tool/Options.cs index b37a5c769d..33f15e00e1 100644 --- a/DS4Tool/Options.cs +++ b/DS4Tool/Options.cs @@ -7,8 +7,24 @@ using System.IO; using System.Reflection; using System.Xml; +using System.Linq; + namespace DS4Windows { + public static class OptionsUIUtilities + { + public static void AddButtonsToButtonCollection(System.Windows.Forms.Control.ControlCollection controls, List