diff options
| author | a1xd <[email protected]> | 2020-08-31 19:41:21 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2020-08-31 19:41:21 -0400 |
| commit | 9010cc593af419dd824dba0ade6a2022aea6143f (patch) | |
| tree | 90a82ee14dbb112621657efbd2523ed35f59d154 /grapher/Models/Serialized/DriverSettings.cs | |
| parent | clean up wrapper, minimize heap alloc (diff) | |
| download | rawaccel-9010cc593af419dd824dba0ade6a2022aea6143f.tar.xz rawaccel-9010cc593af419dd824dba0ade6a2022aea6143f.zip | |
add independent xy accel to driver
other changes:
modifier_args type name is now settings,
which is now the type passed in driver ioctl
remove most settings/args verification from driver,
plan to let gui handle most of it
add another accel arg, rate, which is used to set
the 'accel' parameter of types which call exp (nat/sig),
might want to cap it
add (update) serializable DriverSettings (ModifierArgs) class to
gui and static methods for interop
remove properties from ManagedAccel, its now just a black box
for accessing modifier methods
add exception handling in wrapper_io to throw proper managed types
change SettingsManager::Startup to make a new settings file
if an error occurs during deserialization
change structure of accel types; how offset and weight are applied
now depend on additivity of types
remove tagged_union and add a handrolled variant/visit impl
AccelGui::UpdateActiveValueLabels currently broken for caps
and a few other args
remove gui default layout and initial natural accel setup
cli not updated
Diffstat (limited to 'grapher/Models/Serialized/DriverSettings.cs')
| -rw-r--r-- | grapher/Models/Serialized/DriverSettings.cs | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs new file mode 100644 index 0000000..91d7e9f --- /dev/null +++ b/grapher/Models/Serialized/DriverSettings.cs @@ -0,0 +1,87 @@ +using System; +using System.Runtime.InteropServices; + +namespace grapher.Models.Serialized +{ + public enum AccelMode + { + linear, classic, natural, logarithmic, sigmoid, naturalgain, sigmoidgain, power, noaccel + } + + [StructLayout(LayoutKind.Sequential)] + public struct AccelArgs + { + public double offset; + public double accel; + public double limit; + public double exponent; + public double midpoint; + public double powerScale; + public double powerExponent; + public double weight; + public double rate; + public double scaleCap; + public double gainCap; + }; + + [StructLayout(LayoutKind.Sequential)] + public struct Vec2 <T> + { + public T x; + public T y; + } + + [StructLayout(LayoutKind.Sequential)] + [Serializable] + public class DriverSettings + { + private static readonly IntPtr UnmanagedSettingsHandle = + Marshal.AllocHGlobal(Marshal.SizeOf<DriverSettings>()); + + public double rotation; + public bool combineMagnitudes; + public Vec2<AccelMode> modes; + public Vec2<AccelArgs> args; + public Vec2<double> sensitivity; + public double minimumTime; + + public static DriverSettings GetActive() + { + DriverInterop.GetActiveSettings(UnmanagedSettingsHandle); + return Marshal.PtrToStructure<DriverSettings>(UnmanagedSettingsHandle); + } + + public static void SetActive(DriverSettings settings) + { + Marshal.StructureToPtr(settings, UnmanagedSettingsHandle, false); + DriverInterop.SetActiveSettings(UnmanagedSettingsHandle); + } + + public void SendToDriver() + { + SetActive(this); + } + + public void SendToDriverAndUpdate(ManagedAccel accel) + { + SendToDriver(); + accel.UpdateFromSettings(UnmanagedSettingsHandle); + } + + public bool verify() + { + /* + if (args.accel < 0 || args.rate < 0) + bad_arg("accel can not be negative, use a negative weight to compensate"); + if (args.rate > 1) bad_arg("rate can not be greater than 1"); + if (args.exponent <= 1) bad_arg("exponent must be greater than 1"); + if (args.limit <= 1) bad_arg("limit must be greater than 1"); + if (args.power_scale <= 0) bad_arg("scale must be positive"); + if (args.power_exp <= 0) bad_arg("exponent must be positive"); + if (args.midpoint < 0) bad_arg("midpoint must not be negative"); + if (args.time_min <= 0) bad_arg("min time must be positive"); + */ + return true; + } + } +} |