diff options
| -rw-r--r-- | common/accel-base.hpp | 2 | ||||
| -rw-r--r-- | common/rawaccel.hpp | 105 | ||||
| -rw-r--r-- | grapher/AccelGUI.cs | 8 | ||||
| -rw-r--r-- | grapher/CapOptions.cs | 137 | ||||
| -rw-r--r-- | grapher/FieldXY.cs | 54 | ||||
| -rw-r--r-- | grapher/Form1.Designer.cs | 128 | ||||
| -rw-r--r-- | grapher/Form1.cs | 17 | ||||
| -rw-r--r-- | grapher/OptionXY.cs | 6 | ||||
| -rw-r--r-- | grapher/grapher.csproj | 1 | ||||
| -rw-r--r-- | wrapper/wrapper.cpp | 4 | ||||
| -rw-r--r-- | wrapper/wrapper.hpp | 3 |
11 files changed, 391 insertions, 74 deletions
diff --git a/common/accel-base.hpp b/common/accel-base.hpp index 91510a4..60b7362 100644 --- a/common/accel-base.hpp +++ b/common/accel-base.hpp @@ -24,6 +24,7 @@ namespace rawaccel { double exponent = 2; double midpoint = 0; double power_scale = 1; + double gain_cap = 0; vec2d weight = { 1, 1 }; }; @@ -68,6 +69,7 @@ namespace rawaccel { /// <param name="args">Arguments to verified.</param> void verify(const accel_args& args) const { if (args.accel < 0) bad_arg("accel can not be negative, use a negative weight to compensate"); + if (args.gain_cap > 0 && weight.x != weight.y) bad_arg("weight x and y values must be equal with a gain cap"); } accel_base() = default; diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp index 7aa1eb2..8dc4825 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -78,6 +78,83 @@ namespace rawaccel { /// <summary> Tagged union to hold all accel implementations and allow "polymorphism" via a visitor call. </summary> using accel_impl_t = tagged_union<accel_linear, accel_classic, accel_natural, accel_logarithmic, accel_sigmoid, accel_power, accel_noaccel>; + /// <summary> Struct to hold information about applying a gain cap. </summary> + struct velocity_gain_cap { + + // <summary> The minimum speed past which gain cap is applied. </summary> + double threshold = 0; + + // <summary> The gain at the point of cap </summary> + double slope = 0; + + // <summary> The intercept for the line with above slope to give continuous velocity function </summary> + double intercept = 0; + + // <summary> Whether or not velocity gain cap is enabled </summary> + bool cap_gain_enabled = false; + + /// <summary> + /// Initializes a velocity gain cap for a certain speed threshold + /// by estimating the slope at the threshold and creating a line + /// with that slope for output velocity calculations. + /// </summary> + /// <param name="speed"> The speed at which velocity gain cap will kick in </param> + /// <param name="offset"> The offset applied in accel calculations </param> + /// <param name="accel"> The accel implementation used in the containing accel_fn </param> + velocity_gain_cap(double speed, double offset, accel_impl_t accel) + { + if (speed <= 0) return; + + // Estimate gain at cap point by taking line between two input vs output velocity points. + // First input velocity point is at cap; for second pick a velocity a tiny bit larger. + double speed_second = 1.001 * speed; + double speed_diff = speed_second - speed; + + // Return if by glitch or strange values the difference in points is 0. + if (speed_diff == 0) return; + + cap_gain_enabled = true; + + // Find the corresponding output velocities for the two points. + // Subtract offset for acceleration, like in accel_fn() + double out_first = accel.visit([=](auto&& impl) { + double accel_val = impl.accelerate(speed-offset); + return impl.scale(accel_val); + }).x * speed; + double out_second = accel.visit([=](auto&& impl) { + double accel_val = impl.accelerate(speed_second-offset); + return impl.scale(accel_val); + }).x * speed_second; + + // Calculate slope and intercept from two points. + slope = (out_second - out_first) / speed_diff; + intercept = out_first - slope * speed; + + threshold = speed; + } + + /// <summary> + /// Applies velocity gain cap to speed. + /// Returns scale value by which to multiply input to place on gain cap line. + /// </summary> + /// <param name="speed"> Speed to be capped </param> + /// <returns> Scale multiplier for input </returns> + inline double operator()(double speed) const { + return slope + intercept / speed; + } + + /// <summary> + /// Whether gain cap should be applied to given speed. + /// </summary> + /// <param name="speed"> Speed to check against threshold. </param> + /// <returns> Whether gain cap should be applied. </returns> + inline bool should_apply(double speed) const { + return cap_gain_enabled && speed > threshold; + } + + velocity_gain_cap() = default; + }; + struct accel_fn_args { accel_args acc_args; int accel_mode = accel_impl_t::id<accel_noaccel>; @@ -105,17 +182,20 @@ namespace rawaccel { /// <summary> The object which sets a min and max for the acceleration scale. </summary> vec2<accel_scale_clamp> clamp; + velocity_gain_cap gain_cap = velocity_gain_cap(); + accel_function(const accel_fn_args& args) { if (args.time_min <= 0) bad_arg("min time must be positive"); if (args.acc_args.offset < 0) bad_arg("offset must not be negative"); accel.tag = args.accel_mode; - accel.visit([&](auto& impl){ impl = { args.acc_args }; }); + accel.visit([&](auto& impl) { impl = { args.acc_args }; }); time_min = args.time_min; speed_offset = args.acc_args.offset; clamp.x = accel_scale_clamp(args.cap.x); clamp.y = accel_scale_clamp(args.cap.y); + gain_cap = velocity_gain_cap(args.acc_args.gain_cap, speed_offset, accel); } /// <summary> @@ -127,12 +207,23 @@ namespace rawaccel { inline vec2d operator()(const vec2d& input, milliseconds time) const { double mag = sqrtsd(input.x * input.x + input.y * input.y); double time_clamped = clampsd(time, time_min, 100); - double speed = maxsd(mag / time_clamped - speed_offset, 0); - - vec2d scale = accel.visit([=](auto&& impl) { - double accel_val = impl.accelerate(speed); - return impl.scale(accel_val); - }); + double raw_speed = mag / time_clamped; + + vec2d scale; + + // gain_cap needs raw speed for velocity line calculation + if (gain_cap.should_apply(raw_speed)) + { + double gain_cap_scale = gain_cap(raw_speed); + scale = { gain_cap_scale, gain_cap_scale }; + } + else + { + scale = accel.visit([=](auto&& impl) { + double accel_val = impl.accelerate(maxsd(mag / time_clamped - speed_offset, 0)); + return impl.scale(accel_val); + }); + } return { input.x * clamp.x(scale.x), diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs index c660afe..ae05359 100644 --- a/grapher/AccelGUI.cs +++ b/grapher/AccelGUI.cs @@ -30,7 +30,7 @@ namespace grapher OptionXY sensitivity, Option rotation, OptionXY weight, - OptionXY cap, + CapOptions cap, Option offset, Option acceleration, Option limtOrExp, @@ -78,7 +78,7 @@ namespace grapher public OptionXY Weight { get; } - public OptionXY Cap { get; } + public CapOptions Cap { get; } public Option Offset { get; } @@ -149,8 +149,6 @@ namespace grapher var inDiff = magnitudeData.magnitude - lastInputMagnitude; var outDiff = outMagnitude - lastOutputMagnitude; var slope = inDiff > 0 ? outDiff / inDiff : Sensitivity.Fields.X; - lastInputMagnitude = magnitudeData.magnitude; - lastOutputMagnitude = outMagnitude; if (!OrderedAccelPoints.ContainsKey(magnitudeData.magnitude)) { @@ -167,6 +165,8 @@ namespace grapher OrderedGainPoints.Add(magnitudeData.magnitude, slope); } + lastInputMagnitude = magnitudeData.magnitude; + lastOutputMagnitude = outMagnitude; } AccelCharts.SensitivityChart.Series[0].Points.DataBindXY(OrderedAccelPoints.Keys, OrderedAccelPoints.Values); diff --git a/grapher/CapOptions.cs b/grapher/CapOptions.cs new file mode 100644 index 0000000..2ee7f6b --- /dev/null +++ b/grapher/CapOptions.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher +{ + public class CapOptions + { + public CapOptions( + ToolStripMenuItem sensitivityCapCheck, + ToolStripMenuItem velocityGainCapCheck, + OptionXY capOption, + OptionXY weightOption) + { + + SensitivityCapCheck = sensitivityCapCheck; + VelocityGainCapCheck = velocityGainCapCheck; + CapOption = capOption; + WeightOption = weightOption; + + SensitivityCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick); + VelocityGainCapCheck.Click += new System.EventHandler(OnVelocityGainCapCheckClick); + + SensitivityCapCheck.CheckedChanged += new System.EventHandler(OnSensitivityCapCheckedChange); + VelocityGainCapCheck.CheckedChanged += new System.EventHandler(OnVelocityGainCapCheckedChange); + + EnableSensitivityCap(); + } + + ToolStripMenuItem SensitivityCapCheck { get; } + + ToolStripMenuItem VelocityGainCapCheck { get; } + + OptionXY CapOption { get; } + + OptionXY WeightOption { get; } + + public double SensitivityCapX { + get + { + if (IsSensitivityGain) + { + return CapOption.Fields.X; + } + else + { + return 0; + } + } + } + + public double SensitivityCapY { + get + { + if (IsSensitivityGain) + { + return CapOption.Fields.Y; + } + else + { + return 0; + } + } + } + + public double VelocityGainCap { + get + { + if (IsSensitivityGain) + { + return 0; + } + else + { + return CapOption.Fields.X; + } + } + } + + public bool IsSensitivityGain { get; private set; } + + void OnSensitivityCapCheckClick(object sender, EventArgs e) + { + if (!SensitivityCapCheck.Checked) + { + VelocityGainCapCheck.Checked = false; + SensitivityCapCheck.Checked = true; + } + } + + void OnVelocityGainCapCheckClick(object sender, EventArgs e) + { + if (!VelocityGainCapCheck.Checked) + { + VelocityGainCapCheck.Checked = true; + SensitivityCapCheck.Checked = false; + } + } + + void OnSensitivityCapCheckedChange(object sender, EventArgs e) + { + if (SensitivityCapCheck.Checked == true) + { + EnableSensitivityCap(); + } + } + + void OnVelocityGainCapCheckedChange(object sender, EventArgs e) + { + if (SensitivityCapCheck.Checked == true) + { + EnableVelocityGainCap(); + } + } + + void EnableSensitivityCap() + { + IsSensitivityGain = true; + CapOption.Fields.LockCheckBox.Enabled = true; + WeightOption.Fields.LockCheckBox.Enabled = true; + CapOption.SetName("Sensitivity Cap"); + } + + void EnableVelocityGainCap() + { + IsSensitivityGain = false; + CapOption.Fields.LockCheckBox.Checked = true; + CapOption.Fields.LockCheckBox.Enabled = false; + WeightOption.Fields.LockCheckBox.Checked = true; + WeightOption.Fields.LockCheckBox.Enabled = false; + CapOption.SetName("Velocity Gain Cap"); + } + } +} diff --git a/grapher/FieldXY.cs b/grapher/FieldXY.cs index 23c5de1..7338962 100644 --- a/grapher/FieldXY.cs +++ b/grapher/FieldXY.cs @@ -15,7 +15,10 @@ namespace grapher YField = new Field(yBox, containingForm, defaultData); LockCheckBox = lockCheckBox; LockCheckBox.CheckedChanged += new System.EventHandler(CheckChanged); - SetLocked(); + DefaultWidthX = XField.Box.Width; + DefaultWidthY = YField.Box.Width; + CombinedWidth = DefaultWidthX + DefaultWidthY + YField.Box.Left - (XField.Box.Left + DefaultWidthX); + SetCombined(); } public double X { @@ -26,7 +29,7 @@ namespace grapher { get { - if (Locked) + if (Combined) { return X; } @@ -43,29 +46,41 @@ namespace grapher public Field YField { get; } - private bool Locked { get; set; } + private bool Combined { get; set; } + + private int DefaultWidthX { get; } + + private int DefaultWidthY { get; } + + private int CombinedWidth { get; } private void CheckChanged(object sender, EventArgs e) { if (LockCheckBox.CheckState == CheckState.Checked) { - SetLocked(); + SetCombined(); } else { - SetUnlocked(); + SetSeparate(); } } - private void SetLocked() + public void SetCombined() { - Locked = true; + Combined = true; YField.SetToUnavailable(); + YField.Box.Hide(); + XField.Box.Width = CombinedWidth; } - private void SetUnlocked() + public void SetSeparate() { - Locked = false; + Combined = false; + + XField.Box.Width = DefaultWidthX; + YField.Box.Width = DefaultWidthY; + if (XField.State == Field.FieldState.Default) { YField.SetToDefault(); @@ -74,6 +89,27 @@ namespace grapher { YField.SetToEntered(XField.Data); } + + if (XField.Box.Visible) + { + YField.Box.Show(); + } + } + + public void Show() + { + XField.Box.Show(); + + if (!Combined) + { + YField.Box.Show(); + } + } + + public void Hide() + { + XField.Box.Hide(); + YField.Box.Hide(); } } } diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 1a268d6..849801b 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -30,15 +30,15 @@ namespace grapher /// </summary> private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea10 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend10 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea11 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend11 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea12 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend12 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend5 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend6 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.accelTypeDrop = new System.Windows.Forms.ComboBox(); this.sensitivityBoxX = new System.Windows.Forms.TextBox(); @@ -70,6 +70,10 @@ namespace grapher this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.graphsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showVelocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.capStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sensitivityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.velocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit(); @@ -78,19 +82,19 @@ namespace grapher // // AccelerationChart // - chartArea10.AxisX.Title = "Speed (counts/ms)"; - chartArea10.AxisY.Title = "Sensitivity (magnitude ratio)"; - chartArea10.Name = "ChartArea1"; - this.AccelerationChart.ChartAreas.Add(chartArea10); - legend10.Name = "Legend1"; - this.AccelerationChart.Legends.Add(legend10); + chartArea4.AxisX.Title = "Speed (counts/ms)"; + chartArea4.AxisY.Title = "Sensitivity (magnitude ratio)"; + chartArea4.Name = "ChartArea1"; + this.AccelerationChart.ChartAreas.Add(chartArea4); + legend4.Name = "Legend1"; + this.AccelerationChart.Legends.Add(legend4); this.AccelerationChart.Location = new System.Drawing.Point(242, 0); this.AccelerationChart.Name = "AccelerationChart"; - series10.ChartArea = "ChartArea1"; - series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series10.Legend = "Legend1"; - series10.Name = "Accelerated Sensitivity"; - this.AccelerationChart.Series.Add(series10); + series4.ChartArea = "ChartArea1"; + series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series4.Legend = "Legend1"; + series4.Name = "Accelerated Sensitivity"; + this.AccelerationChart.Series.Add(series4); this.AccelerationChart.Size = new System.Drawing.Size(721, 328); this.AccelerationChart.TabIndex = 0; this.AccelerationChart.Text = "chart1"; @@ -313,38 +317,38 @@ namespace grapher // // VelocityChart // - chartArea11.AxisX.Title = "Speed (count/ms)"; - chartArea11.AxisY.Title = "Output Speed (counts/ms)"; - chartArea11.Name = "ChartArea1"; - this.VelocityChart.ChartAreas.Add(chartArea11); - legend11.Name = "Legend1"; - this.VelocityChart.Legends.Add(legend11); + chartArea5.AxisX.Title = "Speed (count/ms)"; + chartArea5.AxisY.Title = "Output Speed (counts/ms)"; + chartArea5.Name = "ChartArea1"; + this.VelocityChart.ChartAreas.Add(chartArea5); + legend5.Name = "Legend1"; + this.VelocityChart.Legends.Add(legend5); this.VelocityChart.Location = new System.Drawing.Point(242, 334); this.VelocityChart.Name = "VelocityChart"; - series11.ChartArea = "ChartArea1"; - series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series11.Legend = "Legend1"; - series11.Name = "Mouse Velocity"; - this.VelocityChart.Series.Add(series11); + series5.ChartArea = "ChartArea1"; + series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series5.Legend = "Legend1"; + series5.Name = "Mouse Velocity"; + this.VelocityChart.Series.Add(series5); this.VelocityChart.Size = new System.Drawing.Size(721, 307); this.VelocityChart.TabIndex = 28; this.VelocityChart.Text = "chart1"; // // GainChart // - chartArea12.AxisX.Title = "Speed (counts/ms)"; - chartArea12.AxisY.Title = "Slope of Velocity Chart"; - chartArea12.Name = "ChartArea1"; - this.GainChart.ChartAreas.Add(chartArea12); - legend12.Name = "Legend1"; - this.GainChart.Legends.Add(legend12); + chartArea6.AxisX.Title = "Speed (counts/ms)"; + chartArea6.AxisY.Title = "Slope of Velocity Chart"; + chartArea6.Name = "ChartArea1"; + this.GainChart.ChartAreas.Add(chartArea6); + legend6.Name = "Legend1"; + this.GainChart.Legends.Add(legend6); this.GainChart.Location = new System.Drawing.Point(242, 647); this.GainChart.Name = "GainChart"; - series12.ChartArea = "ChartArea1"; - series12.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series12.Legend = "Legend1"; - series12.Name = "Velocity Gain"; - this.GainChart.Series.Add(series12); + series6.ChartArea = "ChartArea1"; + series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series6.Legend = "Legend1"; + series6.Name = "Velocity Gain"; + this.GainChart.Series.Add(series6); this.GainChart.Size = new System.Drawing.Size(721, 309); this.GainChart.TabIndex = 29; this.GainChart.Text = "chart1"; @@ -353,7 +357,8 @@ namespace grapher // this.menuStrip1.BackColor = System.Drawing.SystemColors.ControlLight; this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.graphsToolStripMenuItem}); + this.graphsToolStripMenuItem, + this.advancedToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(963, 24); @@ -376,11 +381,42 @@ namespace grapher this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(187, 22); this.showVelocityGainToolStripMenuItem.Text = "Show Velocity && Gain"; // + // advancedToolStripMenuItem + // + this.advancedToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.capStyleToolStripMenuItem}); + this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem"; + this.advancedToolStripMenuItem.Size = new System.Drawing.Size(72, 20); + this.advancedToolStripMenuItem.Text = "Advanced"; + // + // capStyleToolStripMenuItem + // + this.capStyleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.sensitivityToolStripMenuItem, + this.velocityGainToolStripMenuItem}); + this.capStyleToolStripMenuItem.Name = "capStyleToolStripMenuItem"; + this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.capStyleToolStripMenuItem.Text = "Cap Style"; + // + // sensitivityToolStripMenuItem + // + this.sensitivityToolStripMenuItem.Checked = true; + this.sensitivityToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.sensitivityToolStripMenuItem.Name = "sensitivityToolStripMenuItem"; + this.sensitivityToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.sensitivityToolStripMenuItem.Text = "Sensitivity"; + // + // velocityGainToolStripMenuItem + // + this.velocityGainToolStripMenuItem.Name = "velocityGainToolStripMenuItem"; + this.velocityGainToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.velocityGainToolStripMenuItem.Text = "Velocity Gain"; + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(963, 955); + this.ClientSize = new System.Drawing.Size(963, 958); this.Controls.Add(this.GainChart); this.Controls.Add(this.VelocityChart); this.Controls.Add(this.LockXYLabel); @@ -456,6 +492,10 @@ namespace grapher private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem graphsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem showVelocityGainToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem advancedToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem capStyleToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem sensitivityToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem velocityGainToolStripMenuItem; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 237a25d..518ffc3 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -33,6 +33,7 @@ namespace grapher public double exponent; public double midpoint; public double power_scale; + public double gain_cap; public vec2d weight; } @@ -75,6 +76,7 @@ namespace grapher args.acc_fn_args.acc_args.power_scale = 1; args.acc_fn_args.acc_args.weight.x = 1; args.acc_fn_args.acc_args.weight.y = 1; + args.acc_fn_args.acc_args.gain_cap = 0; args.acc_fn_args.accel_mode = (int)accel_mode.natural; args.acc_fn_args.time_min = 0.4; args.acc_fn_args.cap.x = 0; @@ -114,6 +116,12 @@ namespace grapher }, writeButton); + var capOptions = new CapOptions( + sensitivityToolStripMenuItem, + velocityGainToolStripMenuItem, + cap, + weight); + AccelGUI = new AccelGUI( this, new AccelCharts( @@ -127,7 +135,7 @@ namespace grapher sensitivity, rotation, weight, - cap, + capOptions, offset, acceleration, limitOrExponent, @@ -218,12 +226,13 @@ namespace grapher AccelGUI.Sensitivity.Fields.Y, AccelGUI.Weight.Fields.X, AccelGUI.Weight.Fields.Y, - AccelGUI.Cap.Fields.X, - AccelGUI.Cap.Fields.Y, + AccelGUI.Cap.SensitivityCapX, + AccelGUI.Cap.SensitivityCapY, AccelGUI.Offset.Field.Data, AccelGUI.Acceleration.Field.Data, AccelGUI.LimitOrExponent.Field.Data, - AccelGUI.Midpoint.Field.Data); + AccelGUI.Midpoint.Field.Data, + AccelGUI.Cap.VelocityGainCap); AccelGUI.UpdateGraph(); } diff --git a/grapher/OptionXY.cs b/grapher/OptionXY.cs index 1fdf244..ca1559d 100644 --- a/grapher/OptionXY.cs +++ b/grapher/OptionXY.cs @@ -57,16 +57,14 @@ namespace grapher public void Hide() { - Fields.XField.Box.Hide(); - Fields.YField.Box.Hide(); + Fields.Hide(); Fields.LockCheckBox.Hide(); Label.Hide(); } public void Show() { - Fields.XField.Box.Show(); - Fields.YField.Box.Show(); + Fields.Show(); Fields.LockCheckBox.Show(); Label.Show(); } diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 1611fd3..da70b46 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -50,6 +50,7 @@ <Compile Include="AccelCharts.cs" /> <Compile Include="AccelGUI.cs" /> <Compile Include="AccelOptions.cs" /> + <Compile Include="CapOptions.cs" /> <Compile Include="Field.cs" /> <Compile Include="FieldXY.cs" /> <Compile Include="Form1.cs"> diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index e29f08d..0afb386 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -28,7 +28,8 @@ void ManagedAccel::UpdateAccel( double offset, double accel, double lim_exp, - double midpoint) + double midpoint, + double gain_cap) { modifier_args args{}; args.acc_fn_args.accel_mode = mode; @@ -44,6 +45,7 @@ void ManagedAccel::UpdateAccel( args.acc_fn_args.acc_args.limit = lim_exp; args.acc_fn_args.acc_args.exponent = lim_exp; args.acc_fn_args.acc_args.midpoint = midpoint; + args.acc_fn_args.acc_args.gain_cap = gain_cap; mouse_modifier* temp_modifier = new mouse_modifier(args); driverWriter->writeToDriver(temp_modifier); diff --git a/wrapper/wrapper.hpp b/wrapper/wrapper.hpp index 1933ccc..20ee095 100644 --- a/wrapper/wrapper.hpp +++ b/wrapper/wrapper.hpp @@ -59,7 +59,8 @@ public: double offset, double accel, double lim_exp, - double midpoint); + double midpoint, + double gain_cap); void WriteToDriver(); |