diff options
| author | JacobPalecki <[email protected]> | 2021-01-20 20:13:33 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-01-20 20:13:33 -0800 |
| commit | 5b6479013c8f35df933dd57c680063f4db1e4028 (patch) | |
| tree | 60dd7c67a0f163457da2519b42553382a39a591b /wrapper/wrapper.cpp | |
| parent | show custom dialog on bad input (#63) (diff) | |
| parent | Guard against bad anisotropy args (diff) | |
| download | rawaccel-5b6479013c8f35df933dd57c680063f4db1e4028.tar.xz rawaccel-5b6479013c8f35df933dd57c680063f4db1e4028.zip | |
Merge pull request #65 from JacobPalecki/Directional
Directionality Features + Graph Fidelity
Diffstat (limited to 'wrapper/wrapper.cpp')
| -rw-r--r-- | wrapper/wrapper.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index 2c0d5e3..46e7e3a 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -54,6 +54,14 @@ public value struct Vec2 }; [JsonObject(ItemRequired = Required::Always)] +[StructLayout(LayoutKind::Sequential)] +public value struct DomainArgs +{ + Vec2<double> domainXY; + double lpNorm; +}; + +[JsonObject(ItemRequired = Required::Always)] [StructLayout(LayoutKind::Sequential, CharSet = CharSet::Unicode)] public ref struct DriverSettings { @@ -78,6 +86,12 @@ public ref struct DriverSettings [JsonProperty("Negative directional multipliers", Required = Required::Default)] Vec2<double> directionalMultipliers; + [JsonProperty("Stretches domain for horizontal vs vertical inputs")] + DomainArgs domainArgs; + + [JsonProperty("Stretches accel range for horizontal vs vertical inputs")] + Vec2<double> rangeXY; + [JsonProperty(Required = Required::Default)] double minimumTime; @@ -183,16 +197,40 @@ error_list_t^ get_accel_errors(AccelMode mode, AccelArgs^ args) return error_list; } +error_list_t^ get_other_errors(DriverSettings^ settings) +{ + auto error_list = gcnew error_list_t(); + + if (settings->rangeXY.x <= 0 || settings->rangeXY.y <= 0) + { + error_list->Add("range values must be positive"); + } + + if (settings->domainArgs.domainXY.x <= 0 || settings->domainArgs.domainXY.y <= 0) + { + error_list->Add("domain values must be positive"); + } + + if (settings->domainArgs.lpNorm <= 0) + { + error_list->Add("lp norm must be positive"); + } + + return error_list; +} + public ref class SettingsErrors { public: error_list_t^ x; error_list_t^ y; + error_list_t^ other; bool Empty() { return (x == nullptr || x->Count == 0) && - (y == nullptr || y->Count == 0); + (y == nullptr || y->Count == 0) && + (other == nullptr || other->Count == 0); } virtual String^ ToString() override @@ -219,6 +257,11 @@ public: sb->AppendFormat("y: {0}\n", str); } } + + for each (String ^ str in other) + { + sb->AppendLine(str); + } return sb->ToString(); } @@ -272,9 +315,13 @@ public ref struct DriverInterop errors->y = get_accel_errors(args->modes.y, args->args.y); } + errors->other = get_other_errors(args); + return errors; } + + static error_list_t^ GetAccelErrors(AccelMode mode, AccelArgs^ args) { return get_accel_errors(mode, args); |