summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-08-20 12:51:33 -0700
committerJacob Palecki <[email protected]>2020-08-20 12:51:33 -0700
commitfe17d04e571d180e663c7014e803ce790693f4b1 (patch)
treec2e026ab79b73d3e48cc71aebde90b095771587c
parentAdd empty active labels for all options (diff)
downloadrawaccel-fe17d04e571d180e663c7014e803ce790693f4b1.tar.xz
rawaccel-fe17d04e571d180e663c7014e803ce790693f4b1.zip
Display active values
-rw-r--r--common/rawaccel.hpp3
-rw-r--r--grapher/Form1.Designer.cs20
-rw-r--r--grapher/Form1.cs79
-rw-r--r--grapher/Models/AccelGUI.cs13
-rw-r--r--grapher/Models/Calculations/AccelCalculator.cs6
-rw-r--r--grapher/Models/Options/ActiveValueLabel.cs46
-rw-r--r--grapher/Models/Options/ActiveValueLabelXY.cs64
-rw-r--r--grapher/Models/Options/CapOptions.cs20
-rw-r--r--grapher/Models/Options/Option.cs50
-rw-r--r--grapher/Models/Options/OptionXY.cs22
-rw-r--r--grapher/grapher.csproj2
-rw-r--r--wrapper/wrapper.cpp25
-rw-r--r--wrapper/wrapper.hpp18
13 files changed, 318 insertions, 50 deletions
diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp
index 7e72f20..23a8214 100644
--- a/common/rawaccel.hpp
+++ b/common/rawaccel.hpp
@@ -185,6 +185,8 @@ namespace rawaccel {
vec2<accel_scale_clamp> clamp;
velocity_gain_cap gain_cap = velocity_gain_cap();
+
+ accel_args impl_args;
accel_function(const accel_fn_args& args) {
if (args.time_min <= 0) bad_arg("min time must be positive");
@@ -192,6 +194,7 @@ namespace rawaccel {
accel.tag = args.accel_mode;
accel.visit([&](auto& impl) { impl = { args.acc_args }; });
+ impl_args = args.acc_args;
time_min = args.time_min;
speed_offset = args.acc_args.offset;
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index ab9aa99..bb6b9ee 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -99,7 +99,7 @@ namespace grapher
this.VelocityChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.GainChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.MouseLabel = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
+ this.ActiveValueTitle = new System.Windows.Forms.Label();
this.SensitivityActiveXLabel = new System.Windows.Forms.Label();
this.SensitivityActiveYLabel = new System.Windows.Forms.Label();
this.RotationActiveLabel = new System.Windows.Forms.Label();
@@ -600,14 +600,14 @@ namespace grapher
this.MouseLabel.TabIndex = 34;
this.MouseLabel.Text = "Last (x, y): (x, y)";
//
- // label1
+ // ActiveValueTitle
//
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(249, 30);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(67, 13);
- this.label1.TabIndex = 35;
- this.label1.Text = "Active Value";
+ this.ActiveValueTitle.AutoSize = true;
+ this.ActiveValueTitle.Location = new System.Drawing.Point(249, 30);
+ this.ActiveValueTitle.Name = "ActiveValueTitle";
+ this.ActiveValueTitle.Size = new System.Drawing.Size(67, 13);
+ this.ActiveValueTitle.TabIndex = 35;
+ this.ActiveValueTitle.Text = "Active Value";
//
// SensitivityActiveXLabel
//
@@ -734,7 +734,7 @@ namespace grapher
this.Controls.Add(this.RotationActiveLabel);
this.Controls.Add(this.SensitivityActiveYLabel);
this.Controls.Add(this.SensitivityActiveXLabel);
- this.Controls.Add(this.label1);
+ this.Controls.Add(this.ActiveValueTitle);
this.Controls.Add(this.MouseLabel);
this.Controls.Add(this.GainChartY);
this.Controls.Add(this.VelocityChartY);
@@ -832,7 +832,7 @@ namespace grapher
private System.Windows.Forms.ToolStripMenuItem pollRateToolStripMenuItem;
private System.Windows.Forms.ToolStripTextBox PollRateTextBox;
private System.Windows.Forms.ToolStripMenuItem ScaleMenuItem;
- private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label ActiveValueTitle;
private System.Windows.Forms.Label SensitivityActiveXLabel;
private System.Windows.Forms.Label SensitivityActiveYLabel;
private System.Windows.Forms.Label RotationActiveLabel;
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index 6e08683..01e7b20 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -10,12 +10,13 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using grapher.Models.Calculations;
+using grapher.Models.Options;
namespace grapher
{
public enum accel_mode
{
- linear=1, classic, natural, logarithmic, sigmoid, power, noaccel
+ linear=1, classic, natural, logarithmic, sigmoid, power, naturalgain, sigmoidgain, noaccel
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
@@ -99,16 +100,76 @@ namespace grapher
new CheckBox[] { sensXYLock, weightXYLock, capXYLock });
- var sensitivity = new OptionXY(sensitivityBoxX, sensitivityBoxY, sensXYLock, this, 1, sensitivityLabel, "Sensitivity", accelCharts);
- var rotation = new Option(rotationBox, this, 0, rotationLabel, "Rotation");
- var weight = new OptionXY(weightBoxFirst, weightBoxSecond, weightXYLock, this, 1, weightLabel, "Weight", accelCharts);
- var cap = new OptionXY(capBoxX, capBoxY, capXYLock, this, 0, capLabel, "Cap", accelCharts);
- var offset = new Option(offsetBox, this, 0, offsetLabel, "Offset");
+ var sensitivity = new OptionXY(
+ sensitivityBoxX,
+ sensitivityBoxY,
+ sensXYLock,
+ this,
+ 1,
+ sensitivityLabel,
+ new ActiveValueLabelXY(
+ new ActiveValueLabel(SensitivityActiveXLabel, ActiveValueTitle),
+ new ActiveValueLabel(SensitivityActiveYLabel, ActiveValueTitle)),
+ "Sensitivity",
+ accelCharts);
+
+ var rotation = new Option(
+ rotationBox,
+ this,
+ 0,
+ rotationLabel,
+ new ActiveValueLabel(RotationActiveLabel, ActiveValueTitle),
+ "Rotation");
+
+ var weight = new OptionXY(
+ weightBoxFirst,
+ weightBoxSecond,
+ weightXYLock,
+ this,
+ 1,
+ weightLabel,
+ new ActiveValueLabelXY(
+ new ActiveValueLabel(WeightActiveXLabel, ActiveValueTitle),
+ new ActiveValueLabel(WeightActiveYLabel, ActiveValueTitle)),
+ "Weight",
+ accelCharts);
+
+ var cap = new OptionXY(
+ capBoxX,
+ capBoxY,
+ capXYLock,
+ this,
+ 0,
+ capLabel,
+ new ActiveValueLabelXY(
+ new ActiveValueLabel(CapActiveXLabel, ActiveValueTitle),
+ new ActiveValueLabel(CapActiveYLabel, ActiveValueTitle)),
+ "Cap",
+ accelCharts);
+
+ var offset = new Option(
+ offsetBox,
+ this,
+ 0,
+ offsetLabel,
+ new ActiveValueLabel(OffsetActiveLabel, ActiveValueTitle),
+ "Offset");
// The name and layout of these options is handled by AccelerationOptions object.
- var acceleration = new Option(new Field(accelerationBox, this, 0), constantOneLabel);
- var limitOrExponent = new Option(new Field(limitBox, this, 2), constantTwoLabel);
- var midpoint = new Option(new Field(midpointBox, this, 0), constantThreeLabel);
+ var acceleration = new Option(
+ new Field(accelerationBox, this, 0),
+ constantOneLabel,
+ new ActiveValueLabel(AccelerationActiveLabel, ActiveValueTitle));
+
+ var limitOrExponent = new Option(
+ new Field(limitBox, this, 2),
+ constantTwoLabel,
+ new ActiveValueLabel(LimitExpActiveLabel, ActiveValueTitle));
+
+ var midpoint = new Option(
+ new Field(midpointBox, this, 0),
+ constantThreeLabel,
+ new ActiveValueLabel(MidpointActiveLabel, ActiveValueTitle));
var accelerationOptions = new AccelOptions(
accelTypeDrop,
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 2c27bf7..afc3def 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -102,6 +102,19 @@ namespace grapher
{
AccelCalculator.Calculate(AccelCharts.AccelData, ManagedAcceleration);
AccelCharts.Bind();
+ UpdateActiveValueLabels();
+ }
+
+ public void UpdateActiveValueLabels()
+ {
+ Sensitivity.SetActiveValues(ManagedAcceleration.SensitivityX, ManagedAcceleration.SensitivityY);
+ Rotation.SetActiveValue(ManagedAcceleration.Rotation);
+ Offset.SetActiveValue(ManagedAcceleration.Offset);
+ Acceleration.SetActiveValue(ManagedAcceleration.Acceleration);
+ Cap.SetActiveValues(ManagedAcceleration.GainCap, ManagedAcceleration.CapX, ManagedAcceleration.CapY, ManagedAcceleration.GainCapEnabled);
+ Weight.SetActiveValues(ManagedAcceleration.WeightX, ManagedAcceleration.WeightY);
+ LimitOrExponent.SetActiveValue(ManagedAcceleration.LimitExp);
+ Midpoint.SetActiveValue(ManagedAcceleration.Midpoint);
}
private void OnScaleMenuItemClick(object sender, EventArgs e)
diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs
index 0346fb8..63ed281 100644
--- a/grapher/Models/Calculations/AccelCalculator.cs
+++ b/grapher/Models/Calculations/AccelCalculator.cs
@@ -52,9 +52,9 @@ namespace grapher.Models.Calculations
data.Clear();
- Calculate(data.Combined, accel, accel.GetSensitivityX(), MagnitudesCombined);
- Calculate(data.X, accel, accel.GetSensitivityX(), MagnitudesX);
- Calculate(data.Y, accel, accel.GetSensitivityY(), MagnitudesY);
+ Calculate(data.Combined, accel, accel.SensitivityX, MagnitudesCombined);
+ Calculate(data.X, accel, accel.SensitivityX, MagnitudesX);
+ Calculate(data.Y, accel, accel.SensitivityY, MagnitudesY);
}
public static void Calculate(AccelChartData data, ManagedAccel accel, double starter, ICollection<MagnitudeData> magnitudeData)
diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs
new file mode 100644
index 0000000..ecafaba
--- /dev/null
+++ b/grapher/Models/Options/ActiveValueLabel.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options
+{
+ public class ActiveValueLabel
+ {
+ public const string DefaultFormatString = "0.######";
+
+ public ActiveValueLabel(Label valueLabel, Label centeringLabel)
+ {
+ ValueLabel = valueLabel;
+ ValueLabel.ForeColor = Color.DarkGray;
+ ValueLabel.Left = centeringLabel.Left;
+ ValueLabel.Width = centeringLabel.Width;
+ ValueLabel.AutoSize = false;
+ ValueLabel.TextAlign = ContentAlignment.MiddleCenter;
+ }
+
+ public Label ValueLabel { get; }
+
+ private int Left { get; }
+
+ private int Width { get; }
+
+ public void Hide()
+ {
+ ValueLabel.Hide();
+ }
+
+ public void Show()
+ {
+ ValueLabel.Show();
+ }
+
+ public void SetValue(double value)
+ {
+ ValueLabel.Text = value.ToString(DefaultFormatString);
+ }
+ }
+}
diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs
new file mode 100644
index 0000000..b3b580f
--- /dev/null
+++ b/grapher/Models/Options/ActiveValueLabelXY.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Models.Options
+{
+ public class ActiveValueLabelXY
+ {
+ public const int ActiveLabelXYSeparation = 4;
+
+ public ActiveValueLabelXY(
+ ActiveValueLabel x,
+ ActiveValueLabel y)
+ {
+ X = x;
+ Y = y;
+ Combined = false;
+ SetCombined();
+ }
+
+ public ActiveValueLabel X { get; }
+
+ public ActiveValueLabel Y { get; }
+
+ public bool Combined { get; private set; }
+
+ public void SetValues(double x, double y)
+ {
+ X.SetValue(x);
+ Y.SetValue(y);
+
+ if (x == y)
+ {
+ SetCombined();
+ }
+ else
+ {
+ SetSeparate();
+ }
+ }
+
+ public void SetCombined()
+ {
+ if (!Combined)
+ {
+ Y.Hide();
+ }
+
+ Combined = true;
+ }
+
+ public void SetSeparate()
+ {
+ if (Combined)
+ {
+ Y.Show();
+ }
+
+ Combined = false;
+ }
+ }
+}
diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs
index 2ee7f6b..fedda08 100644
--- a/grapher/Models/Options/CapOptions.cs
+++ b/grapher/Models/Options/CapOptions.cs
@@ -30,13 +30,13 @@ namespace grapher
EnableSensitivityCap();
}
- ToolStripMenuItem SensitivityCapCheck { get; }
+ public ToolStripMenuItem SensitivityCapCheck { get; }
- ToolStripMenuItem VelocityGainCapCheck { get; }
+ public ToolStripMenuItem VelocityGainCapCheck { get; }
- OptionXY CapOption { get; }
+ public OptionXY CapOption { get; }
- OptionXY WeightOption { get; }
+ public OptionXY WeightOption { get; }
public double SensitivityCapX {
get
@@ -82,6 +82,18 @@ namespace grapher
public bool IsSensitivityGain { get; private set; }
+ public void SetActiveValues(double gainCap, double sensCapX, double sensCapY, bool capGainEnabled)
+ {
+ if (capGainEnabled)
+ {
+ CapOption.SetActiveValues(gainCap, gainCap);
+ }
+ else
+ {
+ CapOption.SetActiveValues(sensCapX, sensCapY);
+ }
+ }
+
void OnSensitivityCapCheckClick(object sender, EventArgs e)
{
if (!SensitivityCapCheck.Checked)
diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs
index eb5105e..bacd760 100644
--- a/grapher/Models/Options/Option.cs
+++ b/grapher/Models/Options/Option.cs
@@ -1,4 +1,5 @@
-using System;
+using grapher.Models.Options;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,19 +10,42 @@ namespace grapher
{
public class Option
{
- public Option(Field field, Label label)
+ public Option(
+ Field field,
+ Label label,
+ ActiveValueLabel activeValueLabel)
{
Field = field;
Label = label;
+ ActiveValueLabel = activeValueLabel;
}
- public Option(TextBox box, Form containingForm, double defaultData, Label label)
- : this(new Field(box, containingForm, defaultData), label)
+ public Option(
+ TextBox box,
+ Form containingForm,
+ double defaultData,
+ Label label,
+ ActiveValueLabel activeValueLabel)
+ : this(
+ new Field(box, containingForm, defaultData),
+ label,
+ activeValueLabel)
{
}
- public Option(TextBox box, Form containingForm, double defaultData, Label label, string startingName)
- : this(box, containingForm, defaultData, label)
+ public Option(
+ TextBox box,
+ Form containingForm,
+ double defaultData,
+ Label label,
+ ActiveValueLabel activeValueLabel,
+ string startingName)
+ : this(
+ box,
+ containingForm,
+ defaultData,
+ label,
+ activeValueLabel)
{
SetName(startingName);
}
@@ -30,22 +54,36 @@ namespace grapher
public Label Label { get; }
+ public ActiveValueLabel ActiveValueLabel { get; }
+
public void SetName(string name)
{
Label.Text = name;
Label.Left = Convert.ToInt32((Field.Box.Left / 2.0) - (Label.Width / 2.0));
}
+ public void SetActiveValue(double value)
+ {
+ ActiveValueLabel.SetValue(value);
+ }
+
public void Hide()
{
Field.Box.Hide();
Label.Hide();
+ ActiveValueLabel.Hide();
}
public void Show()
{
Field.Box.Show();
Label.Show();
+ ActiveValueLabel.Show();
+ }
+
+ public void UpdateActiveValue(double value)
+ {
+ ActiveValueLabel.SetValue(value);
}
public void Show(string name)
diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs
index 90a46d7..b22bb78 100644
--- a/grapher/Models/Options/OptionXY.cs
+++ b/grapher/Models/Options/OptionXY.cs
@@ -1,4 +1,5 @@
-using System;
+using grapher.Models.Options;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,10 +10,11 @@ namespace grapher
{
public class OptionXY
{
- public OptionXY(FieldXY fields, Label label)
+ public OptionXY(FieldXY fields, Label label, ActiveValueLabelXY activeValueLabels)
{
Fields = fields;
Label = label;
+ ActiveValueLabels = activeValueLabels;
}
public OptionXY(
@@ -22,8 +24,9 @@ namespace grapher
Form containingForm,
double defaultData,
Label label,
- AccelCharts accelCharts)
- : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, accelCharts), label)
+ AccelCharts accelCharts,
+ ActiveValueLabelXY activeValueLabels)
+ : this(new FieldXY(xBox, yBox, lockCheckBox, containingForm, defaultData, accelCharts), label, activeValueLabels)
{
}
@@ -34,6 +37,7 @@ namespace grapher
Form containingForm,
double defaultData,
Label label,
+ ActiveValueLabelXY activeValueLabels,
string startingName,
AccelCharts accelCharts):
this(
@@ -43,7 +47,8 @@ namespace grapher
containingForm,
defaultData,
label,
- accelCharts)
+ accelCharts,
+ activeValueLabels)
{
SetName(startingName);
}
@@ -52,12 +57,19 @@ namespace grapher
public Label Label { get; }
+ public ActiveValueLabelXY ActiveValueLabels { get; }
+
public void SetName(string name)
{
Label.Text = name;
Label.Left = Convert.ToInt32((Fields.XField.Box.Left / 2.0) - (Label.Width / 2.0));
}
+ public void SetActiveValues(double x, double y)
+ {
+ ActiveValueLabels.SetValues(x, y);
+ }
+
public void Hide()
{
Fields.Hide();
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index 2d9f4ab..64f5e3c 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -58,6 +58,8 @@
<Compile Include="Models\Mouse\MouseWatcher.cs" />
<Compile Include="Models\Mouse\PointData.cs" />
<Compile Include="Models\Options\AccelOptions.cs" />
+ <Compile Include="Models\Options\ActiveValueLabel.cs" />
+ <Compile Include="Models\Options\ActiveValueLabelXY.cs" />
<Compile Include="Models\Options\CapOptions.cs" />
<Compile Include="Models\Charts\ChartXY.cs" />
<Compile Include="Models\Fields\Field.cs" />
diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp
index 6a92caa..067a874 100644
--- a/wrapper/wrapper.cpp
+++ b/wrapper/wrapper.cpp
@@ -5,16 +5,6 @@
using namespace rawaccel;
using namespace System;
-double ManagedAccel::GetSensitivityX()
-{
- return modifier_instance->sensitivity.x;
-}
-
-double ManagedAccel::GetSensitivityY()
-{
- return modifier_instance->sensitivity.y;
-}
-
Tuple<double, double>^ ManagedAccel::Accelerate(int x, int y, double time)
{
vec2d input_vec2d = {
@@ -64,6 +54,21 @@ void ManagedAccel::UpdateAccel(
ReadFromDriver();
}
+double ManagedAccel::SensitivityX::get() { return modifier_instance->sensitivity.x; }
+double ManagedAccel::SensitivityY::get() { return modifier_instance->sensitivity.y; }
+double ManagedAccel::Rotation::get() { return modifier_instance->rotate.rot_vec.x; }
+int ManagedAccel::Type::get() { return modifier_instance->accel_fn.accel.tag; }
+double ManagedAccel::Acceleration::get() { return modifier_instance->accel_fn.impl_args.accel; }
+double ManagedAccel::CapX::get() { return modifier_instance->accel_fn.clamp.x.hi; }
+double ManagedAccel::CapY::get() { return modifier_instance->accel_fn.clamp.y.hi; }
+double ManagedAccel::GainCap::get() { return modifier_instance->accel_fn.gain_cap.threshold; }
+bool ManagedAccel::GainCapEnabled::get() { return modifier_instance->accel_fn.gain_cap.cap_gain_enabled; }
+double ManagedAccel::WeightX::get() { return modifier_instance->accel_fn.impl_args.weight.x; }
+double ManagedAccel::WeightY::get() { return modifier_instance->accel_fn.impl_args.weight.y; }
+double ManagedAccel::Offset::get() { return modifier_instance->accel_fn.speed_offset; }
+double ManagedAccel::LimitExp::get() { return modifier_instance->accel_fn.impl_args.limit; }
+double ManagedAccel::Midpoint::get() { return modifier_instance->accel_fn.impl_args.midpoint; }
+
void ManagedAccel::WriteToDriver()
{
driverWriter->writeToDriver(modifier_instance);
diff --git a/wrapper/wrapper.hpp b/wrapper/wrapper.hpp
index b086672..e229735 100644
--- a/wrapper/wrapper.hpp
+++ b/wrapper/wrapper.hpp
@@ -40,9 +40,21 @@ public:
}
}
- double GetSensitivityX();
-
- double GetSensitivityY();
+ // Duplicate all relevant rawaccel struct members here for access and display in GUI
+ property double SensitivityX { double get(); }
+ property double SensitivityY { double get(); }
+ property double Rotation { double get(); }
+ property int Type { int get(); }
+ property double Acceleration { double get(); }
+ property double CapX { double get(); }
+ property double CapY { double get(); }
+ property double GainCap { double get(); }
+ property bool GainCapEnabled { bool get(); }
+ property double WeightX { double get(); }
+ property double WeightY { double get(); }
+ property double Offset { double get(); }
+ property double LimitExp { double get(); }
+ property double Midpoint { double get(); }
mouse_modifier* GetInstance()
{