mirror of
https://github.com/RawAccelOfficial/rawaccel.git
synced 2025-05-12 10:57:10 +02:00
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
172 lines
5.4 KiB
C#
172 lines
5.4 KiB
C#
using grapher.Models.Calculations;
|
|
using grapher.Models.Mouse;
|
|
using grapher.Models.Serialized;
|
|
using System;
|
|
using System.CodeDom;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms.DataVisualization.Charting;
|
|
|
|
namespace grapher
|
|
{
|
|
public class AccelGUI
|
|
{
|
|
|
|
#region constructors
|
|
|
|
public AccelGUI(
|
|
RawAcceleration accelForm,
|
|
AccelCalculator accelCalculator,
|
|
AccelCharts accelCharts,
|
|
SettingsManager settings,
|
|
AccelOptions accelOptions,
|
|
OptionXY sensitivity,
|
|
Option rotation,
|
|
OptionXY weight,
|
|
CapOptions cap,
|
|
Option offset,
|
|
Option acceleration,
|
|
Option limtOrExp,
|
|
Option midpoint,
|
|
Button writeButton,
|
|
Label mouseMoveLabel,
|
|
ToolStripMenuItem scaleMenuItem,
|
|
ToolStripMenuItem autoWriteMenuItem)
|
|
{
|
|
AccelForm = accelForm;
|
|
AccelCalculator = accelCalculator;
|
|
AccelCharts = accelCharts;
|
|
AccelerationOptions = accelOptions;
|
|
Sensitivity = sensitivity;
|
|
Rotation = rotation;
|
|
Weight = weight;
|
|
Cap = cap;
|
|
Offset = offset;
|
|
Acceleration = acceleration;
|
|
LimitOrExponent = limtOrExp;
|
|
Midpoint = midpoint;
|
|
WriteButton = writeButton;
|
|
ScaleMenuItem = scaleMenuItem;
|
|
Settings = settings;
|
|
Settings.Startup();
|
|
UpdateGraph();
|
|
|
|
MouseWatcher = new MouseWatcher(AccelForm, mouseMoveLabel, AccelCharts);
|
|
|
|
ScaleMenuItem.Click += new System.EventHandler(OnScaleMenuItemClick);
|
|
}
|
|
|
|
#endregion constructors
|
|
|
|
#region properties
|
|
|
|
public RawAcceleration AccelForm { get; }
|
|
|
|
public AccelCalculator AccelCalculator { get; }
|
|
|
|
public AccelCharts AccelCharts { get; }
|
|
|
|
public SettingsManager Settings { get; }
|
|
|
|
public AccelOptions AccelerationOptions { get; }
|
|
|
|
public OptionXY Sensitivity { get; }
|
|
|
|
public Option Rotation { get; }
|
|
|
|
public OptionXY Weight { get; }
|
|
|
|
public CapOptions Cap { get; }
|
|
|
|
public Option Offset { get; }
|
|
|
|
public Option Acceleration { get; }
|
|
|
|
public Option LimitOrExponent { get; }
|
|
|
|
public Option Midpoint { get; }
|
|
|
|
public Button WriteButton { get; }
|
|
|
|
public MouseWatcher MouseWatcher { get; }
|
|
|
|
public ToolStripMenuItem ScaleMenuItem { get; }
|
|
|
|
#endregion properties
|
|
|
|
#region methods
|
|
|
|
public void UpdateActiveSettingsFromFields()
|
|
{
|
|
Settings.UpdateActiveSettings(new DriverSettings
|
|
{
|
|
rotation = Rotation.Field.Data,
|
|
sensitivity = new Vec2<double>
|
|
{
|
|
x = Sensitivity.Fields.X,
|
|
y = Sensitivity.Fields.Y
|
|
},
|
|
combineMagnitudes = true,
|
|
modes = new Vec2<AccelMode>
|
|
{
|
|
x = (AccelMode)AccelerationOptions.AccelerationIndex
|
|
},
|
|
args = new Vec2<AccelArgs>
|
|
{
|
|
x = new AccelArgs
|
|
{
|
|
offset = Offset.Field.Data,
|
|
weight = Weight.Fields.X,
|
|
gainCap = Cap.VelocityGainCap,
|
|
scaleCap = Cap.SensitivityCapX,
|
|
accel = Acceleration.Field.Data,
|
|
rate = Acceleration.Field.Data,
|
|
powerScale = Acceleration.Field.Data,
|
|
limit = LimitOrExponent.Field.Data,
|
|
exponent = LimitOrExponent.Field.Data,
|
|
powerExponent = LimitOrExponent.Field.Data,
|
|
midpoint = Midpoint.Field.Data
|
|
}
|
|
},
|
|
minimumTime = .4
|
|
});
|
|
UpdateGraph();
|
|
}
|
|
|
|
public void UpdateGraph()
|
|
{
|
|
AccelCalculator.Calculate(
|
|
AccelCharts.AccelData,
|
|
Settings.ActiveAccel,
|
|
Settings.RawAccelSettings.AccelerationSettings);
|
|
AccelCharts.Bind();
|
|
UpdateActiveValueLabels();
|
|
}
|
|
|
|
public void UpdateActiveValueLabels()
|
|
{
|
|
var settings = Settings.RawAccelSettings.AccelerationSettings;
|
|
|
|
Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y);
|
|
Rotation.SetActiveValue(settings.rotation);
|
|
AccelerationOptions.SetActiveValue((int)settings.modes.x);
|
|
Offset.SetActiveValue(settings.args.x.offset);
|
|
Weight.SetActiveValues(settings.args.x.weight, settings.args.x.weight);
|
|
Acceleration.SetActiveValue(settings.args.x.accel); // rate, powerscale
|
|
LimitOrExponent.SetActiveValue(settings.args.x.limit); //exp, powerexp
|
|
Midpoint.SetActiveValue(settings.args.x.midpoint);
|
|
//Cap.SetActiveValues(Settings.ActiveAccel.GainCap, Settings.ActiveAccel.CapX, Settings.ActiveAccel.CapY, Settings.ActiveAccel.GainCapEnabled);
|
|
}
|
|
|
|
private void OnScaleMenuItemClick(object sender, EventArgs e)
|
|
{
|
|
UpdateGraph();
|
|
}
|
|
#endregion methods
|
|
}
|
|
|
|
}
|