summaryrefslogtreecommitdiff
path: root/grapher/Models/Serialized/SettingsManager.cs
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-25 19:35:54 -0700
committerJacob Palecki <[email protected]>2020-09-25 19:35:54 -0700
commitf2279a5c52d5da43e48133e753514b3806bb7e3c (patch)
tree328830580cf5bb96a317a61bef3e155dc2a17fd5 /grapher/Models/Serialized/SettingsManager.cs
parentUse log LUT rather than binary search for last mouse move point (diff)
parentadd initial writer (diff)
downloadrawaccel-f2279a5c52d5da43e48133e753514b3806bb7e3c.tar.xz
rawaccel-f2279a5c52d5da43e48133e753514b3806bb7e3c.zip
merge with writer
Diffstat (limited to 'grapher/Models/Serialized/SettingsManager.cs')
-rw-r--r--grapher/Models/Serialized/SettingsManager.cs41
1 files changed, 23 insertions, 18 deletions
diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs
index cac2bd0..26160f5 100644
--- a/grapher/Models/Serialized/SettingsManager.cs
+++ b/grapher/Models/Serialized/SettingsManager.cs
@@ -1,6 +1,7 @@
using Newtonsoft.Json;
using System;
using System.Windows.Forms;
+using System.Threading;
namespace grapher.Models.Serialized
{
@@ -46,29 +47,28 @@ namespace grapher.Models.Serialized
#region Methods
- public void UpdateActiveSettings(DriverSettings settings, Action afterAccelSettingsUpdate = null)
+ public void UpdateActiveSettings(DriverSettings settings)
{
- settings.SendToDriverAndUpdate(ActiveAccel, () =>
- {
- RawAccelSettings.AccelerationSettings = settings;
- RawAccelSettings.GUISettings = new GUISettings
- {
- AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked,
- DPI = (int)DpiField.Data,
- PollRate = (int)PollRateField.Data,
- ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked,
- ShowVelocityAndGain = ShowVelocityAndGainMoveMenuItem.Checked,
- };
+ ActiveAccel.UpdateFromSettings(settings);
+ SendToDriver(settings);
- RawAccelSettings.Save();
+ RawAccelSettings.AccelerationSettings = settings;
+ RawAccelSettings.GUISettings = new GUISettings
+ {
+ AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked,
+ DPI = (int)DpiField.Data,
+ PollRate = (int)PollRateField.Data,
+ ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked,
+ ShowVelocityAndGain = ShowVelocityAndGainMoveMenuItem.Checked,
+ };
- afterAccelSettingsUpdate?.Invoke();
- });
+ RawAccelSettings.Save();
}
public void UpdateActiveAccelFromFileSettings(DriverSettings settings)
- {
- settings.SendToDriverAndUpdate(ActiveAccel);
+ {
+ ActiveAccel.UpdateFromSettings(settings);
+ SendToDriver(settings);
DpiField.SetToEntered(RawAccelSettings.GUISettings.DPI);
PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate);
@@ -77,6 +77,11 @@ namespace grapher.Models.Serialized
ShowVelocityAndGainMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowVelocityAndGain;
}
+ public static void SendToDriver(DriverSettings settings)
+ {
+ new Thread(() => DriverInterop.SetActiveSettings(settings)).Start();
+ }
+
public void Startup()
{
if (RawAccelSettings.Exists())
@@ -97,7 +102,7 @@ namespace grapher.Models.Serialized
}
RawAccelSettings = new RawAccelSettings(
- DriverSettings.GetActive(),
+ DriverInterop.GetActiveSettings(),
new GUISettings
{
AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked,