summaryrefslogtreecommitdiff
path: root/wrapper
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-29 10:08:13 -0700
committerJacob Palecki <[email protected]>2020-09-29 10:08:13 -0700
commit49675a0fa01a1d7f04a7a2e31ec1872125a0cf37 (patch)
treeac4a331892ff777de67deb8b8be8905bb017434e /wrapper
parentUse 0 for cap\offset when not visible (diff)
parentset invisible args to default values before write (diff)
downloadrawaccel-49675a0fa01a1d7f04a7a2e31ec1872125a0cf37.tar.xz
rawaccel-49675a0fa01a1d7f04a7a2e31ec1872125a0cf37.zip
merge + small fixes
Diffstat (limited to 'wrapper')
-rw-r--r--wrapper/wrapper.cpp19
-rw-r--r--wrapper/wrapper.vcxproj8
2 files changed, 18 insertions, 9 deletions
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)" &amp;
+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">