diff options
| author | a1xd <[email protected]> | 2020-12-05 21:28:08 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-05 21:28:08 -0500 |
| commit | c8503654da5bc40a129e58914549cd394349d059 (patch) | |
| tree | e4760c579597d0e292c7b03dff95d19bb8f3c750 | |
| parent | Merge pull request #45 from JacobPalecki/fix (diff) | |
| parent | update signed, add installers (diff) | |
| download | rawaccel-c8503654da5bc40a129e58914549cd394349d059.tar.xz rawaccel-c8503654da5bc40a129e58914549cd394349d059.zip | |
Merge pull request #46 from a1xd/1.3
63 files changed, 1482 insertions, 273 deletions
@@ -28,6 +28,7 @@ bld/ [Ll]og/ signed/* !signed/driver/ +!signed/*install*.exe # Visual Studio 2015/2017 cache/options directory .vs/ diff --git a/common-install/common-install.vcxitems b/common-install/common-install.vcxitems deleted file mode 100644 index fa4e370..0000000 --- a/common-install/common-install.vcxitems +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup Label="Globals"> - <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> - <HasSharedItems>true</HasSharedItems> - <ItemsProjectGuid>{058d66c6-d88b-4fdb-b0e4-0a6fe7483b95}</ItemsProjectGuid> - </PropertyGroup> - <ItemDefinitionGroup> - <ClCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories> - </ClCompile> - </ItemDefinitionGroup> - <ItemGroup> - <ProjectCapability Include="SourceItemsFromImports" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="$(MSBuildThisFileDirectory)utility-install.hpp" /> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/common/common.vcxitems b/common/common.vcxitems index 1eabfd7..2b03405 100644 --- a/common/common.vcxitems +++ b/common/common.vcxitems @@ -23,9 +23,12 @@ <ClInclude Include="$(MSBuildThisFileDirectory)accel-noaccel.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)accel-power.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-error.hpp" /> + <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" /> <ClInclude Include="$(MSBuildThisFileDirectory)vec2.h" /> </ItemGroup> diff --git a/common-install/external/WinReg.hpp b/common/external/WinReg.hpp index 9ce2396..9ce2396 100644 --- a/common-install/external/WinReg.hpp +++ b/common/external/WinReg.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 new file mode 100644 index 0000000..d8d4088 --- /dev/null +++ b/common/rawaccel-io-def.h @@ -0,0 +1,13 @@ +#pragma once + +#ifdef _KERNEL_MODE +#include <ntddk.h> +#else +#include <winioctl.h> +#endif + +#define RA_DEV_TYPE 0x8888u + +#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 e8641d1..703ea92 100644 --- a/common/rawaccel-io.hpp +++ b/common/rawaccel-io.hpp @@ -5,18 +5,17 @@ #define NOMINMAX #include <Windows.h> +#include "rawaccel-io-def.h" #include "rawaccel-settings.h" +#include "rawaccel-version.h" #include "rawaccel-error.hpp" -#define RA_READ CTL_CODE(0x8888, 0x888, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) -#define RA_WRITE CTL_CODE(0x8888, 0x889, METHOD_BUFFERED, FILE_ANY_ACCESS) - #pragma warning(push) #pragma warning(disable:4245) // int -> DWORD conversion while passing CTL_CODE namespace rawaccel { - settings read() { + void io_control(DWORD code, void* in, DWORD in_size, void* out, DWORD out_size) { HANDLE ra_handle = INVALID_HANDLE_VALUE; ra_handle = CreateFileW(L"\\\\.\\rawaccel", 0, 0, 0, OPEN_EXISTING, 0, 0); @@ -25,18 +24,17 @@ namespace rawaccel { throw install_error(); } - settings args; DWORD dummy; BOOL success = DeviceIoControl( ra_handle, - RA_READ, - NULL, // input buffer - 0, // input buffer size - &args, // output buffer - sizeof(settings), // output buffer size - &dummy, // bytes returned - NULL // overlapped structure + code, + in, + in_size, + out, + out_size, + &dummy, // bytes returned + NULL // overlapped structure ); CloseHandle(ra_handle); @@ -44,38 +42,24 @@ namespace rawaccel { if (!success) { throw std::system_error(GetLastError(), std::system_category(), "DeviceIoControl failed"); } + } + settings read() { + settings args; + io_control(RA_READ, NULL, 0, &args, sizeof(settings)); return args; } void write(const settings& args) { - HANDLE ra_handle = INVALID_HANDLE_VALUE; - - ra_handle = CreateFileW(L"\\\\.\\rawaccel", 0, 0, 0, OPEN_EXISTING, 0, 0); - - if (ra_handle == INVALID_HANDLE_VALUE) { - throw install_error(); - } - - DWORD dummy; - - BOOL success = DeviceIoControl( - ra_handle, - RA_WRITE, - const_cast<settings*>(&args), // input buffer - sizeof(settings), // input buffer size - NULL, // output buffer - 0, // output buffer size - &dummy, // bytes returned - NULL // overlapped structure - ); - - CloseHandle(ra_handle); + auto in_ptr = const_cast<settings*>(&args); + io_control(RA_WRITE, in_ptr, sizeof(settings), NULL, 0); + } - if (!success) { - throw std::system_error(GetLastError(), std::system_category(), "DeviceIoControl failed"); - } + version_t get_version() { + version_t ver; + io_control(RA_GET_VERSION, NULL, 0, &ver, sizeof(version_t)); + return ver; } } diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h index e9e158c..649c936 100644 --- a/common/rawaccel-settings.h +++ b/common/rawaccel-settings.h @@ -21,6 +21,7 @@ namespace rawaccel { vec2<accel_mode> modes = { accel_mode::noaccel, accel_mode::noaccel }; vec2<accel_args> argsv; vec2d sens = { 1, 1 }; + vec2d dir_multipliers = {}; milliseconds time_min = DEFAULT_TIME_MIN; }; diff --git a/common/rawaccel-version.h b/common/rawaccel-version.h new file mode 100644 index 0000000..9470ca0 --- /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 "Win7" + +#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/common/rawaccel.hpp b/common/rawaccel.hpp index b160a42..3e049cb 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -233,6 +233,7 @@ namespace rawaccel { rotator rotate; vec2<accelerator> accels; vec2d sensitivity = { 1, 1 }; + vec2d directional_multipliers = {}; mouse_modifier(const settings& args, vec2<si_pair*> luts = {}) : combine_magnitudes(args.combine_mags) @@ -245,6 +246,9 @@ namespace rawaccel { if (args.sens.x != 0) sensitivity.x = args.sens.x; if (args.sens.y != 0) sensitivity.y = args.sens.y; + directional_multipliers.x = fabs(args.dir_multipliers.x); + directional_multipliers.y = fabs(args.dir_multipliers.y); + if ((combine_magnitudes && args.modes.x == accel_mode::noaccel) || (args.modes.x == accel_mode::noaccel && args.modes.y == accel_mode::noaccel)) { @@ -285,9 +289,16 @@ namespace rawaccel { } } - inline void apply_sensitivity(vec2d& movement) { + inline void apply_sensitivity(vec2d& movement) { movement.x *= sensitivity.x; movement.y *= sensitivity.y; + + if (directional_multipliers.x > 0 && movement.x < 0) { + movement.x *= directional_multipliers.x; + } + if (directional_multipliers.y > 0 && movement.y < 0) { + movement.y *= directional_multipliers.y; + } } mouse_modifier() = default; diff --git a/common-install/utility-install.hpp b/common/utility-install.hpp index e1823e4..e1823e4 100644 --- a/common-install/utility-install.hpp +++ b/common/utility-install.hpp 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 778f3be..a99a70b 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -1,10 +1,9 @@ #include <rawaccel.hpp> +#include <rawaccel-io-def.h> +#include <rawaccel-version.h> #include "driver.h" -#define RA_READ CTL_CODE(0x8888, 0x888, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) -#define RA_WRITE CTL_CODE(0x8888, 0x889, METHOD_BUFFERED, FILE_ANY_ACCESS) - #ifdef ALLOC_PRAGMA #pragma alloc_text (INIT, DriverEntry) #pragma alloc_text (PAGE, EvtDeviceAdd) @@ -144,70 +143,75 @@ Return Value: { NTSTATUS status; void* buffer; - size_t size; UNREFERENCED_PARAMETER(Queue); - - + UNREFERENCED_PARAMETER(OutputBufferLength); + UNREFERENCED_PARAMETER(InputBufferLength); PAGED_CODE(); DebugPrint(("Ioctl received into filter control object.\n")); - if (IoControlCode == RA_WRITE && InputBufferLength == sizeof(ra::settings)) { - LARGE_INTEGER interval; - interval.QuadPart = static_cast<LONGLONG>(ra::WRITE_DELAY) * -10000; - KeDelayExecutionThread(KernelMode, FALSE, &interval); - + switch (IoControlCode) { + case RA_READ: + status = WdfRequestRetrieveOutputBuffer( + Request, + sizeof(ra::settings), + &buffer, + NULL + ); + if (!NT_SUCCESS(status)) { + DebugPrint(("RetrieveOutputBuffer failed: 0x%x\n", status)); + } + else { + *reinterpret_cast<ra::settings*>(buffer) = global.args; + } + break; + case RA_WRITE: status = WdfRequestRetrieveInputBuffer( Request, sizeof(ra::settings), &buffer, - &size + NULL ); - if (!NT_SUCCESS(status)) { DebugPrint(("RetrieveInputBuffer failed: 0x%x\n", status)); - // status maps to win32 error code 1359: ERROR_INTERNAL_ERROR - WdfRequestComplete(Request, STATUS_MESSAGE_LOST); - return; } + else { + LARGE_INTEGER interval; + interval.QuadPart = static_cast<LONGLONG>(ra::WRITE_DELAY) * -10000; + KeDelayExecutionThread(KernelMode, FALSE, &interval); - ra::settings new_settings = *reinterpret_cast<ra::settings*>(buffer); + ra::settings new_settings = *reinterpret_cast<ra::settings*>(buffer); - if (new_settings.time_min <= 0 || _isnanf(static_cast<float>(new_settings.time_min))) { - new_settings.time_min = ra::settings{}.time_min; - } - - global.args = new_settings; - global.modifier = { global.args, global.lookups }; + if (new_settings.time_min <= 0 || _isnanf(static_cast<float>(new_settings.time_min))) { + new_settings.time_min = ra::settings{}.time_min; + } - WdfRequestComplete(Request, STATUS_SUCCESS); - } - else if (IoControlCode == RA_READ && OutputBufferLength == sizeof(ra::settings)) { + global.args = new_settings; + global.modifier = { global.args, global.lookups }; + } + break; + case RA_GET_VERSION: status = WdfRequestRetrieveOutputBuffer( Request, - sizeof(ra::settings), + sizeof(ra::version_t), &buffer, - &size + NULL ); - if (!NT_SUCCESS(status)) { DebugPrint(("RetrieveOutputBuffer failed: 0x%x\n", status)); - // status maps to win32 error code 1359: ERROR_INTERNAL_ERROR - WdfRequestComplete(Request, STATUS_MESSAGE_LOST); - return; } - - *reinterpret_cast<ra::settings*>(buffer) = global.args; - - WdfRequestComplete(Request, STATUS_SUCCESS); - } - else { - DebugPrint(("Received unknown request: in %uB, out %uB\n", InputBufferLength, OutputBufferLength)); - // status maps to win32 error code 1784: ERROR_INVALID_USER_BUFFER - WdfRequestComplete(Request, STATUS_INVALID_BUFFER_SIZE); + else { + *reinterpret_cast<ra::version_t*>(buffer) = { RA_VER_MAJOR, RA_VER_MINOR, RA_VER_PATCH }; + } + break; + default: + status = STATUS_INVALID_DEVICE_REQUEST; + break; } + WdfRequestComplete(Request, status); + } #pragma warning(pop) // enable 28118 again @@ -404,7 +408,7 @@ Error: WdfObjectDelete(controlDevice); } - DebugPrint(("CreateControlDevice failed\n", status)); + DebugPrint(("CreateControlDevice failed with status code 0x%x\n", status)); } 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 7df16a0..9034680 100644 --- a/driver/driver.vcxproj +++ b/driver/driver.vcxproj @@ -22,9 +22,9 @@ </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <TargetVersion>Windows10</TargetVersion> + <TargetVersion>Windows7</TargetVersion> <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Desktop</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -32,9 +32,9 @@ <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <TargetVersion>Windows10</TargetVersion> + <TargetVersion>Windows7</TargetVersion> <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> + <DriverTargetPlatform>Desktop</DriverTargetPlatform> <DriverType>KMDF</DriverType> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -55,10 +55,12 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetName>rawaccel</TargetName> <EnableInf2cat>false</EnableInf2cat> + <TimeStampServer>http://timestamp.globalsign.com/scripts/timstamp.dll</TimeStampServer> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetName>rawaccel</TargetName> <EnableInf2cat>false</EnableInf2cat> + <TimeStampServer>http://timestamp.globalsign.com/scripts/timstamp.dll</TimeStampServer> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -93,6 +95,12 @@ </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> + <DriverSign> + <FileDigestAlgorithm>sha256</FileDigestAlgorithm> + </DriverSign> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> @@ -101,7 +109,7 @@ <ExceptionHandling> </ExceptionHandling> <AdditionalOptions>/Kernel %(AdditionalOptions)</AdditionalOptions> - <LanguageStandard>stdcpplatest</LanguageStandard> + <LanguageStandard>stdcpp17</LanguageStandard> <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories);$(SolutionDir)\external;$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories> <RuntimeLibrary> </RuntimeLibrary> @@ -116,6 +124,12 @@ </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> + <DriverSign> + <FileDigestAlgorithm>sha256</FileDigestAlgorithm> + </DriverSign> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;$(UM_IncludePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="driver.cpp" /> @@ -130,5 +144,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/1X//1X/+9 + VUBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBGYYz58++//z5Dx806viCeJf6XuxyQ71Bl + 91PlJ4PGMFHH3V2wgHyFKno6Nf7LL7+YL7/80nz77bf8tNC1X8U5Yif9/IO7JSCf4N50Ktts3rzZLF26 + 1Dz++OPmrbfeMr/++iuXLHT9HXGQ+A93a0A6oAI9RpwnThPPFpurvP/oLmccSq+6+Lj4OxX922+/mXff + fdfccMMN5oILLjD333+/+fzzz7lkoWBfideJDVwUAaWFCrGJuOU12wLG4LniYMLo99buloxB6ewrPiD+ + xgPoaF599VUzYsQI06lTJ3PRRReZ119/nUsWhBPn6rSDmPHny0uoAAe5wr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YE26BBAztm5tM+fQRd9O+YsPuu + F0W2urPBNnKYDVRcONXKn6+FK0N2PxJvPk6KaADYqfkKJFfJx65LMhvAZQ56hKQPaSwSD3DFlj9Q3rAV + sPIAXSUNgH2AvoLJVdKweYuLMxZhmGCDK2rkCCobPtDVSaf59yHoCMogPgfszgQd886DJ8Ib9pB8GSX5 + GgocfBlhnEnjj1ApKj4Ryih+B2xPQGGV1n9QtpKdRJi3R78Z5saOHWt9KkRQ/gHfTWjviqVyQWWAkuha + SoECwSCkTZs2ObsqGJElYha4cGyFPQS+DFwWLXTOtxSniI1cUVRuqCDwHL6OwmHqwzSR7Vi+ws1m0nAx + bcPLSDKUvx9Evo52kli2b/znI1QobCaJfyYOaxZ8EZXXTuCykDe+devWdlxP0NZhCzFV5IsoHcVQ6alA + BcXHp1fYUhSQD1AXs8qWTQ6cML6oXbu23RvAtC8S6PTsfFX9RrG2y1JASaFyxMsIDaHAh6XYnMm6wdFH + H233DqBJLA95gTSocN50DC9YwZw1a5bdxBJBzwmwvWvqshGQDqhAa4ljRPuNgQgsuuCyDnMy/P2xAscb + ydyb2QS9BcYZkIorjFGYKBxH7sW8i/EcQxVkEr66yZ5APYd7ghj0G6eZE8RQ8ZmEynobEadU/xbX29JP + AGMvFjksNuGrEA+gqFXxK8B3CfAbjM8hjtjz03DYfs5GFMzR8CSO08l33nnHqnKVhou5IPQ/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..c6a2dcc 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -140,7 +140,8 @@ namespace grapher combineMagnitudes = ApplyOptions.IsWhole, modes = ApplyOptions.GetModes(), args = newArgs, - minimumTime = driverSettings.minimumTime + minimumTime = driverSettings.minimumTime, + directionalMultipliers = driverSettings.directionalMultipliers }; ButtonDelay(WriteButton); @@ -153,7 +154,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/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index 3dc2a74..901a1b5 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -2,6 +2,7 @@ using grapher.Models.Mouse; using grapher.Models.Options; using grapher.Models.Serialized; +using System; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; @@ -104,8 +105,8 @@ namespace grapher.Models Label mouseLabel) { var accelCalculator = new AccelCalculator( - new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI), - new Field(pollRateTextBox.TextBox, form, Constants.DefaultPollRate)); + new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI, 1), + new Field(pollRateTextBox.TextBox, form, Constants.DefaultPollRate, 1)); var accelCharts = new AccelCharts( form, @@ -331,7 +332,7 @@ namespace grapher.Models showLastMouseMoveMenuItem, showVelocityGainToolStripMenuItem); - var mouseWatcher = new MouseWatcher(form, mouseLabel, accelCharts, accelCalculator.PollRate); + var mouseWatcher = new MouseWatcher(form, mouseLabel, accelCharts, settings); return new AccelGUI( form, diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 60d4c89..71ee927 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -80,6 +80,11 @@ namespace grapher.Models.Calculations public int GetVelocityIndex(double outVelocityValue) { + if (outVelocityValue < 0) + { + throw new ArgumentException($"invalid velocity: {outVelocityValue}"); + } + var log = Math.Log10(outVelocityValue); if (log < -2) { diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs index 67d4f3f..d35217f 100644 --- a/grapher/Models/Calculations/AccelData.cs +++ b/grapher/Models/Calculations/AccelData.cs @@ -56,7 +56,7 @@ namespace grapher.Models.Calculations OutVelocityToPoints.Clear(); } - public void CalculateDots(int x, int y, double timeInMs) + public void CalculateDots(double x, double y, double timeInMs) { var outVelocity = AccelCalculator.Velocity(x, y, timeInMs); @@ -66,7 +66,7 @@ namespace grapher.Models.Calculations Estimated.Gain.Set(inCombVel, combGain); } - public void CalculateDotsXY(int x, int y, double timeInMs) + public void CalculateDotsXY(double x, double y, double timeInMs) { var outX = Math.Abs(x) / timeInMs; var outY = Math.Abs(y) / timeInMs; @@ -82,7 +82,7 @@ namespace grapher.Models.Calculations EstimatedY.Gain.Set(inYVelocity, yGain); } - public void CalculateDotsCombinedDiffSens(int x, int y, double timeInMs, DriverSettings settings) + public void CalculateDotsCombinedDiffSens(double x, double y, double timeInMs, DriverSettings settings) { (var xStripped, var yStripped) = AccelCalculator.StripSens(x, y, settings.sensitivity.x, settings.sensitivity.y); var outVelocity = AccelCalculator.Velocity(xStripped, yStripped, timeInMs); diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 6247811..b7abb35 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -99,7 +99,7 @@ namespace grapher #region Methods - public void MakeDots(int x, int y, double timeInMs) + public void MakeDots(double x, double y, double timeInMs) { ChartState.MakeDots(x, y, timeInMs); } diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs index 270e212..0bb141e 100644 --- a/grapher/Models/Charts/ChartState/ChartState.cs +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -40,7 +40,7 @@ namespace grapher.Models.Charts.ChartState internal bool TwoDotsPerGraph { get; set; } - public abstract void MakeDots(int x, int y, double timeInMs); + public abstract void MakeDots(double x, double y, double timeInMs); public abstract void Bind(); diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs index aab8a38..9eadb87 100644 --- a/grapher/Models/Charts/ChartState/CombinedState.cs +++ b/grapher/Models/Charts/ChartState/CombinedState.cs @@ -30,7 +30,7 @@ namespace grapher.Models.Charts.ChartState GainChart.ClearSecondDots(); } - public override void MakeDots(int x, int y, double timeInMs) + public override void MakeDots(double x, double y, double timeInMs) { Data.CalculateDots(x, y, timeInMs); } diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs index 92c799f..2b3cd9c 100644 --- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs @@ -28,7 +28,7 @@ namespace grapher.Models.Charts.ChartState GainChart.SetCombined(); } - public override void MakeDots(int x, int y, double timeInMs) + public override void MakeDots(double x, double y, double timeInMs) { Data.CalculateDotsCombinedDiffSens(x, y, timeInMs, Settings); } diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs index d107f87..732ea3c 100644 --- a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs @@ -33,7 +33,7 @@ namespace grapher.Models.Charts.ChartState GainChart.ClearSecondDots(); } - public override void MakeDots(int x, int y, double timeInMs) + public override void MakeDots(double x, double y, double timeInMs) { Data.CalculateDotsXY(x, y, timeInMs); } diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 98ba059..553ab3e 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -1,4 +1,5 @@ using grapher.Models.Mouse; +using System; using System.Collections; using System.Windows.Forms.DataVisualization.Charting; @@ -29,6 +30,8 @@ namespace grapher #endregion Constructors + private const double VerticalMargin = 0.1; + #region Properties public Chart ChartX { get; } @@ -219,28 +222,30 @@ namespace grapher ChartX.Series[2].IsVisibleInLegend = true; } - public void SetMinMax(double min, double max) + private void VerifyRange(double min, double max) { - if (min < max) + if (min > max) { - ChartX.ChartAreas[0].AxisY.Minimum = min * 0.95; - ChartX.ChartAreas[0].AxisY.Maximum = max * 1.05; + throw new ArgumentException($"invalid chart range: ({min}, {max})"); } } + public void SetMinMax(double min, double max) + { + VerifyRange(min, max); + ChartX.ChartAreas[0].AxisY.Minimum = min * (1 - VerticalMargin); + ChartX.ChartAreas[0].AxisY.Maximum = max * (1 + VerticalMargin); + } + public void SetMinMaxXY(double minX, double maxX, double minY, double maxY) { - if (minX < maxX) - { - ChartX.ChartAreas[0].AxisY.Minimum = minX * 0.95; - ChartX.ChartAreas[0].AxisY.Maximum = maxX * 1.05; - } + VerifyRange(minX, maxX); + ChartX.ChartAreas[0].AxisY.Minimum = minX * (1 - VerticalMargin); + ChartX.ChartAreas[0].AxisY.Maximum = maxX * (1 + VerticalMargin); - if (minY < maxY) - { - ChartY.ChartAreas[0].AxisY.Minimum = minY * 0.95; - ChartY.ChartAreas[0].AxisY.Maximum = maxY * 1.05; - } + VerifyRange(minY, maxY); + ChartX.ChartAreas[0].AxisY.Minimum = minY * (1 - VerticalMargin); + ChartX.ChartAreas[0].AxisY.Maximum = maxY * (1 + VerticalMargin); } public void SetCombined() diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs index 541bbe2..345f814 100644 --- a/grapher/Models/Fields/Field.cs +++ b/grapher/Models/Fields/Field.cs @@ -27,12 +27,16 @@ namespace grapher #region Constructors - public Field(TextBox box, Form containingForm, double defaultData) + public Field(TextBox box, Form containingForm, double defaultData, + double minData = double.MinValue, + double maxData = double.MaxValue) { DefaultText = DecimalString(defaultData); Box = box; _data = defaultData; DefaultData = defaultData; + MinData = minData; + MaxData = maxData; State = FieldState.Undefined; ContainingForm = containingForm; FormatString = Constants.DefaultFieldFormatString; @@ -69,7 +73,7 @@ namespace grapher { return DefaultData; } - } + } } public int Top @@ -122,6 +126,10 @@ namespace grapher private double DefaultData { get; set; } + private double MinData { get; } + + private double MaxData { get; } + #endregion Properties #region Methods @@ -268,12 +276,10 @@ namespace grapher private void TextToData() { - try - { - _data = Convert.ToDouble(Box.Text); - } - catch + if (double.TryParse(Box.Text, out double value) && + value <= MaxData && value >= MinData) { + _data = value; } Box.Text = DecimalString(Data); diff --git a/grapher/Models/Mouse/MouseWatcher.cs b/grapher/Models/Mouse/MouseWatcher.cs index 6209445..cbfc119 100644 --- a/grapher/Models/Mouse/MouseWatcher.cs +++ b/grapher/Models/Mouse/MouseWatcher.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Serialized; +using System; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -677,12 +678,12 @@ namespace grapher.Models.Mouse #region Constructors - public MouseWatcher(Form containingForm, Label display, AccelCharts accelCharts, Field pollRate) + public MouseWatcher(Form containingForm, Label display, AccelCharts accelCharts, SettingsManager setMngr) { ContainingForm = containingForm; Display = display; AccelCharts = accelCharts; - PollRateField = pollRate; + SettingsManager = setMngr; MouseData = new MouseData(); RAWINPUTDEVICE device = new RAWINPUTDEVICE(); @@ -694,8 +695,6 @@ namespace grapher.Models.Mouse RAWINPUTDEVICE[] devices = new RAWINPUTDEVICE[1]; devices[0] = device; RegisterRawInputDevices(devices, 1, Marshal.SizeOf(typeof(RAWINPUTDEVICE))); - PollTime = 1; - PollRate = 1000; } #endregion Constructors @@ -708,24 +707,19 @@ namespace grapher.Models.Mouse private AccelCharts AccelCharts { get; } - private Field PollRateField { get; set; } + private SettingsManager SettingsManager { get; } private MouseData MouseData { get; } - private double PollRate { get; set; } - - private double PollTime { get; set; } + private double PollTime + { + get => 1000 / SettingsManager.PollRateField.Data; + } #endregion Properties #region Methods - public void OnMouseMove(int x, int y, double timeInMs) - { - MouseData.Set(x,y); - AccelCharts.MakeDots(x, y, timeInMs); - } - public void UpdateLastMove() { MouseData.Get(out var x, out var y); @@ -740,15 +734,30 @@ namespace grapher.Models.Mouse outSize = GetRawInputData((IntPtr)message.LParam, RawInputCommand.Input, out rawInput, ref size, Marshal.SizeOf(typeof(RAWINPUTHEADER))); - if (PollRateField.Data != PollRate) - { - PollRate = PollRateField.Data; - PollTime = 1000 / PollRate; - } + bool relative = !rawInput.Data.Mouse.Flags.HasFlag(RawMouseFlags.MoveAbsolute); - if (rawInput.Data.Mouse.LastX != 0 || rawInput.Data.Mouse.LastY != 0) + if (relative && (rawInput.Data.Mouse.LastX != 0 || rawInput.Data.Mouse.LastY != 0)) { - OnMouseMove(rawInput.Data.Mouse.LastX, rawInput.Data.Mouse.LastY, PollTime); + double x = rawInput.Data.Mouse.LastX; + double y = rawInput.Data.Mouse.LastY; + + // strip negative directional multipliers, charts calculated from positive input + + Vec2<double> dirMults = SettingsManager.RawAccelSettings + .AccelerationSettings.directionalMultipliers; + + if (dirMults.x > 0 && x < 0) + { + x /= dirMults.x; + } + + if (dirMults.y > 0 && y < 0) + { + y /= dirMults.y; + } + + MouseData.Set(rawInput.Data.Mouse.LastX, rawInput.Data.Mouse.LastY); + AccelCharts.MakeDots(x, y, PollTime); } } diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs index af87a65..dcaf864 100644 --- a/grapher/Models/Serialized/RawAccelSettings.cs +++ b/grapher/Models/Serialized/RawAccelSettings.cs @@ -127,6 +127,8 @@ namespace grapher.Models.Serialized return accelSettings.sensitivity.x == 1 && accelSettings.sensitivity.y == 1 && + accelSettings.directionalMultipliers.x <= 0 && + accelSettings.directionalMultipliers.y <= 0 && accelSettings.rotation == 0 && accelSettings.modes.x == AccelMode.noaccel && wholeOrNoY; diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs index f13ba81..41ebcb5 100644 --- a/grapher/Models/Serialized/SettingsManager.cs +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -34,9 +34,9 @@ namespace grapher.Models.Serialized public RawAccelSettings RawAccelSettings { get; private set; } - private Field DpiField { get; set; } + public Field DpiField { get; private set; } - private Field PollRateField { get; set; } + public Field PollRateField { get; private set; } private ToolStripMenuItem AutoWriteMenuItem { get; set; } @@ -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/install.manifest b/installer/install.manifest index 0478246..f9b5ea3 100644 --- a/installer/install.manifest +++ b/installer/install.manifest @@ -4,6 +4,12 @@ <application> <!-- Windows 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 7 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> </application> </compatibility> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> diff --git a/installer/installer.cpp b/installer/installer.cpp index 06f234e..916209f 100644 --- a/installer/installer.cpp +++ b/installer/installer.cpp @@ -1,9 +1,8 @@ - - #include <iostream> #include <utility-install.hpp> #include <VersionHelpers.h> + void add_service(const fs::path& target) { SC_HANDLE schSCManager = OpenSCManager( NULL, // local computer @@ -43,8 +42,8 @@ void add_service(const fs::path& target) { int main() { try { - if (!IsWindows10OrGreater()) { - throw std::runtime_error("OS not supported, you need at least Windows 10"); + if (!IsWindows7OrGreater()) { + throw std::runtime_error("OS not supported, you need at least Windows 7"); } fs::path source = fs::path(L"driver") / DRIVER_FILE_NAME; diff --git a/installer/installer.rc b/installer/installer.rc new file mode 100644 index 0000000..43672d7 --- /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", "installer.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 8ff13a6..fa18344 100644 --- a/installer/installer.vcxproj +++ b/installer/installer.vcxproj @@ -35,7 +35,7 @@ <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Label="Shared"> - <Import Project="..\common-install\common-install.vcxitems" Label="Shared" /> + <Import Project="..\common\common.vcxitems" Label="Shared" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> @@ -70,6 +70,9 @@ <Manifest> <AdditionalManifestFiles>install.manifest</AdditionalManifestFiles> </Manifest> + <ResourceCompile> + <AdditionalIncludeDirectories>$(SolutionDir)/common;</AdditionalIncludeDirectories> + </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -96,12 +99,22 @@ <AdditionalManifestFiles>install.manifest</AdditionalManifestFiles> </Manifest> <PostBuildEvent> - <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)"</Command> + <Command> + </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/rawaccel.sln b/rawaccel.sln index aa226c1..9b3978c 100644 --- a/rawaccel.sln +++ b/rawaccel.sln @@ -9,8 +9,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common\common.vcx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "installer", "installer\installer.vcxproj", "{896950D1-520A-420A-B6B1-73014B92A68C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common-install", "common-install\common-install.vcxitems", "{058D66C6-D88B-4FDB-B0E4-0A6FE7483B95}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uninstaller", "uninstaller\uninstaller.vcxproj", "{A4097FF6-A6F0-44E8-B8D0-538D0FB75936}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wrapper", "wrapper\wrapper.vcxproj", "{28A3656F-A1DE-405C-B547-191C32EC555F}" @@ -31,13 +29,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "converter", "converter\conv EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution - common-install\common-install.vcxitems*{058d66c6-d88b-4fdb-b0e4-0a6fe7483b95}*SharedItemsImports = 9 common\common.vcxitems*{24b4226f-1461-408f-a1a4-1371c97153ea}*SharedItemsImports = 9 common\common.vcxitems*{28a3656f-a1de-405c-b547-191c32ec555f}*SharedItemsImports = 4 common\common.vcxitems*{4c421992-9a27-4860-a40c-add76fbace55}*SharedItemsImports = 4 common\common.vcxitems*{60d6c942-ac20-4c05-a2be-54b5c966534d}*SharedItemsImports = 4 - common-install\common-install.vcxitems*{896950d1-520a-420a-b6b1-73014b92a68c}*SharedItemsImports = 4 - common-install\common-install.vcxitems*{a4097ff6-a6f0-44e8-b8d0-538d0fb75936}*SharedItemsImports = 4 + common\common.vcxitems*{896950d1-520a-420a-b6b1-73014b92a68c}*SharedItemsImports = 4 + common\common.vcxitems*{a4097ff6-a6f0-44e8-b8d0-538d0fb75936}*SharedItemsImports = 4 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 diff --git a/signed/driver/rawaccel.sys b/signed/driver/rawaccel.sys Binary files differindex a390fc4..3762899 100644 --- a/signed/driver/rawaccel.sys +++ b/signed/driver/rawaccel.sys diff --git a/signed/installer.exe b/signed/installer.exe Binary files differnew file mode 100644 index 0000000..38f9201 --- /dev/null +++ b/signed/installer.exe diff --git a/signed/uninstaller.exe b/signed/uninstaller.exe Binary files differnew file mode 100644 index 0000000..aa59df9 --- /dev/null +++ b/signed/uninstaller.exe 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 f7e9f75..52e5583 100644 --- a/uninstaller/uninstaller.vcxproj +++ b/uninstaller/uninstaller.vcxproj @@ -35,7 +35,7 @@ <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Label="Shared"> - <Import Project="..\common-install\common-install.vcxitems" Label="Shared" /> + <Import Project="..\common\common.vcxitems" Label="Shared" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> @@ -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> @@ -82,12 +85,22 @@ <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <PostBuildEvent> - <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)"</Command> + <Command> + </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..fcbf2e8 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; @@ -67,7 +71,10 @@ public ref struct DriverSettings [JsonProperty("Sensitivity multipliers")] Vec2<double> sensitivity; - + + [JsonProperty("Negative directional multipliers", Required = Required::Default)] + Vec2<double> directionalMultipliers; + [JsonProperty(Required = Required::Default)] double minimumTime; @@ -129,9 +136,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 +151,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 +170,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 +184,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 +243,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 +316,63 @@ 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\n\nrun installer.exe to reinstall"); + } + + Version^ drv_ver_managed = convert(drv_ver); + + if (drv_ver_managed < convert(min_driver_version)) { + throw gcnew VersionException( + String::Format("driver version is out of date (v{0})\n\nrun installer.exe to reinstall", + drv_ver_managed)); + } + else if (drv_ver_managed > wrapperActual) { + throw gcnew VersionException( + String::Format("newer driver version is installed (v{0})", + drv_ver_managed)); + } + 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..37e384c 100644 --- a/writer/Program.cs +++ b/writer/Program.cs @@ -1,15 +1,21 @@ -using Microsoft.CSharp.RuntimeBinder; -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.IO; +using System.Windows.Forms; namespace writer { class Program { + + static void Show(string msg) + { + MessageBox.Show(msg, "Raw Accel writer"); + } + static void Send(JToken settingsToken) { var settings = settingsToken.ToObject<DriverSettings>(); @@ -21,27 +27,30 @@ namespace writer return; } - foreach (var err in errors.x) + Show($"Bad settings:\n\n{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)"); + Show(e.Message); + return; } - } - static void Main(string[] args) - { - if (args.Length != 1 || args[0].Equals("help")) + if (args.Length != 1) { - Console.WriteLine("USAGE: {0} <file>", System.AppDomain.CurrentDomain.FriendlyName); + Show($"Usage: {System.AppDomain.CurrentDomain.FriendlyName} <settings file path>"); return; } if (!File.Exists(args[0])) { - Console.WriteLine("Settings file not found at {0}", args[0]); + Show($"Settings file not found at {args[0]}"); return; } @@ -59,15 +68,11 @@ namespace writer } catch (JsonException e) { - Console.WriteLine("Settings invalid:\n{0}", e.Message.ToString()); - } - catch (DriverNotInstalledException) - { - Console.WriteLine("Driver is not installed"); + Show($"Settings invalid:\n\n{e.Message}"); } catch (Exception e) { - Console.WriteLine("Error: {0}", e.Message.ToString()); + Show($"Error:\n\n{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)] diff --git a/writer/writer.csproj b/writer/writer.csproj index a874b7f..1c4cca5 100644 --- a/writer/writer.csproj +++ b/writer/writer.csproj @@ -44,6 +44,7 @@ </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> + <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> |