diff options
| author | a1xd <[email protected]> | 2020-09-25 18:46:04 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2020-09-25 18:46:04 -0400 |
| commit | fd184b6ffeaf5b1d1dceb7de58a8ebb7c3d8c760 (patch) | |
| tree | 4e00b478ac1d888c50beaa782733cf52c61d038b /grapher/Models/Serialized/DriverSettings.cs | |
| parent | Merge pull request #22 from JacobPalecki/GUI (diff) | |
| download | rawaccel-fd184b6ffeaf5b1d1dceb7de58a8ebb7c3d8c760.tar.xz rawaccel-fd184b6ffeaf5b1d1dceb7de58a8ebb7c3d8c760.zip | |
add initial writer
move managed settings into wrapper
move gui build into driver build dir
Diffstat (limited to 'grapher/Models/Serialized/DriverSettings.cs')
| -rw-r--r-- | grapher/Models/Serialized/DriverSettings.cs | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs deleted file mode 100644 index 5f9307c..0000000 --- a/grapher/Models/Serialized/DriverSettings.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Threading; - -namespace grapher.Models.Serialized -{ - #region Enumerations - - public enum AccelMode - { - linear, classic, natural, naturalgain, power, logarithm, motivity, noaccel - } - - #endregion Enumerations - - #region Structs - - [StructLayout(LayoutKind.Sequential)] - public struct AccelArgs - { - public double offset; - public double legacy_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; - } - - #endregion Structs - - [StructLayout(LayoutKind.Sequential)] - [Serializable] - public class DriverSettings - { - #region Fields - - private static readonly IntPtr UnmanagedSettingsHandle = - Marshal.AllocHGlobal(Marshal.SizeOf<DriverSettings>()); - private static object UnmanagedSettingsLock = new object(); - - public double rotation; - public bool combineMagnitudes; - public Vec2<AccelMode> modes; - public Vec2<AccelArgs> args; - public Vec2<double> sensitivity; - public double minimumTime; - - #endregion Fields - - #region Methods - - public static DriverSettings GetActive() - { - DriverInterop.GetActiveSettings(UnmanagedSettingsHandle); - return Marshal.PtrToStructure<DriverSettings>(UnmanagedSettingsHandle); - } - - public static void SetActive(DriverSettings settings, Action<IntPtr> unmanagedActionBefore = null) - { - new Thread(() => - { - lock (UnmanagedSettingsLock) - { - Marshal.StructureToPtr(settings, UnmanagedSettingsHandle, false); - unmanagedActionBefore?.Invoke(UnmanagedSettingsHandle); - DriverInterop.SetActiveSettings(UnmanagedSettingsHandle); - } - }).Start(); - - } - - public void SendToDriver(Action<IntPtr> unmanagedActionBefore = null) - { - SetActive(this, unmanagedActionBefore); - } - - public void SendToDriverAndUpdate(ManagedAccel accel, Action betweenAccelAndWrite = null) - { - SendToDriver(settingsHandle => - { - accel.UpdateFromSettings(settingsHandle); - betweenAccelAndWrite?.Invoke(); - }); - } - - 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; - } - - #endregion Methods - } -} |