diff options
| author | JacobPalecki <[email protected]> | 2020-09-29 13:17:50 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-29 13:17:50 -0700 |
| commit | 46e310b9168e2a662ca934bb2c924eea91d88d7f (patch) | |
| tree | b64eb67b725cab86edd5d8464216c50361ebebe8 /wrapper | |
| parent | Merge pull request #27 from JacobPalecki/GUI (diff) | |
| parent | Potential link fix, better power pic (diff) | |
| download | rawaccel-46e310b9168e2a662ca934bb2c924eea91d88d7f.tar.xz rawaccel-46e310b9168e2a662ca934bb2c924eea91d88d7f.zip | |
Merge pull request #28 from a1xd/initial-release
interaccel converter
Diffstat (limited to 'wrapper')
| -rw-r--r-- | wrapper/wrapper.cpp | 20 | ||||
| -rw-r--r-- | wrapper/wrapper.vcxproj | 8 |
2 files changed, 19 insertions, 9 deletions
diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index 72ebdc7..c665bed 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -30,6 +30,7 @@ public value struct AccelArgs double exponent; double midpoint; double weight; + [JsonProperty("legacyCap")] double scaleCap; double gainCap; }; @@ -82,13 +83,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 +137,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 +175,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"> |