summaryrefslogtreecommitdiff
path: root/grapher
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-04-13 23:59:21 -0400
committera1xd <[email protected]>2021-04-13 23:59:21 -0400
commita6926be0e911b7b7637861866f41c3bca31a87a3 (patch)
treea8d7cd5afb4c093e6f97e8d772b139dd5d749988 /grapher
parentadditional fixes (diff)
downloadrawaccel-a6926be0e911b7b7637861866f41c3bca31a87a3.tar.xz
rawaccel-a6926be0e911b7b7637861866f41c3bca31a87a3.zip
move arbitrary input into settings
separate arbitrary mode from spaced modes, arbitrary now deserializes from default settings file
Diffstat (limited to 'grapher')
-rw-r--r--grapher/Layouts/ClassicLayout.cs2
-rw-r--r--grapher/Layouts/DefaultLayout.cs2
-rw-r--r--grapher/Layouts/JumpLayout.cs2
-rw-r--r--grapher/Layouts/LUTLayout.cs2
-rw-r--r--grapher/Layouts/LayoutBase.cs11
-rw-r--r--grapher/Layouts/LinearLayout.cs2
-rw-r--r--grapher/Layouts/MotivityLayout.cs2
-rw-r--r--grapher/Layouts/NaturalLayout.cs2
-rw-r--r--grapher/Layouts/OffLayout.cs2
-rw-r--r--grapher/Layouts/PowerLayout.cs2
-rw-r--r--grapher/Layouts/UnsupportedLayout.cs31
-rw-r--r--grapher/Models/AccelGUI.cs23
-rw-r--r--grapher/Models/Options/AccelOptionSet.cs9
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs121
-rw-r--r--grapher/Models/Options/ApplyOptions.cs57
-rw-r--r--grapher/grapher.csproj1
16 files changed, 139 insertions, 132 deletions
diff --git a/grapher/Layouts/ClassicLayout.cs b/grapher/Layouts/ClassicLayout.cs
index e9013b6..fe5c25d 100644
--- a/grapher/Layouts/ClassicLayout.cs
+++ b/grapher/Layouts/ClassicLayout.cs
@@ -8,7 +8,7 @@ namespace grapher.Layouts
: base()
{
Name = "Classic";
- Index = (int)AccelMode.classic;
+ Mode = AccelMode.classic;
GainSwitchOptionLayout = new OptionLayout(true, Gain);
AccelLayout = new OptionLayout(true, Acceleration);
diff --git a/grapher/Layouts/DefaultLayout.cs b/grapher/Layouts/DefaultLayout.cs
index 42de7f3..8146255 100644
--- a/grapher/Layouts/DefaultLayout.cs
+++ b/grapher/Layouts/DefaultLayout.cs
@@ -8,7 +8,7 @@ namespace grapher.Layouts
: base()
{
Name = "Default";
- Index = (int)AccelMode.noaccel;
+ Mode = AccelMode.noaccel;
LogarithmicCharts = false;
GainSwitchOptionLayout = new OptionLayout(true, Gain);
diff --git a/grapher/Layouts/JumpLayout.cs b/grapher/Layouts/JumpLayout.cs
index d78d273..cf5eb24 100644
--- a/grapher/Layouts/JumpLayout.cs
+++ b/grapher/Layouts/JumpLayout.cs
@@ -8,7 +8,7 @@ namespace grapher.Layouts
: base()
{
Name = "Jump";
- Index = (int)AccelMode.jump;
+ Mode = AccelMode.jump;
LogarithmicCharts = false;
GainSwitchOptionLayout = new OptionLayout(true, Gain);
diff --git a/grapher/Layouts/LUTLayout.cs b/grapher/Layouts/LUTLayout.cs
index fd0b75a..5505114 100644
--- a/grapher/Layouts/LUTLayout.cs
+++ b/grapher/Layouts/LUTLayout.cs
@@ -14,7 +14,7 @@ namespace grapher.Layouts
: base()
{
Name = "LookUpTable";
- Index = (int)AccelMode.noaccel + 1;
+ Mode = AccelMode.lut;
GainSwitchOptionLayout = new OptionLayout(false, string.Empty);
AccelLayout = new OptionLayout(false, Acceleration);
diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs
index e3583c4..900d611 100644
--- a/grapher/Layouts/LayoutBase.cs
+++ b/grapher/Layouts/LayoutBase.cs
@@ -34,11 +34,7 @@ namespace grapher.Layouts
LogarithmicCharts = false;
}
- /// <summary>
- /// Gets or sets mapping from acceleration type to identifying integer.
- /// Must match accel_mode defined in rawaccel-settings.h
- /// </summary>
- public int Index { get; protected set; }
+ public AccelMode Mode { get; protected set; }
public string Name { get; protected set; }
@@ -64,6 +60,11 @@ namespace grapher.Layouts
protected OptionLayout GainSwitchOptionLayout { get; set; }
+ public override string ToString()
+ {
+ return Name;
+ }
+
public void Layout(
IOption gainSwitchOption,
IOption accelOption,
diff --git a/grapher/Layouts/LinearLayout.cs b/grapher/Layouts/LinearLayout.cs
index 31ae353..88be3d4 100644
--- a/grapher/Layouts/LinearLayout.cs
+++ b/grapher/Layouts/LinearLayout.cs
@@ -10,7 +10,7 @@ namespace grapher.Layouts
: base()
{
Name = LinearName;
- Index = (int)AccelMode.classic;
+ Mode = AccelMode.classic;
LogarithmicCharts = false;
GainSwitchOptionLayout = new OptionLayout(true, Gain);
diff --git a/grapher/Layouts/MotivityLayout.cs b/grapher/Layouts/MotivityLayout.cs
index e9c81f4..7458dfc 100644
--- a/grapher/Layouts/MotivityLayout.cs
+++ b/grapher/Layouts/MotivityLayout.cs
@@ -13,7 +13,7 @@ namespace grapher.Layouts
: base()
{
Name = "Motivity";
- Index = (int)AccelMode.motivity;
+ Mode = AccelMode.motivity;
LogarithmicCharts = true;
GainSwitchOptionLayout = new OptionLayout(true, Gain);
diff --git a/grapher/Layouts/NaturalLayout.cs b/grapher/Layouts/NaturalLayout.cs
index 070a249..ece2b00 100644
--- a/grapher/Layouts/NaturalLayout.cs
+++ b/grapher/Layouts/NaturalLayout.cs
@@ -8,7 +8,7 @@ namespace grapher.Layouts
: base()
{
Name = "Natural";
- Index = (int)AccelMode.natural;
+ Mode = AccelMode.natural;
LogarithmicCharts = false;
GainSwitchOptionLayout = new OptionLayout(true, Gain);
diff --git a/grapher/Layouts/OffLayout.cs b/grapher/Layouts/OffLayout.cs
index 9c56632..e802113 100644
--- a/grapher/Layouts/OffLayout.cs
+++ b/grapher/Layouts/OffLayout.cs
@@ -8,7 +8,7 @@ namespace grapher.Layouts
: base()
{
Name = "Off";
- Index = (int)AccelMode.noaccel;
+ Mode = AccelMode.noaccel;
LogarithmicCharts = false;
GainSwitchOptionLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Layouts/PowerLayout.cs b/grapher/Layouts/PowerLayout.cs
index 8304ccf..bb07457 100644
--- a/grapher/Layouts/PowerLayout.cs
+++ b/grapher/Layouts/PowerLayout.cs
@@ -6,7 +6,7 @@
: base()
{
Name = "Power";
- Index = (int)AccelMode.power;
+ Mode = AccelMode.power;
LogarithmicCharts = false;
GainSwitchOptionLayout = new OptionLayout(true, Gain);
diff --git a/grapher/Layouts/UnsupportedLayout.cs b/grapher/Layouts/UnsupportedLayout.cs
new file mode 100644
index 0000000..1607a6c
--- /dev/null
+++ b/grapher/Layouts/UnsupportedLayout.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Layouts
+{
+ public class UnsupportedLayout : LayoutBase
+ {
+ public const string LUTLayoutText = "This mode is unsupported by this program. See the guide for details.";
+
+ public UnsupportedLayout()
+ : base()
+ {
+ Name = "Unsupported";
+ Mode = AccelMode.noaccel + 1;
+
+ GainSwitchOptionLayout = new OptionLayout(false, string.Empty);
+ AccelLayout = new OptionLayout(false, Acceleration);
+ ScaleLayout = new OptionLayout(false, string.Empty);
+ CapLayout = new OptionLayout(false, Cap);
+ WeightLayout = new OptionLayout(false, Weight);
+ OffsetLayout = new OptionLayout(false, Offset);
+ LimitLayout = new OptionLayout(false, string.Empty);
+ ExponentLayout = new OptionLayout(false, Exponent);
+ MidpointLayout = new OptionLayout(false, string.Empty);
+ LUTTextLayout = new OptionLayout(true, LUTLayoutText);
+ }
+ }
+} \ No newline at end of file
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index ec570d3..324dcb1 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -114,20 +114,19 @@ namespace grapher
public void UpdateActiveSettingsFromFields()
{
- var settings = new DriverSettings
+ var settings = new DriverSettings();
+
+ settings.rotation = ApplyOptions.Rotation.Field.Data;
+ settings.sensitivity = new Vec2<double>
{
- rotation = ApplyOptions.Rotation.Field.Data,
- sensitivity = new Vec2<double>
- {
- x = ApplyOptions.Sensitivity.Fields.X,
- y = ApplyOptions.Sensitivity.Fields.Y
- },
- combineMagnitudes = ApplyOptions.IsWhole,
- args = ApplyOptions.GetArgs(),
- domainArgs = ApplyOptions.Directionality.GetDomainArgs(),
- rangeXY = ApplyOptions.Directionality.GetRangeXY(),
- deviceID = DeviceIDManager.ID,
+ x = ApplyOptions.Sensitivity.Fields.X,
+ y = ApplyOptions.Sensitivity.Fields.Y
};
+ settings.combineMagnitudes = ApplyOptions.IsWhole;
+ ApplyOptions.SetArgs(ref settings.args);
+ settings.domainArgs = ApplyOptions.Directionality.GetDomainArgs();
+ settings.rangeXY = ApplyOptions.Directionality.GetRangeXY();
+ settings.deviceID = DeviceIDManager.ID;
Settings.SetHiddenOptions(settings);
diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs
index f4c08a1..8b957f1 100644
--- a/grapher/Models/Options/AccelOptionSet.cs
+++ b/grapher/Models/Options/AccelOptionSet.cs
@@ -103,16 +103,11 @@ namespace grapher.Models.Options
Options.SetArgs(ref args);
}
- public AccelArgs GenerateArgs()
- {
- return Options.GenerateArgs();
- }
-
- public void SetActiveValues(AccelArgs args)
+ public void SetActiveValues(ref AccelArgs args)
{
if (!Hidden)
{
- Options.SetActiveValues(args);
+ Options.SetActiveValues(ref args);
}
}
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index b12ad8a..62a923d 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -12,19 +12,15 @@ namespace grapher
{
#region Fields
- public static readonly Dictionary<string, LayoutBase> AccelerationTypes = new List<LayoutBase>
- {
- new LinearLayout(),
- new ClassicLayout(),
- new NaturalLayout(),
- new JumpLayout(),
- new PowerLayout(),
- new MotivityLayout(),
- new LUTLayout(),
- new OffLayout(),
- }.ToDictionary(k => k.Name);
-
- public static readonly AccelArgs DefaultArgs = new DriverSettings().args.x;
+ public static readonly LayoutBase Linear = new LinearLayout();
+ public static readonly LayoutBase Classic = new ClassicLayout();
+ public static readonly LayoutBase Jump = new JumpLayout();
+ public static readonly LayoutBase Natural = new NaturalLayout();
+ public static readonly LayoutBase Motivity = new MotivityLayout();
+ public static readonly LayoutBase Power = new PowerLayout();
+ public static readonly LayoutBase LUT = new LUTLayout();
+ public static readonly LayoutBase Off = new OffLayout();
+ public static readonly LayoutBase Unsupported = new UnsupportedLayout();
#endregion Fields
@@ -47,7 +43,19 @@ namespace grapher
{
AccelDropdown = accelDropdown;
AccelDropdown.Items.Clear();
- AccelDropdown.Items.AddRange(AccelerationTypes.Keys.ToArray());
+ AccelDropdown.Items.AddRange(
+ new LayoutBase[]
+ {
+ Linear,
+ Classic,
+ Jump,
+ Natural,
+ Motivity,
+ Power,
+ LUT,
+ Off
+ });
+
AccelDropdown.SelectedIndexChanged += new System.EventHandler(OnIndexChanged);
GainSwitch = gainSwitch;
@@ -67,7 +75,8 @@ namespace grapher
AccelTypeActiveValue.Height = AccelDropdown.Height;
GainSwitch.Left = Acceleration.Field.Left;
- Layout("Off");
+ AccelerationType = Off;
+ Layout();
ShowingDefault = true;
}
@@ -80,16 +89,6 @@ namespace grapher
public ComboBox AccelDropdown { get; }
- public int AccelerationIndex
- {
- get
- {
- return AccelerationType.Index;
- }
- }
-
- public LayoutBase AccelerationType { get; private set; }
-
public ActiveValueLabel AccelTypeActiveValue { get; }
public Option Acceleration { get; }
@@ -112,6 +111,18 @@ namespace grapher
public CheckBoxOption GainSwitch { get; }
+ public LayoutBase AccelerationType
+ {
+ get
+ {
+ return AccelDropdown.SelectedItem as LayoutBase;
+ }
+ private set
+ {
+ AccelDropdown.SelectedItem = value;
+ }
+ }
+
public override int Top
{
get
@@ -201,18 +212,15 @@ namespace grapher
Show();
}
- public void SetActiveValues(AccelArgs args)
+ public void SetActiveValues(ref AccelArgs args)
{
- AccelerationType = AccelTypeFromSettings(args);
+ AccelerationType = AccelTypeFromSettings(ref args);
AccelTypeActiveValue.SetValue(AccelerationType.Name);
- // Add one to include linear, which is not represented separately in the config
- AccelDropdown.SelectedIndex = AccelerationType.Index + 1;
-
GainSwitch.SetActiveValue(args.legacy);
Weight.SetActiveValue(args.weight);
Cap.SetActiveValue(args.cap);
Offset.SetActiveValue(args.offset);
- Acceleration.SetActiveValue(AccelerationParameterFromArgs(args));
+ Acceleration.SetActiveValue(AccelerationParameterFromArgs(ref args));
Scale.SetActiveValue(args.scale);
Limit.SetActiveValue(args.limit);
Exponent.SetActiveValue(args.exponent);
@@ -243,7 +251,10 @@ namespace grapher
public void SetArgs(ref AccelArgs args)
{
- args.mode = (AccelMode)AccelerationType.Index;
+ if (AccelerationType == Unsupported) throw new NotImplementedException();
+
+ args.mode = AccelerationType.Mode;
+
if (Acceleration.Visible)
{
if (args.mode == AccelMode.natural)
@@ -273,13 +284,6 @@ namespace grapher
if (Weight.Visible) args.weight = Weight.Field.Data;
}
- public AccelArgs GenerateArgs()
- {
- AccelArgs args = new DriverSettings().args.x;
- SetArgs(ref args);
- return args;
- }
-
public override void AlignActiveValues()
{
AccelTypeActiveValue.Align();
@@ -296,17 +300,10 @@ namespace grapher
private void OnIndexChanged(object sender, EventArgs e)
{
- var accelerationTypeString = AccelDropdown.SelectedItem.ToString();
- Layout(accelerationTypeString, Beneath);
+ Layout(Beneath);
ShowingDefault = false;
}
- private void Layout(string type, int top = -1)
- {
- AccelerationType = AccelerationTypes[type];
- Layout(top);
- }
-
private void Layout(int top = -1)
{
if (top < 0)
@@ -328,23 +325,31 @@ namespace grapher
top);
}
- private LayoutBase AccelTypeFromSettings(AccelArgs args)
- {
- LayoutBase type;
- if (args.mode == AccelMode.classic && args.exponent == 2)
+ private LayoutBase AccelTypeFromSettings(ref AccelArgs args)
+ {
+ if (args.spacedTableArgs.mode != SpacedTableMode.off)
{
- type = AccelerationTypes.Values.Where(t => string.Equals(t.Name, LinearLayout.LinearName)).FirstOrDefault();
+ if (!AccelDropdown.Items.Contains(Unsupported))
+ {
+ AccelDropdown.Items.Add(Unsupported);
+ }
+
+ return Unsupported;
}
- else
+
+ switch (args.mode)
{
- int index = (int)args.mode;
- type = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value;
+ case AccelMode.classic: return (args.power == 2) ? Linear : Classic;
+ case AccelMode.jump: return Jump;
+ case AccelMode.natural: return Natural;
+ case AccelMode.motivity: return Motivity;
+ case AccelMode.power: return Power;
+ case AccelMode.lut: return LUT;
+ default: return Off;
}
-
- return type;
}
- private double AccelerationParameterFromArgs(AccelArgs args)
+ private double AccelerationParameterFromArgs(ref AccelArgs args)
{
if (args.mode == AccelMode.motivity)
{
diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs
index 43a2da8..06854b8 100644
--- a/grapher/Models/Options/ApplyOptions.cs
+++ b/grapher/Models/Options/ApplyOptions.cs
@@ -81,55 +81,30 @@ namespace grapher.Models.Options
#region Methods
- public Vec2<AccelMode> GetModes()
+ public void SetArgs(ref Vec2<AccelArgs> args)
{
- var xMode = (AccelMode)OptionSetX.Options.AccelerationIndex;
+ OptionSetX.SetArgs(ref args.x);
- return new Vec2<AccelMode>
+ if (ByComponentVectorXYLock.Checked)
{
- x = xMode,
- y = ByComponentVectorXYLock.Checked ? xMode : (AccelMode)OptionSetY.Options.AccelerationIndex
- };
- }
-
- public Vec2<AccelArgs> GetArgs()
- {
- var xArgs = OptionSetX.GenerateArgs();
-
- return new Vec2<AccelArgs>
+ OptionSetX.SetArgs(ref args.y);
+ }
+ else
{
- x = xArgs,
- y = ByComponentVectorXYLock.Checked ? xArgs : OptionSetY.GenerateArgs()
- };
-
- }
-
- public void SetActiveValues(
- double xSens,
- double ySens,
- double rotation,
- AccelArgs xArgs,
- AccelArgs yArgs,
- bool isWhole)
- {
- Sensitivity.SetActiveValues(xSens, ySens);
- Rotation.SetActiveValue(rotation);
- OptionSetX.SetActiveValues(xArgs);
- WholeVectorCheckBox.Checked = isWhole;
- ByComponentVectorCheckBox.Checked = !isWhole;
- ByComponentVectorXYLock.Checked = xArgs.Equals(yArgs);
- OptionSetY.SetActiveValues(yArgs);
+ OptionSetY.SetArgs(ref args.y);
+ }
}
public void SetActiveValues(DriverSettings settings)
{
- SetActiveValues(
- settings.sensitivity.x,
- settings.sensitivity.y,
- settings.rotation,
- settings.args.x,
- settings.args.y,
- settings.combineMagnitudes);
+ Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y);
+ Rotation.SetActiveValue(settings.rotation);
+
+ WholeVectorCheckBox.Checked = settings.combineMagnitudes;
+ ByComponentVectorCheckBox.Checked = !settings.combineMagnitudes;
+ ByComponentVectorXYLock.Checked = settings.args.x.Equals(settings.args.y);
+ OptionSetX.SetActiveValues(ref settings.args.x);
+ OptionSetY.SetActiveValues(ref settings.args.y);
Directionality.SetActiveValues(settings);
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index b453b6f..50545e4 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -81,6 +81,7 @@
<Compile Include="Layouts\LUTLayout.cs" />
<Compile Include="Layouts\MotivityLayout.cs" />
<Compile Include="Layouts\JumpLayout.cs" />
+ <Compile Include="Layouts\UnsupportedLayout.cs" />
<Compile Include="MessageDialog.cs">
<SubType>Form</SubType>
</Compile>