diff options
| author | Jacob Palecki <[email protected]> | 2020-09-29 10:08:13 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-29 10:08:13 -0700 |
| commit | 49675a0fa01a1d7f04a7a2e31ec1872125a0cf37 (patch) | |
| tree | ac4a331892ff777de67deb8b8be8905bb017434e | |
| parent | Use 0 for cap\offset when not visible (diff) | |
| parent | set invisible args to default values before write (diff) | |
| download | rawaccel-49675a0fa01a1d7f04a7a2e31ec1872125a0cf37.tar.xz rawaccel-49675a0fa01a1d7f04a7a2e31ec1872125a0cf37.zip | |
merge + small fixes
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Alpha.zip | bin | 2072225 -> 0 bytes | |||
| -rw-r--r-- | common/accel-base.hpp | 2 | ||||
| -rw-r--r-- | converter/converter.cpp | 222 | ||||
| -rw-r--r-- | converter/converter.vcxproj | 109 | ||||
| -rw-r--r-- | converter/converter.vcxproj.filters | 22 | ||||
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 2 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelOptionSet.cs | 8 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 25 | ||||
| -rw-r--r-- | grapher/Models/Options/ApplyOptions.cs | 6 | ||||
| -rw-r--r-- | grapher/grapher.csproj | 38 | ||||
| -rw-r--r-- | grapher/mouse.ico | bin | 0 -> 112630 bytes | |||
| -rw-r--r-- | installer/installer.vcxproj | 3 | ||||
| -rw-r--r-- | rawaccel.sln | 20 | ||||
| -rw-r--r-- | uninstaller/uninstaller.vcxproj | 3 | ||||
| -rw-r--r-- | wrapper-deps/Class1.cs | 12 | ||||
| -rw-r--r-- | wrapper-deps/Properties/AssemblyInfo.cs | 36 | ||||
| -rw-r--r-- | wrapper-deps/packages.config | 4 | ||||
| -rw-r--r-- | wrapper-deps/wrapper-deps.csproj | 57 | ||||
| -rw-r--r-- | wrapper/wrapper.cpp | 19 | ||||
| -rw-r--r-- | wrapper/wrapper.vcxproj | 8 | ||||
| -rw-r--r-- | writer/packages.config | 4 | ||||
| -rw-r--r-- | writer/writer.csproj | 10 |
23 files changed, 579 insertions, 33 deletions
@@ -26,6 +26,8 @@ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ +signed/* +!signed/driver/ # Visual Studio 2015/2017 cache/options directory .vs/ diff --git a/Alpha.zip b/Alpha.zip Binary files differdeleted file mode 100644 index af777f0..0000000 --- a/Alpha.zip +++ /dev/null diff --git a/common/accel-base.hpp b/common/accel-base.hpp index 5106268..67a1b8f 100644 --- a/common/accel-base.hpp +++ b/common/accel-base.hpp @@ -48,7 +48,7 @@ namespace rawaccel { struct nonadditive_accel : accel_val_base<Func> { nonadditive_accel(const accel_args& args) : accel_val_base(args) { - if (args.weight != 0) weight = args.weight; + if (args.weight > 0) weight = args.weight; } inline double operator()(double speed) const { diff --git a/converter/converter.cpp b/converter/converter.cpp new file mode 100644 index 0000000..3aff02c --- /dev/null +++ b/converter/converter.cpp @@ -0,0 +1,222 @@ +#include <array> +#include <charconv> +#include <filesystem> +#include <fstream> +#include <iostream> +#include <optional> +#include <string> + +#include <rawaccel-settings.h> + +using namespace System; +using namespace System::Runtime::InteropServices; +using namespace Newtonsoft::Json; + +namespace ra = rawaccel; +namespace fs = std::filesystem; + +const wchar_t* IA_SETTINGS_NAME = L"settings.txt"; +const wchar_t* IA_PROFILE_EXT = L".profile"; + +enum IA_MODES_ENUM { IA_QL, IA_NAT, IA_LOG }; + +constexpr std::array<std::string_view, 3> IA_MODES = { + "QuakeLive", "Natural", "Logarithmic" +}; + +// trim from start (in place) +static inline void ltrim(std::string& s) { + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { + return !std::isspace(ch); + })); +} + +// trim from end (in place) +static inline void rtrim(std::string& s) { + s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { + return !std::isspace(ch); + }).base(), s.end()); +} + +// trim from both ends (in place) +static inline void trim(std::string& s) { + ltrim(s); + rtrim(s); +} + +bool yes() { + bool b; + while (wchar_t c = _getwch()) { + if (c == 'y') { + b = true; + break; + } + else if (c == 'n') { + b = false; + break; + } + } + return b; +} + +bool try_convert(const fs::path& fp) { + std::vector<std::pair<std::string, double>> kv_pairs; + + { + std::ifstream ifs(fp); + std::string line; + + while (std::getline(ifs, line)) { + if (line.empty()) continue; + + auto delim_pos = line.find('='); + if (delim_pos == std::string::npos) continue; + + std::string key(line.substr(0, delim_pos)); + trim(key); + + auto val_pos = line.find_first_not_of(" \t", delim_pos + 1); + if (val_pos == std::string::npos) continue; + + double val = 0; + + auto [p, ec] = std::from_chars(&line[val_pos], &line[0] + line.size(), val); + + if (ec == std::errc()) { + kv_pairs.emplace_back(key, val); + } + else if (key == "AccelMode") { + std::string mode_val = line.substr(val_pos); + rtrim(mode_val); + auto it = std::find(IA_MODES.begin(), IA_MODES.end(), mode_val); + if (it != IA_MODES.end()) { + val = static_cast<double>(std::distance(IA_MODES.begin(), it)); + kv_pairs.emplace_back(key, val); + } + } + } + } + + auto get = [&](auto... keys) -> std::optional<double> { + auto it = std::find_if(kv_pairs.begin(), kv_pairs.end(), [=](auto&& p) { + return ((p.first == keys) || ...); + }); + if (it == kv_pairs.end()) return std::nullopt; + return it->second; + }; + + ra::settings ra_settings; + ra::accel_args& args = ra_settings.argsv.x; + + auto opt_mode = get("AccelMode"); + if (!opt_mode) opt_mode = 0.0; + + double accel = std::max(get("Acceleration").value_or(0), 0.0); + double sens = get("Sensitivity").value_or(1); + double cap = get("SensitivityCap").value_or(0); + + std::cout << "We recommend trying out our new cap and offset styles.\n" + "Use new cap and offset? (y|n)\n"; + + args.legacy_offset = !yes(); + args.offset = get("Offset").value_or(0); + args.accel = accel / sens * get("Pre-ScaleX").value_or(1); + args.limit = 1 + std::abs(cap - sens); + + ra_settings.degrees_rotation = get("Angle", "AngleAdjustment").value_or(0); + ra_settings.sens = { + get("Post-ScaleX").value_or(1), + get("Post-ScaleY").value_or(1) + }; + + switch (static_cast<IA_MODES_ENUM>(opt_mode.value())) { + case IA_QL: { + auto opt_pow = get("Power"); + if (!opt_pow || opt_pow.value() <= 1) return false; + args.exponent = opt_pow.value(); + + if (args.legacy_offset || cap <= 1) { + args.scale_cap = cap; + } + else { + double b = (cap - 1) / args.exponent; + double e = 1 / (args.exponent - 1); + args.gain_cap = args.offset + (1 / accel) * std::pow(b, e); + } + ra_settings.modes.x = ra::accel_mode::classic; + break; + } + case IA_NAT: { + std::cout << "Raw Accel offers a new mode that you might like more than Natural.\n" + "Wanna try it out now? (y|n)\n"; + ra_settings.modes.x = yes() ? ra::accel_mode::naturalgain : ra::accel_mode::natural; + break; + } + case IA_LOG: { + std::cout << "Logarithmic accel mode is not supported.\n"; + return true; + } + default: return false; + } + + DriverSettings^ new_settings = Marshal::PtrToStructure<DriverSettings^>((IntPtr)&ra_settings); + auto errors = DriverInterop::GetSettingsErrors(new_settings); + + if (errors->Empty()) { + Console::Write("Sending to driver... "); + DriverInterop::Write(new_settings); + Console::WriteLine("done"); + + Console::Write("Generating settings.json... "); + auto json = JsonConvert::SerializeObject(new_settings, Formatting::Indented); + System::IO::File::WriteAllText("settings.json", json); + Console::WriteLine("done"); + } + else { + Console::WriteLine("Bad settings:\n" + errors->x->ToArray()[0]); + } + + return true; +} + +int main() +{ + std::optional<fs::path> opt_path; + + if (fs::exists(IA_SETTINGS_NAME)) { + opt_path = IA_SETTINGS_NAME; + } + else { + for (auto&& entry : fs::directory_iterator(".")) { + if (fs::is_regular_file(entry) && + entry.path().extension() == IA_PROFILE_EXT) { + opt_path = entry; + break; + } + } + } + + if (opt_path) { + std::cout << "Found " << opt_path->filename() << + "\n\nConvert and send settings generated from " << + opt_path->filename() << "? (y|n)\n"; + if (!yes()) return 0; + try { + if (!try_convert(opt_path.value())) + std::cout << "Unable to convert settings.\n"; + } + catch (DriverNotInstalledException^) { + std::cout << "\nDriver is not installed\n"; + } + catch (const std::exception& e) { + std::cout << "Error: \n" << e.what() << '\n'; + } + } + else { + std::cout << "Drop your InterAccel settings/profile into this directory.\n" + "Then run this program to generate the equivalent Raw Accel settings.\n"; + } + + std::cout << "Press any key to close this window . . .\n"; + _getwch(); +} diff --git a/converter/converter.vcxproj b/converter/converter.vcxproj new file mode 100644 index 0000000..3cbe7bf --- /dev/null +++ b/converter/converter.vcxproj @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>16.0</VCProjectVersion> + <Keyword>Win32Proj</Keyword> + <ProjectGuid>{4c421992-9a27-4860-a40c-add76fbace55}</ProjectGuid> + <RootNamespace>converter</RootNamespace> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + <CLRSupport>true</CLRSupport> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + <WholeProgramOptimization>false</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <CLRSupport>true</CLRSupport> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup 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" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <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> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <LanguageStandard>stdcpp17</LanguageStandard> + <AdditionalOptions>/Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <LanguageStandard>stdcpp17</LanguageStandard> + <AdditionalOptions>/Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + <PostBuildEvent> + <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)"</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="converter.cpp" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\wrapper\wrapper.vcxproj"> + <Project>{28a3656f-a1de-405c-b547-191c32ec555f}</Project> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Reference Include="Newtonsoft.Json"> + <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/converter/converter.vcxproj.filters b/converter/converter.vcxproj.filters new file mode 100644 index 0000000..954dbfa --- /dev/null +++ b/converter/converter.vcxproj.filters @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="converter.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 15a0c0e..11685ee 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -84,7 +84,7 @@ namespace grapher }, combineMagnitudes = ApplyOptions.IsWhole, modes = ApplyOptions.GetModes(), - args = ApplyOptions.GetUpdatedArgs(ref driverSettings.args), + args = ApplyOptions.GetArgs(), minimumTime = driverSettings.minimumTime }; diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs index 53c39af..11a7f10 100644 --- a/grapher/Models/Options/AccelOptionSet.cs +++ b/grapher/Models/Options/AccelOptionSet.cs @@ -98,14 +98,14 @@ namespace grapher.Models.Options Options.Top = TopAnchor; } - public void SetArgs(ref AccelArgs args, ref /*readonly*/ AccelArgs last) + public void SetArgs(ref AccelArgs args) { - Options.SetArgs(ref args, ref last); + Options.SetArgs(ref args); } - public AccelArgs GenerateArgs(ref /*readonly*/ AccelArgs last) + public AccelArgs GenerateArgs() { - return Options.GenerateArgs(ref last); + return Options.GenerateArgs(); } public void SetActiveValues(int mode, AccelArgs args) diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index e8d0e46..f9ecac1 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -225,24 +225,25 @@ namespace grapher Width = Acceleration.Field.Width; } - public void SetArgs(ref AccelArgs args, ref /*readonly*/ AccelArgs last) + public void SetArgs(ref AccelArgs args) { - args.acceleration = Acceleration.Visible ? Acceleration.Field.Data : last.acceleration; - args.scale = Scale.Visible ? Scale.Field.Data : last.scale; - args.gainCap = Cap.Visible ? Cap.VelocityGainCap : 0.0; - args.scaleCap = Cap.Visible ? Cap.SensitivityCap : 0.0; - args.limit = Limit.Visible ? Limit.Field.Data : last.limit; - args.exponent = Exponent.Visible ? Exponent.Field.Data : last.exponent; - args.offset = Offset.Visible ? Offset.Offset : 0.0; + AccelArgs defaults = (AccelArgs)DriverInterop.DefaultArgs; + args.acceleration = Acceleration.Visible ? Acceleration.Field.Data : defaults.acceleration; + args.scale = Scale.Visible ? Scale.Field.Data : defaults.scale; + args.gainCap = Cap.Visible ? Cap.VelocityGainCap : defaults.gainCap; + args.scaleCap = Cap.Visible ? Cap.SensitivityCap : defaults.scaleCap; + args.limit = Limit.Visible ? Limit.Field.Data : defaults.limit; + args.exponent = Exponent.Visible ? Exponent.Field.Data : defaults.exponent; + args.offset = Offset.Visible ? Offset.Offset : defaults.offset; args.legacyOffset = Offset.IsLegacy; - args.midpoint = Midpoint.Visible ? Midpoint.Field.Data : last.midpoint; - args.weight = Weight.Visible ? Weight.Field.Data : last.weight; + args.midpoint = Midpoint.Visible ? Midpoint.Field.Data : defaults.midpoint; + args.weight = Weight.Visible ? Weight.Field.Data : defaults.weight; } - public AccelArgs GenerateArgs(ref /*readonly*/ AccelArgs last) + public AccelArgs GenerateArgs() { AccelArgs args = new AccelArgs(); - SetArgs(ref args, ref last); + SetArgs(ref args); return args; } diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs index 51c80ea..c2ed498 100644 --- a/grapher/Models/Options/ApplyOptions.cs +++ b/grapher/Models/Options/ApplyOptions.cs @@ -89,14 +89,14 @@ namespace grapher.Models.Options }; } - public Vec2<AccelArgs> GetUpdatedArgs(ref /*readonly*/ Vec2<AccelArgs> last) + public Vec2<AccelArgs> GetArgs() { - var xArgs = OptionSetX.GenerateArgs(ref last.x); + var xArgs = OptionSetX.GenerateArgs(); return new Vec2<AccelArgs> { x = xArgs, - y = ByComponentVectorXYLock.Checked ? xArgs : OptionSetY.GenerateArgs(ref last.y) + y = ByComponentVectorXYLock.Checked ? xArgs : OptionSetY.GenerateArgs() }; } diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 9e9b15b..3e23226 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -12,6 +12,21 @@ <FileAlignment>512</FileAlignment> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <Deterministic>true</Deterministic> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> <DebugSymbols>true</DebugSymbols> @@ -35,6 +50,9 @@ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <Prefer32Bit>true</Prefer32Bit> </PropertyGroup> + <PropertyGroup> + <ApplicationIcon>mouse.ico</ApplicationIcon> + </PropertyGroup> <ItemGroup> <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> @@ -140,5 +158,25 @@ <Folder Include="Icon\" /> <Folder Include="ReadMe\" /> </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include=".NETFramework,Version=v4.7.2"> + <Visible>False</Visible> + <ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>false</Install> + </BootstrapperPackage> + </ItemGroup> + <ItemGroup> + <Content Include="mouse.ico" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <PropertyGroup> + <PostBuildEvent>IF ($(ConfigurationName)) == (Debug) GOTO END +copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)" +:END</PostBuildEvent> + </PropertyGroup> </Project>
\ No newline at end of file diff --git a/grapher/mouse.ico b/grapher/mouse.ico Binary files differnew file mode 100644 index 0000000..493036a --- /dev/null +++ b/grapher/mouse.ico diff --git a/installer/installer.vcxproj b/installer/installer.vcxproj index a91ed09..8ff13a6 100644 --- a/installer/installer.vcxproj +++ b/installer/installer.vcxproj @@ -95,6 +95,9 @@ <Manifest> <AdditionalManifestFiles>install.manifest</AdditionalManifestFiles> </Manifest> + <PostBuildEvent> + <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)"</Command> + </PostBuildEvent> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="installer.cpp" /> diff --git a/rawaccel.sln b/rawaccel.sln index cfbbc23..aa226c1 100644 --- a/rawaccel.sln +++ b/rawaccel.sln @@ -14,16 +14,27 @@ 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}" + ProjectSection(ProjectDependencies) = postProject + {0695A19E-8B14-4DE7-AADF-97E5912B197C} = {0695A19E-8B14-4DE7-AADF-97E5912B197C} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "grapher", "grapher\grapher.csproj", "{EF67F71F-ABF5-4760-B50D-D1B9836DF01C}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "writer", "writer\writer.csproj", "{28ACF254-E4EF-4A0E-9761-0FE22048D6FD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wrapper-deps", "wrapper-deps\wrapper-deps.csproj", "{0695A19E-8B14-4DE7-AADF-97E5912B197C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "converter", "converter\converter.vcxproj", "{4C421992-9A27-4860-A40C-ADD76FBACE55}" + ProjectSection(ProjectDependencies) = postProject + {28A3656F-A1DE-405C-B547-191C32EC555F} = {28A3656F-A1DE-405C-B547-191C32EC555F} + EndProjectSection +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 @@ -35,7 +46,6 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {60D6C942-AC20-4C05-A2BE-54B5C966534D}.Debug|x64.ActiveCfg = Debug|x64 {60D6C942-AC20-4C05-A2BE-54B5C966534D}.Debug|x64.Build.0 = Debug|x64 - {60D6C942-AC20-4C05-A2BE-54B5C966534D}.Debug|x64.Deploy.0 = Debug|x64 {60D6C942-AC20-4C05-A2BE-54B5C966534D}.Release|x64.ActiveCfg = Release|x64 {60D6C942-AC20-4C05-A2BE-54B5C966534D}.Release|x64.Build.0 = Release|x64 {896950D1-520A-420A-B6B1-73014B92A68C}.Debug|x64.ActiveCfg = Debug|x64 @@ -58,6 +68,14 @@ Global {28ACF254-E4EF-4A0E-9761-0FE22048D6FD}.Debug|x64.Build.0 = Debug|x64 {28ACF254-E4EF-4A0E-9761-0FE22048D6FD}.Release|x64.ActiveCfg = Release|x64 {28ACF254-E4EF-4A0E-9761-0FE22048D6FD}.Release|x64.Build.0 = Release|x64 + {0695A19E-8B14-4DE7-AADF-97E5912B197C}.Debug|x64.ActiveCfg = Debug|x64 + {0695A19E-8B14-4DE7-AADF-97E5912B197C}.Debug|x64.Build.0 = Debug|x64 + {0695A19E-8B14-4DE7-AADF-97E5912B197C}.Release|x64.ActiveCfg = Release|x64 + {0695A19E-8B14-4DE7-AADF-97E5912B197C}.Release|x64.Build.0 = Release|x64 + {4C421992-9A27-4860-A40C-ADD76FBACE55}.Debug|x64.ActiveCfg = Debug|x64 + {4C421992-9A27-4860-A40C-ADD76FBACE55}.Debug|x64.Build.0 = Debug|x64 + {4C421992-9A27-4860-A40C-ADD76FBACE55}.Release|x64.ActiveCfg = Release|x64 + {4C421992-9A27-4860-A40C-ADD76FBACE55}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/uninstaller/uninstaller.vcxproj b/uninstaller/uninstaller.vcxproj index 95a9dc8..f7e9f75 100644 --- a/uninstaller/uninstaller.vcxproj +++ b/uninstaller/uninstaller.vcxproj @@ -81,6 +81,9 @@ <GenerateDebugInformation>true</GenerateDebugInformation> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> + <PostBuildEvent> + <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)"</Command> + </PostBuildEvent> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="uninstaller.cpp" /> diff --git a/wrapper-deps/Class1.cs b/wrapper-deps/Class1.cs new file mode 100644 index 0000000..397bd8f --- /dev/null +++ b/wrapper-deps/Class1.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace wrapper_deps +{ + public class Class1 + { + } +} diff --git a/wrapper-deps/Properties/AssemblyInfo.cs b/wrapper-deps/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4e2bc26 --- /dev/null +++ b/wrapper-deps/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("wrapper-deps")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("wrapper-deps")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0695a19e-8b14-4de7-aadf-97e5912b197c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/wrapper-deps/packages.config b/wrapper-deps/packages.config new file mode 100644 index 0000000..a9de8b5 --- /dev/null +++ b/wrapper-deps/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" /> +</packages>
\ No newline at end of file diff --git a/wrapper-deps/wrapper-deps.csproj b/wrapper-deps/wrapper-deps.csproj new file mode 100644 index 0000000..35391b5 --- /dev/null +++ b/wrapper-deps/wrapper-deps.csproj @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{0695A19E-8B14-4DE7-AADF-97E5912B197C}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>wrapper_deps</RootNamespace> + <AssemblyName>wrapper-deps</AssemblyName> + <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x64\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <LangVersion>7.3</LangVersion> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + <OutputPath>bin\x64\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <LangVersion>7.3</LangVersion> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <ItemGroup> + <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Class1.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index 72ebdc7..c5834d9 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -82,13 +82,12 @@ void as_native(DriverSettings^ managed_args, NativeSettingsFunc fn) if (Marshal::SizeOf(managed_args) != sizeof(settings)) throw gcnew InvalidOperationException("setting sizes differ"); #endif - IntPtr unmanagedHandle = Marshal::AllocHGlobal(sizeof(settings)); - Marshal::StructureToPtr(managed_args, unmanagedHandle, false); - fn(*reinterpret_cast<settings*>(unmanagedHandle.ToPointer())); + settings args; + Marshal::StructureToPtr(managed_args, (IntPtr)&args, false); + fn(args); if constexpr (!std::is_invocable_v<NativeSettingsFunc, const settings&>) { - Marshal::PtrToStructure(unmanagedHandle, managed_args); + Marshal::PtrToStructure((IntPtr)&args, managed_args); } - Marshal::FreeHGlobal(unmanagedHandle); } DriverSettings^ get_default() @@ -137,9 +136,12 @@ error_list_t^ get_accel_errors(AccelMode mode, AccelArgs^ args) if (args->acceleration > 1 && is_mode(am::natural, am::naturalgain)) error_list->Add("acceleration can not be greater than 1"); - else if (args->acceleration < 0) - error_list->Add("acceleration can not be negative, use a negative weight to compensate"); - + else if (args->acceleration < 0) { + bool additive = m < 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"); + } + if (args->scale <= 0) error_list->Add("scale must be positive"); @@ -172,6 +174,7 @@ public: public ref struct DriverInterop { literal double WriteDelayMs = WRITE_DELAY; + static initonly AccelArgs^ DefaultArgs = get_default()->args.x; static DriverSettings^ GetActiveSettings() { diff --git a/wrapper/wrapper.vcxproj b/wrapper/wrapper.vcxproj index 37060ad..6c85a57 100644 --- a/wrapper/wrapper.vcxproj +++ b/wrapper/wrapper.vcxproj @@ -66,6 +66,10 @@ <Link> <AdditionalDependencies /> </Link> + <PostBuildEvent> + <Command>copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)" & +copy /Y "$(TargetDir)Newtonsoft.Json.dll" "$(SolutionDir)signed\Newtonsoft.Json.dll"</Command> + </PostBuildEvent> </ItemDefinitionGroup> <ItemGroup> <ClInclude Include="wrapper_io.hpp" /> @@ -75,7 +79,9 @@ <ClCompile Include="wrapper_io.cpp" /> </ItemGroup> <ItemGroup> - <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" /> + <Reference Include="Newtonsoft.Json"> + <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/writer/packages.config b/writer/packages.config new file mode 100644 index 0000000..a9de8b5 --- /dev/null +++ b/writer/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" /> +</packages>
\ No newline at end of file diff --git a/writer/writer.csproj b/writer/writer.csproj index 4befc1a..a28d5ef 100644 --- a/writer/writer.csproj +++ b/writer/writer.csproj @@ -36,8 +36,8 @@ <Prefer32Bit>true</Prefer32Bit> </PropertyGroup> <ItemGroup> - <Reference Include="Newtonsoft.Json"> - <HintPath>..\x64\Release\Newtonsoft.Json.dll</HintPath> + <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> @@ -54,6 +54,7 @@ </ItemGroup> <ItemGroup> <None Include="App.config" /> + <None Include="packages.config" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\wrapper\wrapper.vcxproj"> @@ -62,4 +63,9 @@ </ProjectReference> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <PropertyGroup> + <PostBuildEvent>IF ($(ConfigurationName)) == (Debug) GOTO END +copy /Y "$(TargetPath)" "$(SolutionDir)signed\$(TargetFileName)" +:END</PostBuildEvent> + </PropertyGroup> </Project>
\ No newline at end of file |