diff options
| author | Tomáš Pazdiora <[email protected]> | 2021-01-07 23:21:33 +0100 |
|---|---|---|
| committer | Tomáš Pazdiora <[email protected]> | 2021-01-07 23:21:33 +0100 |
| commit | 215a21f9b62aa50d9ca4037ca0a22f5b0920f373 (patch) | |
| tree | 3f0cbca12e4575cc325c86996d952d01829b2acd | |
| parent | update devicelist app (diff) | |
| download | rawaccel-215a21f9b62aa50d9ca4037ca0a22f5b0920f373.tar.xz rawaccel-215a21f9b62aa50d9ca4037ca0a22f5b0920f373.zip | |
rough GUI integration of "Device Hardware ID"
| -rw-r--r-- | devicelist/App.config | 6 | ||||
| -rw-r--r-- | devicelist/Program.cs | 37 | ||||
| -rw-r--r-- | devicelist/Properties/AssemblyInfo.cs | 36 | ||||
| -rw-r--r-- | devicelist/devicelist.csproj | 73 | ||||
| -rw-r--r-- | grapher/Form1.Designer.cs | 31 | ||||
| -rw-r--r-- | grapher/Form1.cs | 1 | ||||
| -rw-r--r-- | grapher/Models/AccelGUIFactory.cs | 2 | ||||
| -rw-r--r-- | grapher/Models/Devices/DeviceList.cs | 33 | ||||
| -rw-r--r-- | grapher/Models/Serialized/SettingsManager.cs | 66 | ||||
| -rw-r--r-- | grapher/grapher.csproj | 2 | ||||
| -rw-r--r-- | rawaccel.sln | 6 |
11 files changed, 124 insertions, 169 deletions
diff --git a/devicelist/App.config b/devicelist/App.config deleted file mode 100644 index 56efbc7..0000000 --- a/devicelist/App.config +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<configuration> - <startup> - <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> - </startup> -</configuration>
\ No newline at end of file diff --git a/devicelist/Program.cs b/devicelist/Program.cs deleted file mode 100644 index 9323fd4..0000000 --- a/devicelist/Program.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Text; -using System.Management; -using System.Windows.Forms; - -namespace devicelist -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("To use Raw Accel driver for a specific device, " - + "replace '\"Device Hardware ID\": null' in 'settings.json' by following:"); - Console.WriteLine(""); - - ManagementObjectSearcher searcher = new ManagementObjectSearcher(new SelectQuery("Win32_PnPEntity")); - - foreach (ManagementObject obj in searcher.Get()) - { - bool is_mouse = obj["PNPClass"] != null && obj["PNPClass"].ToString() == "Mouse"; // == "HIDClass" ??? - - if (is_mouse && obj["HardwareID"] != null) { - String[] hwidArray = (String[])(obj["HardwareID"]); - if (hwidArray.Length > 0) { - String hwid = hwidArray[0].ToString().Replace(@"\", @"\\"); - String name = obj["Name"].ToString(); - Console.WriteLine(name + ":"); - Console.WriteLine("\"Device Hardware ID\": \"" + hwid + "\""); - Console.WriteLine(""); - } - } - } - - Console.ReadKey(); - } - } -} diff --git a/devicelist/Properties/AssemblyInfo.cs b/devicelist/Properties/AssemblyInfo.cs deleted file mode 100644 index 36f0015..0000000 --- a/devicelist/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 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("Raw Accel devicelist")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Raw Accel")] -[assembly: AssemblyCopyright("")] -[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)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3666b731-7406-41b1-bcfc-c65073fd09a1")] - -// 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(RawAccelVersion.value)] -[assembly: AssemblyFileVersion(RawAccelVersion.value)] diff --git a/devicelist/devicelist.csproj b/devicelist/devicelist.csproj deleted file mode 100644 index 154d0d0..0000000 --- a/devicelist/devicelist.csproj +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{3666B731-7406-41B1-BCFC-C65073FD09A1}</ProjectGuid> - <OutputType>Exe</OutputType> - <RootNamespace>devicelist</RootNamespace> - <AssemblyName>devicelist</AssemblyName> - <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> - <Deterministic>true</Deterministic> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> - <DebugSymbols>true</DebugSymbols> - <OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <DebugType>full</DebugType> - <PlatformTarget>x64</PlatformTarget> - <LangVersion>7.3</LangVersion> - <ErrorReport>prompt</ErrorReport> - <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> - <Prefer32Bit>true</Prefer32Bit> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> - <OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <Optimize>true</Optimize> - <DebugType>pdbonly</DebugType> - <PlatformTarget>x64</PlatformTarget> - <LangVersion>7.3</LangVersion> - <ErrorReport>prompt</ErrorReport> - <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> - <Prefer32Bit>true</Prefer32Bit> - </PropertyGroup> - <PropertyGroup> - <StartupObject /> - </PropertyGroup> - <ItemGroup> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Management" /> - <Reference Include="System.Windows.Forms" /> - <Reference Include="System.Xml.Linq" /> - <Reference Include="System.Data.DataSetExtensions" /> - <Reference Include="Microsoft.CSharp" /> - <Reference Include="System.Data" /> - <Reference Include="System.Net.Http" /> - <Reference Include="System.Xml" /> - <Reference Include="System.Management" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Program.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - </ItemGroup> - <ItemGroup> - <None Include="App.config" /> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\wrapper\wrapper.vcxproj"> - <Project>{28a3656f-a1de-405c-b547-191c32ec555f}</Project> - <Name>wrapper</Name> - </ProjectReference> - </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <PropertyGroup> - <PostBuildEvent>IF ($(ConfigurationName)) == (Debug) GOTO END -copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)" -:END</PostBuildEvent> - </PropertyGroup> -</Project>
\ No newline at end of file diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 6fd9478..c388d79 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -161,6 +161,8 @@ namespace grapher this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.wholeVectorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.byVectorComponentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.UseSpecificDeviceMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.chartsPanel = new System.Windows.Forms.Panel(); this.GainChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.VelocityChartY = new System.Windows.Forms.DataVisualization.Charting.Chart(); @@ -168,7 +170,6 @@ namespace grapher this.GainChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.VelocityChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsPanel.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.chartsPanel.SuspendLayout(); @@ -956,7 +957,8 @@ namespace grapher this.capStyleToolStripMenuItem, this.offsetStyleToolStripMenuItem, this.toolStripMenuItem1, - this.AutoWriteMenuItem}); + this.AutoWriteMenuItem, + this.UseSpecificDeviceMenuItem}); this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem"; this.advancedToolStripMenuItem.Size = new System.Drawing.Size(72, 20); this.advancedToolStripMenuItem.Text = "Advanced"; @@ -1029,6 +1031,21 @@ namespace grapher this.byVectorComponentToolStripMenuItem.Size = new System.Drawing.Size(154, 22); this.byVectorComponentToolStripMenuItem.Text = "By Component"; // + // AutoWriteMenuItem + // + this.AutoWriteMenuItem.Checked = true; + this.AutoWriteMenuItem.CheckOnClick = true; + this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.AutoWriteMenuItem.Name = "AutoWriteMenuItem"; + this.AutoWriteMenuItem.Size = new System.Drawing.Size(210, 22); + this.AutoWriteMenuItem.Text = "Apply Settings On Startup"; + // + // UseSpecificDeviceMenuItem + // + this.UseSpecificDeviceMenuItem.Name = "UseSpecificDeviceMenuItem"; + this.UseSpecificDeviceMenuItem.Size = new System.Drawing.Size(210, 22); + this.UseSpecificDeviceMenuItem.Text = "Use Specific Device"; + // // chartsPanel // this.chartsPanel.AutoScroll = true; @@ -1281,15 +1298,6 @@ namespace grapher title6.Text = "Sensitivity"; this.AccelerationChart.Titles.Add(title6); // - // AutoWriteMenuItem - // - this.AutoWriteMenuItem.Checked = true; - this.AutoWriteMenuItem.CheckOnClick = true; - this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.AutoWriteMenuItem.Name = "AutoWriteMenuItem"; - this.AutoWriteMenuItem.Size = new System.Drawing.Size(210, 22); - this.AutoWriteMenuItem.Text = "Apply Settings On Startup"; - // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1418,6 +1426,7 @@ namespace grapher private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChart; private System.Windows.Forms.DataVisualization.Charting.Chart AccelerationChart; private System.Windows.Forms.ToolStripMenuItem AutoWriteMenuItem; + private System.Windows.Forms.ToolStripMenuItem UseSpecificDeviceMenuItem; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 0c12b86..e149163 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -71,6 +71,7 @@ namespace grapher gainOffsetToolStripMenuItem, legacyOffsetToolStripMenuItem, AutoWriteMenuItem, + UseSpecificDeviceMenuItem, ScaleMenuItem, DPITextBox, PollRateTextBox, diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index 901a1b5..0e3646d 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -34,6 +34,7 @@ namespace grapher.Models ToolStripMenuItem gainOffsetToolStripMenuItem, ToolStripMenuItem legacyOffsetToolStripMenuItem, ToolStripMenuItem autoWriteMenuItem, + ToolStripMenuItem useSpecificDeviceMenuItem, ToolStripMenuItem scaleMenuItem, ToolStripTextBox dpiTextBox, ToolStripTextBox pollRateTextBox, @@ -329,6 +330,7 @@ namespace grapher.Models accelCalculator.DPI, accelCalculator.PollRate, autoWriteMenuItem, + useSpecificDeviceMenuItem, showLastMouseMoveMenuItem, showVelocityGainToolStripMenuItem); diff --git a/grapher/Models/Devices/DeviceList.cs b/grapher/Models/Devices/DeviceList.cs new file mode 100644 index 0000000..9f2b81d --- /dev/null +++ b/grapher/Models/Devices/DeviceList.cs @@ -0,0 +1,33 @@ +using System; +using System.Management; +using System.Collections.Generic; + +namespace grapher.Models.Devices +{ + class DeviceList + { + public static List<Tuple<string, string>> GetDeviceHardwareIDs(string PNPClass = "Mouse") + { + var results = new List<Tuple<string, string>>(); + + ManagementObjectSearcher searcher = new ManagementObjectSearcher(new SelectQuery("Win32_PnPEntity")); + + foreach (ManagementObject obj in searcher.Get()) + { + if (obj["PNPClass"] != null && obj["PNPClass"].ToString() == PNPClass && obj["HardwareID"] != null) + { + String[] hwidArray = (String[])(obj["HardwareID"]); + if (hwidArray.Length > 0) + { + String hwid = hwidArray[0].ToString(); + String name = obj["Name"].ToString(); + results.Add(Tuple.Create(name, hwid)); + } + } + } + + return results; + } + + } +} diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs index 41ebcb5..3adbc8b 100644 --- a/grapher/Models/Serialized/SettingsManager.cs +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -3,6 +3,7 @@ using System; using System.Windows.Forms; using System.Threading; using System.Text; +using System.Drawing; namespace grapher.Models.Serialized { @@ -15,6 +16,7 @@ namespace grapher.Models.Serialized Field dpiField, Field pollRateField, ToolStripMenuItem autoWrite, + ToolStripMenuItem useSpecificDevice, ToolStripMenuItem showLastMouseMove, ToolStripMenuItem showVelocityAndGain) { @@ -22,6 +24,7 @@ namespace grapher.Models.Serialized DpiField = dpiField; PollRateField = pollRateField; AutoWriteMenuItem = autoWrite; + UseSpecificDeviceMenuItem = useSpecificDevice; ShowLastMouseMoveMenuItem = showLastMouseMove; ShowVelocityAndGainMoveMenuItem = showVelocityAndGain; } @@ -40,6 +43,8 @@ namespace grapher.Models.Serialized private ToolStripMenuItem AutoWriteMenuItem { get; set; } + private ToolStripMenuItem UseSpecificDeviceMenuItem { get; set; } + private ToolStripMenuItem ShowLastMouseMoveMenuItem { get; set; } private ToolStripMenuItem ShowVelocityAndGainMoveMenuItem { get; set; } @@ -61,6 +66,66 @@ namespace grapher.Models.Serialized return errors; } + private void SpecificDeviceClickHnadler(Object o, EventArgs a, string hwid) + { + var item = (ToolStripMenuItem)o; + foreach (ToolStripMenuItem i in UseSpecificDeviceMenuItem.DropDownItems) + { + i.Checked = false; + } + item.Checked = true; + if (hwid == null || hwid == "") + { + UseSpecificDeviceMenuItem.Checked = false; + } else + { + UseSpecificDeviceMenuItem.Checked = true; + } + RawAccelSettings.AccelerationSettings.deviceHardwareID = hwid; + + TryUpdateActiveSettings(RawAccelSettings.AccelerationSettings); + + } + private void UpdateUseSpecificDeviceMenu() + { + var hwid = RawAccelSettings.AccelerationSettings.deviceHardwareID; + if (hwid == null) { hwid = ""; } + + UseSpecificDeviceMenuItem.Checked = hwid.Length > 0; + UseSpecificDeviceMenuItem.DropDownItems.Clear(); + + var any_device = new ToolStripMenuItem(); + any_device.Text = ""; + any_device.Checked = hwid.Length == 0; + any_device.Click += new EventHandler(delegate(Object o, EventArgs a) { SpecificDeviceClickHnadler(o, a, ""); }); + UseSpecificDeviceMenuItem.DropDownItems.Add(any_device); + + var hwid_not_found = true; + + foreach (Tuple<string,string> device in Models.Devices.DeviceList.GetDeviceHardwareIDs()) + { + if (hwid == device.Item2) + { + hwid_not_found = false; + } + var dev = new ToolStripMenuItem(); + dev.Text = device.Item1; + dev.Checked = device.Item2 == RawAccelSettings.AccelerationSettings.deviceHardwareID; + dev.Click += new EventHandler(delegate (Object o, EventArgs a) { SpecificDeviceClickHnadler(o, a, device.Item2); }); + UseSpecificDeviceMenuItem.DropDownItems.Add(dev); + } + + if (hwid.Length > 0 && hwid_not_found) + { + var current_hwid = new ToolStripMenuItem(); + current_hwid.Text = "Disconnected (" + hwid + ")"; + current_hwid.ForeColor = Color.DarkGray; + current_hwid.Checked = true; + current_hwid.Click += new EventHandler(delegate (Object o, EventArgs a) { SpecificDeviceClickHnadler(o, a, hwid); }); + UseSpecificDeviceMenuItem.DropDownItems.Add(current_hwid); + } + } + public void UpdateFieldsFromGUISettings() { DpiField.SetToEntered(RawAccelSettings.GUISettings.DPI); @@ -110,6 +175,7 @@ namespace grapher.Models.Serialized { RawAccelSettings = RawAccelSettings.Load(() => MakeGUISettingsFromFields()); UpdateFieldsFromGUISettings(); + UpdateUseSpecificDeviceMenu(); if (RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup) { TryUpdateAccel(RawAccelSettings.AccelerationSettings); diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index f6bdcb9..8adfa75 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -59,6 +59,7 @@ </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> + <Reference Include="System.Management" /> <Reference Include="System.Windows.Forms.DataVisualization" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> @@ -92,6 +93,7 @@ <Compile Include="Models\Charts\EstimatedPoints.cs" /> <Compile Include="Models\Charts\ChartState\XYOneGraphState.cs" /> <Compile Include="Models\Charts\ChartState\XYTwoGraphState.cs" /> + <Compile Include="Models\Devices\DeviceList.cs" /> <Compile Include="Models\Mouse\MouseData.cs" /> <Compile Include="Models\Mouse\MouseWatcher.cs" /> <Compile Include="Models\Mouse\PointData.cs" /> diff --git a/rawaccel.sln b/rawaccel.sln index fc3d256..9b3978c 100644 --- a/rawaccel.sln +++ b/rawaccel.sln @@ -27,8 +27,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "converter", "converter\conv {28A3656F-A1DE-405C-B547-191C32EC555F} = {28A3656F-A1DE-405C-B547-191C32EC555F} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "devicelist", "devicelist\devicelist.csproj", "{3666B731-7406-41B1-BCFC-C65073FD09A1}" -EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution common\common.vcxitems*{24b4226f-1461-408f-a1a4-1371c97153ea}*SharedItemsImports = 9 @@ -75,10 +73,6 @@ Global {4C421992-9A27-4860-A40C-ADD76FBACE55}.Debug|x64.Build.0 = Debug|x64 {4C421992-9A27-4860-A40C-ADD76FBACE55}.Release|x64.ActiveCfg = Release|x64 {4C421992-9A27-4860-A40C-ADD76FBACE55}.Release|x64.Build.0 = Release|x64 - {3666B731-7406-41B1-BCFC-C65073FD09A1}.Debug|x64.ActiveCfg = Debug|x64 - {3666B731-7406-41B1-BCFC-C65073FD09A1}.Debug|x64.Build.0 = Debug|x64 - {3666B731-7406-41B1-BCFC-C65073FD09A1}.Release|x64.ActiveCfg = Release|x64 - {3666B731-7406-41B1-BCFC-C65073FD09A1}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE |