diff options
38 files changed, 1273 insertions, 93 deletions
diff --git a/common/common.vcxitems b/common/common.vcxitems index 69b4a69..2b03405 100644 --- a/common/common.vcxitems +++ b/common/common.vcxitems @@ -26,6 +26,7 @@ <ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-io-def.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-io.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-settings.h" /> + <ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-version.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)rawaccel.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)utility-install.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)x64-util.hpp" /> diff --git a/common/rawaccel-error.hpp b/common/rawaccel-error.hpp index ecee526..cdbe1e5 100644 --- a/common/rawaccel-error.hpp +++ b/common/rawaccel-error.hpp @@ -8,17 +8,13 @@ namespace rawaccel { using std::runtime_error::runtime_error; }; - class invalid_argument : public error { - using error::error; - }; - class io_error : public error { using error::error; }; class install_error : public io_error { public: - install_error() : io_error("rawaccel is not installed") {} + install_error() : io_error("Raw Accel driver is not installed, run installer.exe") {} }; } diff --git a/common/rawaccel-io-def.h b/common/rawaccel-io-def.h index 791addb..d8d4088 100644 --- a/common/rawaccel-io-def.h +++ b/common/rawaccel-io-def.h @@ -10,3 +10,4 @@ #define RA_READ CTL_CODE(RA_DEV_TYPE, 0x888, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) #define RA_WRITE CTL_CODE(RA_DEV_TYPE, 0x889, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define RA_GET_VERSION CTL_CODE(RA_DEV_TYPE, 0x88a, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) diff --git a/common/rawaccel-io.hpp b/common/rawaccel-io.hpp index 4159b60..703ea92 100644 --- a/common/rawaccel-io.hpp +++ b/common/rawaccel-io.hpp @@ -7,6 +7,7 @@ #include "rawaccel-io-def.h" #include "rawaccel-settings.h" +#include "rawaccel-version.h" #include "rawaccel-error.hpp" #pragma warning(push) @@ -55,6 +56,12 @@ namespace rawaccel { io_control(RA_WRITE, in_ptr, sizeof(settings), NULL, 0); } + version_t get_version() { + version_t ver; + io_control(RA_GET_VERSION, NULL, 0, &ver, sizeof(version_t)); + return ver; + } + } #pragma warning(pop) diff --git a/common/rawaccel-version.h b/common/rawaccel-version.h new file mode 100644 index 0000000..c9828a0 --- /dev/null +++ b/common/rawaccel-version.h @@ -0,0 +1,26 @@ +#pragma once + +#define RA_VER_MAJOR 1 +#define RA_VER_MINOR 3 +#define RA_VER_PATCH 0 + +#define RA_MIN_OS "Win10" + +#define M_STR_HELPER(x) #x +#define M_STR(x) M_STR_HELPER(x) + +#define RA_VER_STRING M_STR(RA_VER_MAJOR) "." M_STR(RA_VER_MINOR) "." M_STR(RA_VER_PATCH) + +namespace rawaccel { + + struct version_t { + int major; + int minor; + int patch; + }; + +#ifndef _KERNEL_MODE + inline constexpr version_t min_driver_version = { 1, 3, 0 }; +#endif + +} diff --git a/converter/AssemblyInfo.cpp b/converter/AssemblyInfo.cpp new file mode 100644 index 0000000..cbe3aec --- /dev/null +++ b/converter/AssemblyInfo.cpp @@ -0,0 +1,12 @@ +#include <rawaccel-version.h> + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +[assembly:AssemblyVersion(RA_VER_STRING)] + +[assembly:ComVisible(false)] ; +[assembly:CLSCompliantAttribute(true)] ; diff --git a/converter/converter.cpp b/converter/converter.cpp index af2699b..230e1be 100644 --- a/converter/converter.cpp +++ b/converter/converter.cpp @@ -192,7 +192,7 @@ bool try_convert(const ia_settings_t& ia_settings) { auto errors = DriverInterop::GetSettingsErrors(new_settings); if (!errors->Empty()) { - Console::WriteLine("Bad settings: " + errors->x->ToArray()[0]); + Console::WriteLine("Bad settings: {0}", errors); return false; } @@ -208,8 +208,26 @@ bool try_convert(const ia_settings_t& ia_settings) { return true; } +public ref struct ASSEMBLY { + static initonly Version^ VERSION = ASSEMBLY::typeid->Assembly->GetName()->Version; +}; + int main() { + auto close_prompt = [] { + std::cout << "Press any key to close this window . . ." << std::endl; + _getwch(); + std::exit(0); + }; + + try { + VersionHelper::ValidateAndGetDriverVersion(ASSEMBLY::VERSION); + } + catch (VersionException^ ex) { + Console::WriteLine(ex->Message); + close_prompt(); + } + std::optional<fs::path> opt_path; if (fs::exists(IA_SETTINGS_NAME)) { @@ -235,11 +253,8 @@ int main() if (!try_convert(parse_ia_settings(opt_path.value()))) std::cout << "Unable to convert settings.\n"; } - catch (DriverNotInstalledException^) { - Console::WriteLine("\nDriver is not installed."); - } catch (Exception^ e) { - Console::WriteLine("\nError: " + e->ToString()); + Console::WriteLine("\nError: {0}", e); } catch (const std::exception& e) { std::cout << "Error: " << e.what() << '\n'; @@ -251,6 +266,5 @@ int main() "Then run this program to generate the equivalent Raw Accel settings.\n"; } - std::cout << "Press any key to close this window . . ." << std::endl; - _getwch(); + close_prompt(); } diff --git a/converter/converter.rc b/converter/converter.rc new file mode 100644 index 0000000..94bc8b5 --- /dev/null +++ b/converter/converter.rc @@ -0,0 +1,100 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#include <rawaccel-version.h> + +VS_VERSION_INFO VERSIONINFO +FILEVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +PRODUCTVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif +FILEOS 0x40004L +FILETYPE 0x1L +FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "InterAccel -> RawAccel settings file converter" + VALUE "FileVersion", RA_VER_STRING + VALUE "OriginalFilename", "converter.exe" + VALUE "ProductName", "Raw Accel" + VALUE "ProductVersion", RA_VER_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/converter/converter.vcxproj b/converter/converter.vcxproj index 2bc5080..049dec7 100644 --- a/converter/converter.vcxproj +++ b/converter/converter.vcxproj @@ -67,6 +67,9 @@ <SubSystem>Console</SubSystem> <GenerateDebugInformation>DebugFull</GenerateDebugInformation> </Link> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -89,8 +92,12 @@ <PostBuildEvent> <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)"</Command> </PostBuildEvent> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> + <ClCompile Include="AssemblyInfo.cpp" /> <ClCompile Include="converter.cpp" /> </ItemGroup> <ItemGroup> @@ -103,6 +110,12 @@ <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> </ItemGroup> + <ItemGroup> + <ClInclude Include="resource.h" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="converter.rc" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/converter/converter.vcxproj.filters b/converter/converter.vcxproj.filters index 954dbfa..f1ad70a 100644 --- a/converter/converter.vcxproj.filters +++ b/converter/converter.vcxproj.filters @@ -18,5 +18,18 @@ <ClCompile Include="converter.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="AssemblyInfo.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="converter.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> </ItemGroup> </Project>
\ No newline at end of file diff --git a/converter/resource.h b/converter/resource.h new file mode 100644 index 0000000..a2c7ba8 --- /dev/null +++ b/converter/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by converter.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/driver/driver.cpp b/driver/driver.cpp index a4de824..a99a70b 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -1,5 +1,6 @@ #include <rawaccel.hpp> #include <rawaccel-io-def.h> +#include <rawaccel-version.h> #include "driver.h" @@ -190,6 +191,20 @@ Return Value: global.modifier = { global.args, global.lookups }; } break; + case RA_GET_VERSION: + status = WdfRequestRetrieveOutputBuffer( + Request, + sizeof(ra::version_t), + &buffer, + NULL + ); + if (!NT_SUCCESS(status)) { + DebugPrint(("RetrieveOutputBuffer failed: 0x%x\n", status)); + } + else { + *reinterpret_cast<ra::version_t*>(buffer) = { RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH }; + } + break; default: status = STATUS_INVALID_DEVICE_REQUEST; break; diff --git a/driver/driver.rc b/driver/driver.rc new file mode 100644 index 0000000..e351ac3 --- /dev/null +++ b/driver/driver.rc @@ -0,0 +1,47 @@ +// +// Include the necessary resources +// +#include <winver.h> +#include <ntdef.h> + +#include <rawaccel-version.h> + +#ifdef RC_INVOKED + +// +// Set up debug information +// +#if DBG +#define VER_DBG VS_FF_DEBUG +#else +#define VER_DBG 0 +#endif + +// ------- version info ------------------------------------------------------- + +VS_VERSION_INFO VERSIONINFO +FILEVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +PRODUCTVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS VER_DBG +FILEOS VOS_NT +FILETYPE VFT_DRV +FILESUBTYPE VFT2_DRV_SYSTEM +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "mouse acceleration filter driver" + VALUE "FileVersion", RA_VER_STRING + VALUE "OriginalFilename", "rawaccel.sys" + VALUE "ProductName", "Raw Accel" + VALUE "ProductVersion", RA_VER_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1200 + END +END +#endif
\ No newline at end of file diff --git a/driver/driver.vcxproj b/driver/driver.vcxproj index f9b7b67..d8cfd40 100644 --- a/driver/driver.vcxproj +++ b/driver/driver.vcxproj @@ -93,6 +93,9 @@ </IgnoreAllDefaultLibraries> <AdditionalDependencies>%(AdditionalDependencies);$(KernelBufferOverflowLib);$(DDK_LIB_PATH)ntoskrnl.lib;$(DDK_LIB_PATH)hal.lib;$(DDK_LIB_PATH)wmilib.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfLdr.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfDriverEntry.lib;$(DDK_LIB_PATH)wdmsec.lib;$(DDK_LIB_PATH)libcntpr.lib</AdditionalDependencies> </Link> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;$(UM_IncludePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> @@ -116,6 +119,9 @@ </IgnoreAllDefaultLibraries> <AdditionalDependencies>%(AdditionalDependencies);$(KernelBufferOverflowLib);$(DDK_LIB_PATH)ntoskrnl.lib;$(DDK_LIB_PATH)hal.lib;$(DDK_LIB_PATH)wmilib.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfLdr.lib;$(KMDF_LIB_PATH)$(KMDF_VER_PATH)\WdfDriverEntry.lib;$(DDK_LIB_PATH)wdmsec.lib;$(DDK_LIB_PATH)libcntpr.lib</AdditionalDependencies> </Link> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;$(UM_IncludePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="driver.cpp" /> @@ -130,5 +136,8 @@ <ItemGroup> <ClInclude Include="driver.h" /> </ItemGroup> + <ItemGroup> + <ResourceCompile Include="driver.rc" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> </Project>
\ No newline at end of file diff --git a/grapher/AboutBox.Designer.cs b/grapher/AboutBox.Designer.cs new file mode 100644 index 0000000..d5ab082 --- /dev/null +++ b/grapher/AboutBox.Designer.cs @@ -0,0 +1,138 @@ + +namespace grapher +{ + partial class AboutBox + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutBox)); + this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.logoPictureBox = new System.Windows.Forms.PictureBox(); + this.labelVersion = new System.Windows.Forms.Label(); + this.okButton = new System.Windows.Forms.Button(); + this.labelDriverVersion = new System.Windows.Forms.Label(); + this.tableLayoutPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit(); + this.SuspendLayout(); + // + // tableLayoutPanel + // + this.tableLayoutPanel.ColumnCount = 2; + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0); + this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1); + this.tableLayoutPanel.Controls.Add(this.okButton, 1, 4); + this.tableLayoutPanel.Controls.Add(this.labelDriverVersion, 1, 2); + this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel.Location = new System.Drawing.Point(9, 9); + this.tableLayoutPanel.Name = "tableLayoutPanel"; + this.tableLayoutPanel.RowCount = 5; + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel.Size = new System.Drawing.Size(280, 133); + this.tableLayoutPanel.TabIndex = 0; + // + // logoPictureBox + // + this.logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.logoPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("logoPictureBox.Image"))); + this.logoPictureBox.Location = new System.Drawing.Point(3, 3); + this.logoPictureBox.Name = "logoPictureBox"; + this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 5); + this.logoPictureBox.Size = new System.Drawing.Size(134, 127); + this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.logoPictureBox.TabIndex = 12; + this.logoPictureBox.TabStop = false; + // + // labelVersion + // + this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelVersion.Location = new System.Drawing.Point(146, 26); + this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); + this.labelVersion.MaximumSize = new System.Drawing.Size(0, 17); + this.labelVersion.Name = "labelVersion"; + this.labelVersion.Size = new System.Drawing.Size(131, 17); + this.labelVersion.TabIndex = 0; + this.labelVersion.Text = "GUI Version"; + this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.okButton.Location = new System.Drawing.Point(202, 107); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 24; + this.okButton.Text = "&OK"; + // + // labelDriverVersion + // + this.labelDriverVersion.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelDriverVersion.Location = new System.Drawing.Point(146, 52); + this.labelDriverVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); + this.labelDriverVersion.MaximumSize = new System.Drawing.Size(0, 17); + this.labelDriverVersion.Name = "labelDriverVersion"; + this.labelDriverVersion.Size = new System.Drawing.Size(131, 17); + this.labelDriverVersion.TabIndex = 25; + this.labelDriverVersion.Text = "Driver Version"; + this.labelDriverVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // AboutBox + // + this.AcceptButton = this.okButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(298, 151); + this.Controls.Add(this.tableLayoutPanel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AboutBox"; + this.Padding = new System.Windows.Forms.Padding(9); + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "AboutBox"; + this.tableLayoutPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; + private System.Windows.Forms.PictureBox logoPictureBox; + private System.Windows.Forms.Label labelVersion; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Label labelDriverVersion; + } +} diff --git a/grapher/AboutBox.cs b/grapher/AboutBox.cs new file mode 100644 index 0000000..5547c59 --- /dev/null +++ b/grapher/AboutBox.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher +{ + partial class AboutBox : Form + { + public AboutBox(Version driver) + { + InitializeComponent(); + this.Text = String.Format("About {0}", AssemblyTitle); + this.labelVersion.Text = String.Format("GUI Version {0}", AssemblyVersion); + this.labelDriverVersion.Text = String.Format("Driver Version {0}", driver.ToString()); + } + + #region Assembly Attribute Accessors + + public string AssemblyTitle + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); + if (attributes.Length > 0) + { + AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; + if (titleAttribute.Title != "") + { + return titleAttribute.Title; + } + } + return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); + } + } + + public string AssemblyVersion + { + get + { + return Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } + } + + #endregion + } +} diff --git a/grapher/AboutBox.resx b/grapher/AboutBox.resx new file mode 100644 index 0000000..e073ca0 --- /dev/null +++ b/grapher/AboutBox.resx @@ -0,0 +1,225 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> + <data name="logoPictureBox.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value> + iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + wwAADsMBx2+oZAAAFvZJREFUeF7tnQm8VVPfx3k8M+/zJEqpCKWJvA0qyRANPEiDkqkIiYgm0uQ1RmhA + hkemEl5JKIkIoZJ4yRBCiZKEzLP1/L7rrH0697zr3nvuvefce8656/f5/D57n7PXXmuvYa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fft29fcd999di4fQeF/EefotKtYqsIvCoq7pRifOdBbzZo1y/YIO++8s20ISTMH + dAlHu9tThu55mPt5AWgAzz//vLn22mvNJZdcYu69915fb7hY7K3TcptOlwuUqdoi4/H/xbIaw3vvvWfG + jx9v9ttvP7PXXnuZgQMHmqeeesoWWATdwxBxhU7Trt5VvI3FGaKdwpDuPffcY1q2bGkbwllnnVWgkhTu + CbGRu71YKOzh4pZph0Aa9DKXX365Oeyww+yL8OCDDyZrMt8X++g0/7SYytR/K3MoZDbZ3Ap0kUzRjjvu + OFO3bl3TokULK7UnCWjM3+eL3fQzrW+I4muoeOMNgVkNw1WDBg3Mrrvuai699FLz9ddfc4nn+Ekcp9O/ + u9uLhMI2VljkpMtE3vB4b4jAfOedd5qjjjrKHHDAAeaqq64yH3/8sbtq03pV7Oyiyi8of39V5nqLT4pW + mwdWrVplxo4daxo1amTfwmOOOcY89NBDBaaVCr5WHCPu5KJLCxQfCq6HXDJ2qogeAflgn332MTNnziRt + e01H3tL27tYC0P9VFQR5qIuIlnScyBSY4fD/TYnoFRBCmT3RAJhaR1B4cJOILqWKSyK/oMzVU+au1PFT + m2vhu+++M3fffbc55JBDzE477WSHCHoF5vQRFP5HEWm6uYsqLVDU7RTnklgqxqxcudJ0797d1KxZ0x5R + OQOFQVZhmkdDvkakgtfbiylC4W2FI4ckkv+Tof9oGct1vFhMeSjKGShTfxGPExeJtgQ4LFmyxJx66qmm + Vq1atlc4+eSTzXPPPRcvJMIKFP4R+pmWcVPxMGvgWWyL09E88MADtifo2bOn7b4LA2F5q1evXm2HNgS/ + YcOG2Tz07t3bdOnSxaqpmX0geCIMM+yhqEL+QCY6+OCDTdeuXc3w4cPtlBX1dpIWEywR0Vu01F/5JS8o + U03FW8S4dMTbjwS955572l6hffv2Vmj78ce49peCWSGeqNMyzR50/9Yi8opddo6QJKDat5f/6LoZqkaP + Hm2OOOIIK8tUqVIlrUQeofE//PDDVk5JhJ5lnThZpy1cFvIDylRVcZi4JpbV2FRy6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FXxK8B3CfAbjM8hjtjz03DYfs5GFMzR8CSO08l33nnHqnKVhou5IPQ/Y/sCcaR+ + 4hG1cszbswkqdIaIvcVzxHvFVeKWb9CmAYrvZ/EDcb7I0ms/kQ/tZOabuwFlgypnW7GZKqirjgPFi0S6 + 5tvEaeL0BLJR7k4dqdhxOh8h9td5N7GtznFwYX0dBwQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE + BAQEBAQE5CK22uo/qucXbjOUCEwAAAAASUVORK5CYII= +</value> + </data> +</root>
\ No newline at end of file diff --git a/grapher/Form1.cs b/grapher/Form1.cs index d62ed6d..0c12b86 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -13,6 +13,8 @@ using grapher.Models.Calculations; using grapher.Models.Options; using grapher.Models.Serialized; using grapher.Models; +using System.Reflection; +using System.Diagnostics; namespace grapher { @@ -26,21 +28,30 @@ namespace grapher { InitializeComponent(); - ManagedAccel activeAccel = null; + Version assemVersion = typeof(RawAcceleration).Assembly.GetName().Version; + Version driverVersion = null; try { - activeAccel = ManagedAccel.GetActiveAccel(); + driverVersion = VersionHelper.ValidateAndGetDriverVersion(assemVersion); } - catch (DriverNotInstalledException ex) + catch (VersionException ex) { - MessageBox.Show($"Driver not installed.\n\n {ex.ToString()}"); + MessageBox.Show(ex.Message); throw; } + + ToolStripMenuItem HelpMenuItem = new ToolStripMenuItem("&Help"); + + HelpMenuItem.DropDownItems.AddRange(new ToolStripItem[] { + new ToolStripMenuItem("&About", null, (s, e) => new AboutBox(driverVersion).ShowDialog()) + }); + + menuStrip1.Items.AddRange(new ToolStripItem[] { HelpMenuItem }); AccelGUI = AccelGUIFactory.Construct( this, - activeAccel, + ManagedAccel.GetActiveAccel(), AccelerationChart, AccelerationChartY, VelocityChart, diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index c08313b..f9291c1 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -153,7 +153,7 @@ namespace grapher } else { - throw new Exception($"Bad arguments: \n {SettingsManager.ErrorStringFrom(errors)}"); + throw new Exception($"Bad arguments:\n\n{errors}"); } } diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs index f13ba81..f5bb1f1 100644 --- a/grapher/Models/Serialized/SettingsManager.cs +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -47,35 +47,6 @@ namespace grapher.Models.Serialized #endregion Properties #region Methods - - public static string ErrorStringFrom(SettingsErrors errors) - { - StringBuilder builder = new StringBuilder(); - bool yPresent = errors.y?.Count > 0; - - if (yPresent) - { - builder.AppendLine("\nx:"); - } - - foreach (var error in errors.x) - { - builder.AppendLine(error); - } - - if (yPresent) - { - builder.AppendLine("\ny:"); - - foreach (var error in errors.y) - { - builder.AppendLine(error); - } - } - - return builder.ToString(); - } - public SettingsErrors TryUpdateActiveSettings(DriverSettings settings) { var errors = TryUpdateAccel(settings); diff --git a/grapher/Properties/AssemblyInfo.cs b/grapher/Properties/AssemblyInfo.cs index 939f98a..a46d6b3 100644 --- a/grapher/Properties/AssemblyInfo.cs +++ b/grapher/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ 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("grapher")] +[assembly: AssemblyTitle("Raw Accel GUI")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("grapher")] -[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyProduct("Raw Accel")] +[assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ 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.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion(RawAccelVersion.value)] +[assembly: AssemblyFileVersion(RawAccelVersion.value)] diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index a3e63ad..f6bdcb9 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -71,6 +71,12 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="AboutBox.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="AboutBox.Designer.cs"> + <DependentUpon>AboutBox.cs</DependentUpon> + </Compile> <Compile Include="Constants\Constants.cs" /> <Compile Include="Layouts\MotivityLayout.cs" /> <Compile Include="Layouts\NaturalGainLayout.cs" /> @@ -122,6 +128,9 @@ <Compile Include="Models\Serialized\SettingsManager.cs" /> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <EmbeddedResource Include="AboutBox.resx"> + <DependentUpon>AboutBox.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="Form1.resx"> <DependentUpon>Form1.cs</DependentUpon> </EmbeddedResource> diff --git a/installer/installer.rc b/installer/installer.rc new file mode 100644 index 0000000..4f56541 --- /dev/null +++ b/installer/installer.rc @@ -0,0 +1,100 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#include <rawaccel-version.h> + +VS_VERSION_INFO VERSIONINFO +FILEVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +PRODUCTVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif +FILEOS 0x40004L +FILETYPE 0x1L +FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "Raw Accel installer (" RA_MIN_OS ")" + VALUE "FileVersion", RA_VER_STRING + VALUE "OriginalFilename", "converter.exe" + VALUE "ProductName", "Raw Accel" + VALUE "ProductVersion", RA_VER_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/installer/installer.vcxproj b/installer/installer.vcxproj index fec4c1e..de4bb0e 100644 --- a/installer/installer.vcxproj +++ b/installer/installer.vcxproj @@ -70,6 +70,9 @@ <Manifest> <AdditionalManifestFiles>install.manifest</AdditionalManifestFiles> </Manifest> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -98,10 +101,19 @@ <PostBuildEvent> <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)"</Command> </PostBuildEvent> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="installer.cpp" /> </ItemGroup> + <ItemGroup> + <ClInclude Include="resource.h" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="installer.rc" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/installer/resource.h b/installer/resource.h new file mode 100644 index 0000000..98c3941 --- /dev/null +++ b/installer/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by installer.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/uninstaller/resource.h b/uninstaller/resource.h new file mode 100644 index 0000000..a56edf6 --- /dev/null +++ b/uninstaller/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by uninstaller.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/uninstaller/uninstaller.rc b/uninstaller/uninstaller.rc new file mode 100644 index 0000000..a9e8304 --- /dev/null +++ b/uninstaller/uninstaller.rc @@ -0,0 +1,97 @@ +// Microsoft Visual C++ generated resource script. +// + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#include <rawaccel-version.h> + +VS_VERSION_INFO VERSIONINFO +FILEVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +PRODUCTVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH +FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif +FILEOS 0x40004L +FILETYPE 0x1L +FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "Raw Accel uninstaller" + VALUE "FileVersion", RA_VER_STRING + VALUE "OriginalFilename", "uninstaller.exe" + VALUE "ProductName", "Raw Accel" + VALUE "ProductVersion", RA_VER_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/uninstaller/uninstaller.vcxproj b/uninstaller/uninstaller.vcxproj index f094c52..1098ed7 100644 --- a/uninstaller/uninstaller.vcxproj +++ b/uninstaller/uninstaller.vcxproj @@ -63,6 +63,9 @@ <GenerateDebugInformation>true</GenerateDebugInformation> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -84,10 +87,19 @@ <PostBuildEvent> <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)"</Command> </PostBuildEvent> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="uninstaller.cpp" /> </ItemGroup> + <ItemGroup> + <ClInclude Include="resource.h" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="uninstaller.rc" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/wrapper/AssemblyInfo.cpp b/wrapper/AssemblyInfo.cpp new file mode 100644 index 0000000..4854fd4 --- /dev/null +++ b/wrapper/AssemblyInfo.cpp @@ -0,0 +1,12 @@ +#include <rawaccel-version.h> + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +[assembly: AssemblyVersion(RA_VER_STRING)] + +[assembly:ComVisible(false)] ; +[assembly:CLSCompliantAttribute(true)] ; diff --git a/wrapper/resource.h b/wrapper/resource.h new file mode 100644 index 0000000..e41cd50 --- /dev/null +++ b/wrapper/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by wrapper.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index ee88112..acd0dbf 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -3,11 +3,15 @@ #include <type_traits> #include <rawaccel.hpp> +#include <rawaccel-version.h> #include "wrapper_io.hpp" using namespace System; using namespace System::Runtime::InteropServices; +using namespace System::Reflection; + +using namespace Windows::Forms; using namespace Newtonsoft::Json; @@ -129,9 +133,11 @@ using error_list_t = Collections::Generic::List<String^>; error_list_t^ get_accel_errors(AccelMode mode, AccelArgs^ args) { - accel_mode m = (accel_mode)mode; + accel_mode mode_native = (accel_mode)mode; - auto is_mode = [m](auto... modes) { return ((m == modes) || ...); }; + auto is_mode = [mode_native](auto... modes) { + return ((mode_native == modes) || ...); + }; using am = accel_mode; @@ -142,7 +148,7 @@ error_list_t^ get_accel_errors(AccelMode mode, AccelArgs^ args) else if (args->acceleration == 0 && is_mode(am::naturalgain)) error_list->Add("acceleration must be positive"); else if (args->acceleration < 0) { - bool additive = m < am::power; + bool additive = mode_native < am::power; if (additive) error_list->Add("acceleration can not be negative, use a negative weight to compensate"); else error_list->Add("acceleration can not be negative"); } @@ -161,6 +167,9 @@ error_list_t^ get_accel_errors(AccelMode mode, AccelArgs^ args) if (args->midpoint <= 0) error_list->Add("midpoint must be positive"); + if (args->offset < 0) + error_list->Add("offset can not be negative"); + return error_list; } @@ -172,7 +181,36 @@ public: bool Empty() { - return x->Count == 0 && y->Count == 0; + return (x == nullptr || x->Count == 0) && + (y == nullptr || y->Count == 0); + } + + virtual String^ ToString() override + { + if (x == nullptr) throw; + + Text::StringBuilder^ sb = gcnew Text::StringBuilder(); + + if (y == nullptr) // assume combineMagnitudes + { + for each (String^ str in x) + { + sb->AppendLine(str); + } + } + else + { + for each (String^ str in x) + { + sb->AppendFormat("x: {0}\n", str); + } + for each (String^ str in y) + { + sb->AppendFormat("y: {0}\n", str); + } + } + + return sb->ToString(); } }; @@ -202,8 +240,9 @@ public ref struct DriverInterop errors->x = get_accel_errors(args->modes.x, args->args.x); - if (args->combineMagnitudes) errors->y = gcnew error_list_t(); - else errors->y = get_accel_errors(args->modes.y, args->args.y); + if (!args->combineMagnitudes) { + errors->y = get_accel_errors(args->modes.y, args->args.y); + } return errors; } @@ -274,3 +313,59 @@ public: return active; } }; + +public ref struct RawAccelVersion +{ + literal String^ value = RA_VER_STRING; +}; + +public ref struct VersionException : public Exception +{ +public: + VersionException() {} + VersionException(String^ what) : Exception(what) {} +}; + +Version^ convert(rawaccel::version_t v) +{ + return gcnew Version(v.major, v.minor, v.patch, 0); +} + +public ref struct VersionHelper +{ + + static Version^ ValidateAndGetDriverVersion(Version^ wrapperTarget) + { + Version^ wrapperActual = VersionHelper::typeid->Assembly->GetName()->Version; + + if (wrapperTarget != wrapperActual) { + throw gcnew VersionException("version mismatch, expected wrapper.dll v" + wrapperActual); + } + + version_t drv_ver; + + try { + wrapper_io::getDriverVersion(drv_ver); + } + catch (DriverNotInstalledException^ ex) { + throw gcnew VersionException(ex->Message); + } + catch (DriverIOException^) { + // Assume version ioctl is unimplemented (driver version < v1.3.0) + throw gcnew VersionException("driver version is out of date, run installer.exe to reinstall"); + } + + Version^ drv_ver_managed = convert(drv_ver); + + if (drv_ver_managed < convert(min_driver_version)) { + throw gcnew VersionException("driver version is out of date, run installer.exe to reinstall"); + } + else if (drv_ver_managed > wrapperActual) { + throw gcnew VersionException("newer driver version is installed"); + } + else { + return drv_ver_managed; + } + } + +}; diff --git a/wrapper/wrapper.rc b/wrapper/wrapper.rc new file mode 100644 index 0000000..edb90d2 --- /dev/null +++ b/wrapper/wrapper.rc @@ -0,0 +1,100 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#include <rawaccel-version.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH + PRODUCTVERSION RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "managed interop & I/O" + VALUE "FileVersion", RA_VER_STRING + VALUE "OriginalFilename", "wrapper.dll" + VALUE "ProductName", "Raw Accel" + VALUE "ProductVersion", RA_VER_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/wrapper/wrapper.vcxproj b/wrapper/wrapper.vcxproj index 6c85a57..4f8ed1c 100644 --- a/wrapper/wrapper.vcxproj +++ b/wrapper/wrapper.vcxproj @@ -46,7 +46,12 @@ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> - <PropertyGroup /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> <WarningLevel>Level3</WarningLevel> @@ -56,6 +61,9 @@ <Link> <AdditionalDependencies /> </Link> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -70,11 +78,16 @@ <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)" & copy /Y "$(TargetDir)Newtonsoft.Json.dll" "$(SolutionDir)signed\Newtonsoft.Json.dll"</Command> </PostBuildEvent> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> + <ClInclude Include="resource.h" /> <ClInclude Include="wrapper_io.hpp" /> </ItemGroup> <ItemGroup> + <ClCompile Include="AssemblyInfo.cpp" /> <ClCompile Include="wrapper.cpp" /> <ClCompile Include="wrapper_io.cpp" /> </ItemGroup> @@ -82,6 +95,10 @@ copy /Y "$(TargetDir)Newtonsoft.Json.dll" "$(SolutionDir)signed\Newtonsoft.Json. <Reference Include="Newtonsoft.Json"> <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> + <Reference Include="System.Windows.Forms" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="wrapper.rc" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/wrapper/wrapper.vcxproj.filters b/wrapper/wrapper.vcxproj.filters index 88e539f..f265d72 100644 --- a/wrapper/wrapper.vcxproj.filters +++ b/wrapper/wrapper.vcxproj.filters @@ -18,6 +18,9 @@ <ClInclude Include="wrapper_io.hpp"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="resource.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="wrapper.cpp"> @@ -26,5 +29,13 @@ <ClCompile Include="wrapper_io.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="AssemblyInfo.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="wrapper.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> </ItemGroup> </Project>
\ No newline at end of file diff --git a/wrapper/wrapper_io.cpp b/wrapper/wrapper_io.cpp index 0f257bf..4b77174 100644 --- a/wrapper/wrapper_io.cpp +++ b/wrapper/wrapper_io.cpp @@ -3,11 +3,10 @@ #include <rawaccel-io.hpp> #include "wrapper_io.hpp" -void wrapper_io::writeToDriver(const settings& args) -{ - try +auto with_managed_ex = [](auto fn) { + try { - write(args); + fn(); } catch (const install_error&) { @@ -17,20 +16,25 @@ void wrapper_io::writeToDriver(const settings& args) { throw gcnew DriverIOException(gcnew String(e.what())); } +}; + +void wrapper_io::writeToDriver(const settings& args) +{ + with_managed_ex([&] { + write(args); + }); } void wrapper_io::readFromDriver(settings& args) { - try - { + with_managed_ex([&] { args = read(); - } - catch (const install_error&) - { - throw gcnew DriverNotInstalledException(); - } - catch (const std::system_error& e) - { - throw gcnew DriverIOException(gcnew String(e.what())); - } + }); +} + +void wrapper_io::getDriverVersion(version_t& ver) +{ + with_managed_ex([&] { + ver = get_version(); + }); } diff --git a/wrapper/wrapper_io.hpp b/wrapper/wrapper_io.hpp index 19f096f..6b94e46 100644 --- a/wrapper/wrapper_io.hpp +++ b/wrapper/wrapper_io.hpp @@ -1,6 +1,8 @@ #pragma once +#include <rawaccel-error.hpp> #include <rawaccel-settings.h> +#include <rawaccel-version.h> using namespace rawaccel; using namespace System; @@ -8,6 +10,7 @@ using namespace System; struct wrapper_io { static void writeToDriver(const settings&); static void readFromDriver(settings&); + static void getDriverVersion(version_t&); }; public ref struct DriverIOException : public IO::IOException { @@ -16,4 +19,7 @@ public: DriverIOException(String^ what) : IO::IOException(what) {} }; -public ref struct DriverNotInstalledException : public DriverIOException {}; +public ref struct DriverNotInstalledException : public DriverIOException { + DriverNotInstalledException() : + DriverIOException(gcnew String(install_error().what())) {} +}; diff --git a/writer/Program.cs b/writer/Program.cs index 2d4128f..ec8706b 100644 --- a/writer/Program.cs +++ b/writer/Program.cs @@ -21,18 +21,21 @@ namespace writer return; } - foreach (var err in errors.x) + Console.Write("Bad settings: \n\n{0}", errors); + } + + static void Main(string[] args) + { + try { - Console.WriteLine(err + (settings.combineMagnitudes ? "" : " (x)")); + VersionHelper.ValidateAndGetDriverVersion(typeof(Program).Assembly.GetName().Version); } - foreach (var err in errors.y) + catch (VersionException e) { - Console.WriteLine(err + " (y)"); + Console.WriteLine(e.Message); + return; } - } - static void Main(string[] args) - { if (args.Length != 1 || args[0].Equals("help")) { Console.WriteLine("USAGE: {0} <file>", System.AppDomain.CurrentDomain.FriendlyName); @@ -59,15 +62,11 @@ namespace writer } catch (JsonException e) { - Console.WriteLine("Settings invalid:\n{0}", e.Message.ToString()); - } - catch (DriverNotInstalledException) - { - Console.WriteLine("Driver is not installed"); + Console.WriteLine("Settings invalid:\n{0}", e.Message); } catch (Exception e) { - Console.WriteLine("Error: {0}", e.Message.ToString()); + Console.WriteLine("Error: {0}", e); } } } diff --git a/writer/Properties/AssemblyInfo.cs b/writer/Properties/AssemblyInfo.cs index 37e79ad..fc6a1ca 100644 --- a/writer/Properties/AssemblyInfo.cs +++ b/writer/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ 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("writer")] +[assembly: AssemblyTitle("Raw Accel settings writer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("writer")] -[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyProduct("Raw Accel")] +[assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ 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.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion(RawAccelVersion.value)] +[assembly: AssemblyFileVersion(RawAccelVersion.value)] |