summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-04 01:15:12 -0700
committerJacob Palecki <[email protected]>2020-09-04 01:15:12 -0700
commit87ee655d3c0ba3cdb0ca71a1b66aeb02c8c6aa70 (patch)
treea2ca5c42352737e3dab48ec854c1cd068a282e46
parentThe menus mostly work (diff)
parentMerge pull request #19 from JacobPalecki/gainOffset (diff)
downloadrawaccel-87ee655d3c0ba3cdb0ca71a1b66aeb02c8c6aa70.tar.xz
rawaccel-87ee655d3c0ba3cdb0ca71a1b66aeb02c8c6aa70.zip
Merge with master
-rw-r--r--common/accel-base.hpp9
-rw-r--r--common/accel-classic.hpp14
-rw-r--r--common/accel-linear.hpp14
-rw-r--r--common/accel-logarithmic.hpp3
-rw-r--r--common/accel-natural.hpp8
-rw-r--r--common/accel-naturalgain.hpp7
-rw-r--r--common/accel-noaccel.hpp1
-rw-r--r--common/accel-sigmoid.hpp1
-rw-r--r--common/accel-sigmoidgain.hpp1
-rw-r--r--common/rawaccel-error.hpp5
-rw-r--r--common/rawaccel-io.hpp5
-rw-r--r--driver/driver.cpp18
-rw-r--r--grapher/Form1.Designer.cs353
-rw-r--r--grapher/Form1.cs7
-rw-r--r--grapher/Models/AccelGUI.cs11
-rw-r--r--grapher/Models/AccelGUIFactory.cs30
-rw-r--r--grapher/Models/Options/AccelOptionSet.cs13
-rw-r--r--grapher/Models/Options/CapOptions.cs26
-rw-r--r--grapher/Models/Options/OffsetOptions.cs124
-rw-r--r--grapher/Models/Serialized/DriverSettings.cs30
-rw-r--r--grapher/Models/Serialized/SettingsManager.cs24
-rw-r--r--grapher/grapher.csproj1
-rw-r--r--wrapper/wrapper_io.cpp4
-rw-r--r--wrapper/wrapper_io.hpp2
24 files changed, 453 insertions, 258 deletions
diff --git a/common/accel-base.hpp b/common/accel-base.hpp
index 560c0b5..714162f 100644
--- a/common/accel-base.hpp
+++ b/common/accel-base.hpp
@@ -5,6 +5,7 @@ namespace rawaccel {
/// <summary> Struct to hold arguments for an acceleration function. </summary>
struct accel_args {
double offset = 0;
+ double legacy_offset = 0;
double accel = 0;
double limit = 2;
double exponent = 2;
@@ -19,6 +20,7 @@ namespace rawaccel {
template <typename Func>
struct accel_val_base {
+ bool legacy_offset = false;
double offset = 0;
double weight = 1;
Func fn;
@@ -31,14 +33,15 @@ namespace rawaccel {
struct additive_accel : accel_val_base<Func> {
additive_accel(const accel_args& args) : accel_val_base(args) {
- offset = args.offset;
+ legacy_offset = args.offset <= 0 && args.legacy_offset > 0;
+ offset = legacy_offset ? args.legacy_offset : args.offset;
weight = args.weight;
}
inline double operator()(double speed) const {
- return 1 + fn(maxsd(speed - offset, 0)) * weight;
+ double offset_speed = speed - offset;
+ return offset_speed > 0 ? ( legacy_offset ? 1 + fn.legacy_offset(offset_speed) * weight : 1 + fn(offset_speed) ) : 1;
}
-
};
template <typename Func>
diff --git a/common/accel-classic.hpp b/common/accel-classic.hpp
index 4cc52ca..1df888a 100644
--- a/common/accel-classic.hpp
+++ b/common/accel-classic.hpp
@@ -10,13 +10,23 @@ namespace rawaccel {
struct classic_impl {
double accel;
double power;
+ double power_inc;
+ double offset;
+ double multiplicative_const;
classic_impl(const accel_args& args) :
- accel(args.accel), power(args.exponent - 1)
- {}
+ accel(args.accel), power(args.exponent - 1), offset(args.offset) {
+ multiplicative_const = pow(accel, power);
+ power_inc = power + 1;
+ }
inline double operator()(double speed) const {
//f(x) = (mx)^(k-1)
+ double base_speed = speed + offset;
+ return multiplicative_const * pow(speed, power_inc) / base_speed;
+ }
+
+ inline double legacy_offset(double speed) const {
return pow(accel * speed, power);
}
};
diff --git a/common/accel-linear.hpp b/common/accel-linear.hpp
index a943594..2bd57b8 100644
--- a/common/accel-linear.hpp
+++ b/common/accel-linear.hpp
@@ -7,13 +7,23 @@ namespace rawaccel {
/// <summary> Struct to hold linear acceleration implementation. </summary>
struct linear_impl {
double accel;
+ double offset;
+ double subtractive_const;
+ double divisive_const;
- linear_impl(const accel_args& args) : accel(args.accel) {}
+ linear_impl(const accel_args& args) : accel(args.accel), offset(args.offset) {
+ subtractive_const = 2 * accel * offset;
+ divisive_const = accel * offset * offset;
+ }
inline double operator()(double speed) const {
- return accel * speed;
+ double base_speed = speed + offset;
+ return accel * base_speed - subtractive_const + divisive_const / base_speed;
}
+ inline double legacy_offset(double speed) const {
+ return accel * speed;
+ }
};
using accel_linear = additive_accel<linear_impl>;
diff --git a/common/accel-logarithmic.hpp b/common/accel-logarithmic.hpp
index c7991c7..1ab0e53 100644
--- a/common/accel-logarithmic.hpp
+++ b/common/accel-logarithmic.hpp
@@ -16,6 +16,9 @@ namespace rawaccel {
//f(x) = log(m*x+1)
return log(accel * speed + 1);
}
+
+ // incorrect but this style is slated for removal
+ inline double legacy_offset(double speed) const { return operator()(speed); }
};
using accel_logarithmic = additive_accel<logarithmic_impl>;
diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp
index c7d0dcd..03700c1 100644
--- a/common/accel-natural.hpp
+++ b/common/accel-natural.hpp
@@ -10,15 +10,21 @@ namespace rawaccel {
struct natural_impl {
double rate;
double limit;
+ double offset;
natural_impl(const accel_args& args) :
- rate(args.accel), limit(args.limit - 1)
+ rate(args.accel), limit(args.limit - 1), offset(args.offset)
{
rate /= limit;
}
inline double operator()(double speed) const {
// f(x) = k(1-e^(-mx))
+ double base_speed = speed + offset;
+ return limit * (1 - ((exp(-rate * speed) * speed + offset) / base_speed));
+ }
+
+ inline double legacy_offset(double speed) const {
return limit - (limit * exp(-rate * speed));
}
diff --git a/common/accel-naturalgain.hpp b/common/accel-naturalgain.hpp
index 646b2bb..cdfd1fa 100644
--- a/common/accel-naturalgain.hpp
+++ b/common/accel-naturalgain.hpp
@@ -13,10 +13,15 @@ namespace rawaccel {
inline double operator()(double speed) const {
// f(x) = k((e^(-mx)-1)/mx + 1)
+ double base_speed = speed + offset;
double scaled_speed = rate * speed;
- return limit * (((exp(-scaled_speed) - 1) / scaled_speed) + 1);
+ return limit * (((exp(-scaled_speed) - 1) / (base_speed * rate) ) + 1 - offset / base_speed);
}
+ inline double legacy_offset(double speed) const {
+ double scaled_speed = rate * speed;
+ return limit * (((exp(-scaled_speed) - 1) / scaled_speed) + 1);
+ }
};
using accel_naturalgain = additive_accel<naturalgain_impl>;
diff --git a/common/accel-noaccel.hpp b/common/accel-noaccel.hpp
index ae6f5f8..c803c2f 100644
--- a/common/accel-noaccel.hpp
+++ b/common/accel-noaccel.hpp
@@ -12,6 +12,7 @@ namespace rawaccel {
inline double operator()(double) const { return 1; }
+ inline double legacy_offset(double speed) const { return operator()(speed); }
};
}
diff --git a/common/accel-sigmoid.hpp b/common/accel-sigmoid.hpp
index c8112ee..239bd9d 100644
--- a/common/accel-sigmoid.hpp
+++ b/common/accel-sigmoid.hpp
@@ -21,6 +21,7 @@ namespace rawaccel {
return limit / (exp(-rate * (speed - midpoint)) + 1);
}
+ inline double legacy_offset(double speed) const { return operator()(speed); }
};
using accel_sigmoid = additive_accel<sigmoid_impl>;
diff --git a/common/accel-sigmoidgain.hpp b/common/accel-sigmoidgain.hpp
index 99bb146..bed2f16 100644
--- a/common/accel-sigmoidgain.hpp
+++ b/common/accel-sigmoidgain.hpp
@@ -26,6 +26,7 @@ namespace rawaccel {
return limit * ((log(additive_constant+exp(scaled_speed)) - integration_constant)/scaled_speed);
}
+ inline double legacy_offset(double speed) const { return operator()(speed); }
};
using accel_sigmoidgain = additive_accel<sigmoidgain_impl>;
diff --git a/common/rawaccel-error.hpp b/common/rawaccel-error.hpp
index f5498f9..ecee526 100644
--- a/common/rawaccel-error.hpp
+++ b/common/rawaccel-error.hpp
@@ -21,9 +21,4 @@ namespace rawaccel {
install_error() : io_error("rawaccel is not installed") {}
};
- class cooldown_error : public io_error {
- public:
- cooldown_error() : io_error("write is on cooldown") {}
- };
-
}
diff --git a/common/rawaccel-io.hpp b/common/rawaccel-io.hpp
index 74e2d1e..e8641d1 100644
--- a/common/rawaccel-io.hpp
+++ b/common/rawaccel-io.hpp
@@ -74,10 +74,7 @@ namespace rawaccel {
CloseHandle(ra_handle);
if (!success) {
- if (auto err = GetLastError(); err != ERROR_BUSY) {
- throw std::system_error(err, std::system_category(), "DeviceIoControl failed");
- }
- throw cooldown_error();
+ throw std::system_error(GetLastError(), std::system_category(), "DeviceIoControl failed");
}
}
diff --git a/driver/driver.cpp b/driver/driver.cpp
index 57b3c8a..fb47477 100644
--- a/driver/driver.cpp
+++ b/driver/driver.cpp
@@ -14,7 +14,6 @@ namespace ra = rawaccel;
using milliseconds = double;
struct {
- counter_t last_write = 0;
ra::settings args;
milliseconds tick_interval = 0; // set in DriverEntry
ra::mouse_modifier modifier;
@@ -150,18 +149,10 @@ Return Value:
DebugPrint(("Ioctl received into filter control object.\n"));
if (InputBufferLength == sizeof(ra::settings)) {
- constexpr milliseconds WRITE_COOLDOWN_TIME = 1000;
-
- counter_t now = KeQueryPerformanceCounter(NULL).QuadPart;
- counter_t ticks = now - global.last_write;
- milliseconds time = ticks * global.tick_interval;
-
- if (global.last_write > 0 && time < WRITE_COOLDOWN_TIME) {
- DebugPrint(("RA write on cooldown\n"));
- // status maps to win32 error code 170: ERROR_BUSY
- WdfRequestComplete(Request, STATUS_ENCOUNTERED_WRITE_IN_PROGRESS);
- return;
- }
+ // 1 second wait
+ LARGE_INTEGER interval;
+ interval.QuadPart = -10000000;
+ KeDelayExecutionThread(KernelMode, FALSE, &interval);
status = WdfRequestRetrieveInputBuffer(
Request,
@@ -179,7 +170,6 @@ Return Value:
global.args = *reinterpret_cast<ra::settings*>(buffer);
global.modifier = { global.args };
- global.last_write = now;
WdfRequestComplete(Request, STATUS_SUCCESS);
}
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index af60be1..b78b450 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -30,30 +30,30 @@ namespace grapher
/// </summary>
private void InitializeComponent()
{
- System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea13 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
- System.Windows.Forms.DataVisualization.Charting.Legend legend13 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series25 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series26 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea14 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
- System.Windows.Forms.DataVisualization.Charting.Legend legend14 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series27 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series28 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea15 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
- System.Windows.Forms.DataVisualization.Charting.Legend legend15 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series29 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series30 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea16 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
- System.Windows.Forms.DataVisualization.Charting.Legend legend16 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series31 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series32 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea17 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
- System.Windows.Forms.DataVisualization.Charting.Legend legend17 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series33 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series34 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea18 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
- System.Windows.Forms.DataVisualization.Charting.Legend legend18 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series35 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series36 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend3 = 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.Series series6 = 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 series7 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series8 = 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 series9 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series10 = 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 series11 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.accelTypeDropX = new System.Windows.Forms.ComboBox();
this.sensitivityBoxX = new System.Windows.Forms.TextBox();
@@ -91,13 +91,16 @@ namespace grapher
this.ScaleMenuItem = 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();
+ this.gainCapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.legacyCapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.offsetStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.gainOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.legacyOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.startupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.wholeVectorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.byVectorComponentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.startupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AccelerationChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.VelocityChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.GainChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
@@ -145,25 +148,25 @@ namespace grapher
//
// AccelerationChart
//
- chartArea13.AxisX.Title = "Speed (counts/ms)";
- chartArea13.AxisY.Title = "Sensitivity (magnitude ratio)";
- chartArea13.Name = "ChartArea1";
- this.AccelerationChart.ChartAreas.Add(chartArea13);
- legend13.Name = "Legend1";
- this.AccelerationChart.Legends.Add(legend13);
+ chartArea1.AxisX.Title = "Speed (counts/ms)";
+ chartArea1.AxisY.Title = "Sensitivity (magnitude ratio)";
+ chartArea1.Name = "ChartArea1";
+ this.AccelerationChart.ChartAreas.Add(chartArea1);
+ legend1.Name = "Legend1";
+ this.AccelerationChart.Legends.Add(legend1);
this.AccelerationChart.Location = new System.Drawing.Point(432, 0);
this.AccelerationChart.Name = "AccelerationChart";
- series25.ChartArea = "ChartArea1";
- series25.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series25.Legend = "Legend1";
- series25.Name = "Accelerated Sensitivity";
- series26.ChartArea = "ChartArea1";
- series26.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series26.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series26.Legend = "Legend1";
- series26.Name = "LastAccelVal";
- this.AccelerationChart.Series.Add(series25);
- this.AccelerationChart.Series.Add(series26);
+ series1.ChartArea = "ChartArea1";
+ series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series1.Legend = "Legend1";
+ series1.Name = "Accelerated Sensitivity";
+ series2.ChartArea = "ChartArea1";
+ series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series2.Legend = "Legend1";
+ series2.Name = "LastAccelVal";
+ this.AccelerationChart.Series.Add(series1);
+ this.AccelerationChart.Series.Add(series2);
this.AccelerationChart.Size = new System.Drawing.Size(723, 328);
this.AccelerationChart.TabIndex = 0;
this.AccelerationChart.Text = "Sensitivity";
@@ -364,50 +367,50 @@ namespace grapher
//
// VelocityChart
//
- chartArea14.AxisX.Title = "Speed (count/ms)";
- chartArea14.AxisY.Title = "Output Speed (counts/ms)";
- chartArea14.Name = "ChartArea1";
- this.VelocityChart.ChartAreas.Add(chartArea14);
- legend14.Name = "Legend1";
- this.VelocityChart.Legends.Add(legend14);
+ chartArea2.AxisX.Title = "Speed (count/ms)";
+ chartArea2.AxisY.Title = "Output Speed (counts/ms)";
+ chartArea2.Name = "ChartArea1";
+ this.VelocityChart.ChartAreas.Add(chartArea2);
+ legend2.Name = "Legend1";
+ this.VelocityChart.Legends.Add(legend2);
this.VelocityChart.Location = new System.Drawing.Point(432, 334);
this.VelocityChart.Name = "VelocityChart";
- series27.ChartArea = "ChartArea1";
- series27.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series27.Legend = "Legend1";
- series27.Name = "Mouse Velocity";
- series28.ChartArea = "ChartArea1";
- series28.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series28.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series28.Legend = "Legend1";
- series28.Name = "LastVelocityVal";
- this.VelocityChart.Series.Add(series27);
- this.VelocityChart.Series.Add(series28);
+ series3.ChartArea = "ChartArea1";
+ series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series3.Legend = "Legend1";
+ series3.Name = "Mouse Velocity";
+ series4.ChartArea = "ChartArea1";
+ series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series4.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series4.Legend = "Legend1";
+ series4.Name = "LastVelocityVal";
+ this.VelocityChart.Series.Add(series3);
+ this.VelocityChart.Series.Add(series4);
this.VelocityChart.Size = new System.Drawing.Size(723, 307);
this.VelocityChart.TabIndex = 28;
this.VelocityChart.Text = "chart1";
//
// GainChart
//
- chartArea15.AxisX.Title = "Speed (counts/ms)";
- chartArea15.AxisY.Title = "Slope of Velocity Chart";
- chartArea15.Name = "ChartArea1";
- this.GainChart.ChartAreas.Add(chartArea15);
- legend15.Name = "Legend1";
- this.GainChart.Legends.Add(legend15);
+ chartArea3.AxisX.Title = "Speed (counts/ms)";
+ chartArea3.AxisY.Title = "Slope of Velocity Chart";
+ chartArea3.Name = "ChartArea1";
+ this.GainChart.ChartAreas.Add(chartArea3);
+ legend3.Name = "Legend1";
+ this.GainChart.Legends.Add(legend3);
this.GainChart.Location = new System.Drawing.Point(432, 647);
this.GainChart.Name = "GainChart";
- series29.ChartArea = "ChartArea1";
- series29.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series29.Legend = "Legend1";
- series29.Name = "Velocity Gain";
- series30.ChartArea = "ChartArea1";
- series30.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series30.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series30.Legend = "Legend1";
- series30.Name = "LastGainVal";
- this.GainChart.Series.Add(series29);
- this.GainChart.Series.Add(series30);
+ series5.ChartArea = "ChartArea1";
+ series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series5.Legend = "Legend1";
+ series5.Name = "Velocity Gain";
+ series6.ChartArea = "ChartArea1";
+ series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series6.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series6.Legend = "Legend1";
+ series6.Name = "LastGainVal";
+ this.GainChart.Series.Add(series5);
+ this.GainChart.Series.Add(series6);
this.GainChart.Size = new System.Drawing.Size(723, 309);
this.GainChart.TabIndex = 29;
this.GainChart.Text = "chart1";
@@ -490,6 +493,7 @@ namespace grapher
//
this.advancedToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.capStyleToolStripMenuItem,
+ this.offsetStyleToolStripMenuItem,
this.toolStripMenuItem1});
this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem";
this.advancedToolStripMenuItem.Size = new System.Drawing.Size(72, 20);
@@ -498,25 +502,63 @@ namespace grapher
// capStyleToolStripMenuItem
//
this.capStyleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.sensitivityToolStripMenuItem,
- this.velocityGainToolStripMenuItem});
+ this.gainCapToolStripMenuItem,
+ this.legacyCapToolStripMenuItem});
this.capStyleToolStripMenuItem.Name = "capStyleToolStripMenuItem";
- this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
+ this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.capStyleToolStripMenuItem.Text = "Cap Style";
//
- // sensitivityToolStripMenuItem
+ // gainCapToolStripMenuItem
+ //
+ this.gainCapToolStripMenuItem.Checked = true;
+ this.gainCapToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.gainCapToolStripMenuItem.Name = "gainCapToolStripMenuItem";
+ this.gainCapToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
+ this.gainCapToolStripMenuItem.Text = "Gain (Default)";
+ //
+ // legacyCapToolStripMenuItem
+ //
+ this.legacyCapToolStripMenuItem.Name = "legacyCapToolStripMenuItem";
+ this.legacyCapToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
+ this.legacyCapToolStripMenuItem.Text = "Legacy";
+ //
+ // offsetStyleToolStripMenuItem
+ //
+ this.offsetStyleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.gainOffsetToolStripMenuItem,
+ this.legacyOffsetToolStripMenuItem});
+ this.offsetStyleToolStripMenuItem.Name = "offsetStyleToolStripMenuItem";
+ this.offsetStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.offsetStyleToolStripMenuItem.Text = "Offset Style";
+ //
+ // gainOffsetToolStripMenuItem
+ //
+ this.gainOffsetToolStripMenuItem.Name = "gainOffsetToolStripMenuItem";
+ this.gainOffsetToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
+ this.gainOffsetToolStripMenuItem.Text = "Gain (Default)";
//
- this.sensitivityToolStripMenuItem.Checked = true;
- this.sensitivityToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
- this.sensitivityToolStripMenuItem.Name = "sensitivityToolStripMenuItem";
- this.sensitivityToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
- this.sensitivityToolStripMenuItem.Text = "Sensitivity";
+ // legacyOffsetToolStripMenuItem
//
- // velocityGainToolStripMenuItem
+ this.legacyOffsetToolStripMenuItem.Name = "legacyOffsetToolStripMenuItem";
+ this.legacyOffsetToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
+ this.legacyOffsetToolStripMenuItem.Text = "Legacy";
//
- this.velocityGainToolStripMenuItem.Name = "velocityGainToolStripMenuItem";
- this.velocityGainToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
- this.velocityGainToolStripMenuItem.Text = "Velocity Gain";
+ // startupToolStripMenuItem
+ //
+ this.startupToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.AutoWriteMenuItem});
+ this.startupToolStripMenuItem.Name = "startupToolStripMenuItem";
+ this.startupToolStripMenuItem.Size = new System.Drawing.Size(57, 20);
+ this.startupToolStripMenuItem.Text = "Startup";
+ //
+ // AutoWriteMenuItem
+ //
+ this.AutoWriteMenuItem.Checked = true;
+ this.AutoWriteMenuItem.CheckOnClick = true;
+ this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.AutoWriteMenuItem.Name = "AutoWriteMenuItem";
+ this.AutoWriteMenuItem.Size = new System.Drawing.Size(229, 22);
+ this.AutoWriteMenuItem.Text = "Apply Settings File on Startup";
//
// toolStripMenuItem1
//
@@ -542,94 +584,77 @@ namespace grapher
this.byVectorComponentToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.byVectorComponentToolStripMenuItem.Text = "By Component";
//
- // startupToolStripMenuItem
- //
- this.startupToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.AutoWriteMenuItem});
- this.startupToolStripMenuItem.Name = "startupToolStripMenuItem";
- this.startupToolStripMenuItem.Size = new System.Drawing.Size(57, 20);
- this.startupToolStripMenuItem.Text = "Startup";
- //
- // AutoWriteMenuItem
- //
- this.AutoWriteMenuItem.Checked = true;
- this.AutoWriteMenuItem.CheckOnClick = true;
- this.AutoWriteMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
- this.AutoWriteMenuItem.Name = "AutoWriteMenuItem";
- this.AutoWriteMenuItem.Size = new System.Drawing.Size(229, 22);
- this.AutoWriteMenuItem.Text = "Apply Settings File on Startup";
- //
// AccelerationChartY
//
- chartArea16.AxisX.Title = "Speed (counts/ms)";
- chartArea16.AxisY.Title = "Sensitivity (magnitude ratio)";
- chartArea16.Name = "ChartArea1";
- this.AccelerationChartY.ChartAreas.Add(chartArea16);
- legend16.Name = "Legend1";
- this.AccelerationChartY.Legends.Add(legend16);
+ chartArea4.AxisX.Title = "Speed (counts/ms)";
+ chartArea4.AxisY.Title = "Sensitivity (magnitude ratio)";
+ chartArea4.Name = "ChartArea1";
+ this.AccelerationChartY.ChartAreas.Add(chartArea4);
+ legend4.Name = "Legend1";
+ this.AccelerationChartY.Legends.Add(legend4);
this.AccelerationChartY.Location = new System.Drawing.Point(1161, 0);
this.AccelerationChartY.Name = "AccelerationChartY";
- series31.ChartArea = "ChartArea1";
- series31.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series31.Legend = "Legend1";
- series31.Name = "Accelerated Sensitivity";
- series32.ChartArea = "ChartArea1";
- series32.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series32.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series32.Legend = "Legend1";
- series32.Name = "LastAccelVal";
- this.AccelerationChartY.Series.Add(series31);
- this.AccelerationChartY.Series.Add(series32);
+ series7.ChartArea = "ChartArea1";
+ series7.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series7.Legend = "Legend1";
+ series7.Name = "Accelerated Sensitivity";
+ series8.ChartArea = "ChartArea1";
+ series8.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series8.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series8.Legend = "Legend1";
+ series8.Name = "LastAccelVal";
+ this.AccelerationChartY.Series.Add(series7);
+ this.AccelerationChartY.Series.Add(series8);
this.AccelerationChartY.Size = new System.Drawing.Size(723, 328);
this.AccelerationChartY.TabIndex = 31;
this.AccelerationChartY.Text = "chart1";
//
// VelocityChartY
//
- chartArea17.AxisX.Title = "Speed (count/ms)";
- chartArea17.AxisY.Title = "Output Speed (counts/ms)";
- chartArea17.Name = "ChartArea1";
- this.VelocityChartY.ChartAreas.Add(chartArea17);
- legend17.Name = "Legend1";
- this.VelocityChartY.Legends.Add(legend17);
+ chartArea5.AxisX.Title = "Speed (count/ms)";
+ chartArea5.AxisY.Title = "Output Speed (counts/ms)";
+ chartArea5.Name = "ChartArea1";
+ this.VelocityChartY.ChartAreas.Add(chartArea5);
+ legend5.Name = "Legend1";
+ this.VelocityChartY.Legends.Add(legend5);
this.VelocityChartY.Location = new System.Drawing.Point(1161, 334);
this.VelocityChartY.Name = "VelocityChartY";
- series33.ChartArea = "ChartArea1";
- series33.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series33.Legend = "Legend1";
- series33.Name = "Mouse Velocity";
- series34.ChartArea = "ChartArea1";
- series34.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series34.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series34.Legend = "Legend1";
- series34.Name = "LastVelocityVal";
- this.VelocityChartY.Series.Add(series33);
- this.VelocityChartY.Series.Add(series34);
+ series9.ChartArea = "ChartArea1";
+ series9.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series9.Legend = "Legend1";
+ series9.Name = "Mouse Velocity";
+ series10.ChartArea = "ChartArea1";
+ series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series10.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series10.Legend = "Legend1";
+ series10.Name = "LastVelocityVal";
+ this.VelocityChartY.Series.Add(series9);
+ this.VelocityChartY.Series.Add(series10);
this.VelocityChartY.Size = new System.Drawing.Size(723, 307);
this.VelocityChartY.TabIndex = 32;
this.VelocityChartY.Text = "chart1";
//
// GainChartY
//
- chartArea18.AxisX.Title = "Speed (counts/ms)";
- chartArea18.AxisY.Title = "Slope of Velocity Chart";
- chartArea18.Name = "ChartArea1";
- this.GainChartY.ChartAreas.Add(chartArea18);
- legend18.Name = "Legend1";
- this.GainChartY.Legends.Add(legend18);
+ chartArea6.AxisX.Title = "Speed (counts/ms)";
+ chartArea6.AxisY.Title = "Slope of Velocity Chart";
+ chartArea6.Name = "ChartArea1";
+ this.GainChartY.ChartAreas.Add(chartArea6);
+ legend6.Name = "Legend1";
+ this.GainChartY.Legends.Add(legend6);
this.GainChartY.Location = new System.Drawing.Point(1161, 647);
this.GainChartY.Name = "GainChartY";
- series35.ChartArea = "ChartArea1";
- series35.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series35.Legend = "Legend1";
- series35.Name = "Velocity Gain";
- series36.ChartArea = "ChartArea1";
- series36.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series36.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series36.Legend = "Legend1";
- series36.Name = "LastGainVal";
- this.GainChartY.Series.Add(series35);
- this.GainChartY.Series.Add(series36);
+ series11.ChartArea = "ChartArea1";
+ series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series11.Legend = "Legend1";
+ series11.Name = "Velocity Gain";
+ series12.ChartArea = "ChartArea1";
+ series12.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series12.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series12.Legend = "Legend1";
+ series12.Name = "LastGainVal";
+ this.GainChartY.Series.Add(series11);
+ this.GainChartY.Series.Add(series12);
this.GainChartY.Size = new System.Drawing.Size(723, 309);
this.GainChartY.TabIndex = 33;
this.GainChartY.Text = "chart1";
@@ -1043,8 +1068,8 @@ namespace grapher
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;
+ private System.Windows.Forms.ToolStripMenuItem gainCapToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem legacyCapToolStripMenuItem;
private System.Windows.Forms.DataVisualization.Charting.Chart AccelerationChartY;
private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChartY;
private System.Windows.Forms.DataVisualization.Charting.Chart GainChartY;
@@ -1092,6 +1117,10 @@ namespace grapher
private System.Windows.Forms.Label OptionSetXTitle;
private System.Windows.Forms.Label OptionSetYTitle;
private System.Windows.Forms.Label AccelTypeActiveLabelY;
+ private System.Windows.Forms.ToolStripMenuItem offsetStyleToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem gainOffsetToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem legacyOffsetToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
}
}
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index 68a8a31..a4c32cd 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -57,8 +57,10 @@ namespace grapher
showVelocityGainToolStripMenuItem,
wholeVectorToolStripMenuItem,
byVectorComponentToolStripMenuItem,
- sensitivityToolStripMenuItem,
- velocityGainToolStripMenuItem,
+ gainCapToolStripMenuItem,
+ legacyCapToolStripMenuItem,
+ gainOffsetToolStripMenuItem,
+ legacyOffsetToolStripMenuItem,
AutoWriteMenuItem,
scaleByDPIToolStripMenuItem,
DPITextBox,
@@ -115,7 +117,6 @@ namespace grapher
OptionSetXTitle,
OptionSetYTitle,
MouseLabel);
-
}
#endregion Constructor
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 3a15d48..e9e925f 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -78,7 +78,7 @@ namespace grapher
public void UpdateActiveSettingsFromFields()
{
- Settings.UpdateActiveSettings(new DriverSettings
+ var settings = new DriverSettings
{
rotation = Rotation.Field.Data,
sensitivity = new Vec2<double>
@@ -90,6 +90,14 @@ namespace grapher
modes = ApplyOptions.GetModes(),
args = ApplyOptions.GetArgs(),
minimumTime = .4
+ };
+
+ Settings.UpdateActiveSettings(settings, () =>
+ {
+ AccelForm.Invoke((MethodInvoker)delegate
+ {
+ UpdateGraph();
+ });
});
RefreshOnRead();
}
@@ -117,7 +125,6 @@ namespace grapher
Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y);
Rotation.SetActiveValue(settings.rotation);
ApplyOptions.SetActiveValues(settings);
-
}
private void OnScaleMenuItemClick(object sender, EventArgs e)
diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs
index 8ed4d72..230b64d 100644
--- a/grapher/Models/AccelGUIFactory.cs
+++ b/grapher/Models/AccelGUIFactory.cs
@@ -30,8 +30,10 @@ namespace grapher.Models
ToolStripMenuItem showVelocityGainToolStripMenuItem,
ToolStripMenuItem wholeVectorToolStripMenuItem,
ToolStripMenuItem byVectorComponentToolStripMenuItem,
- ToolStripMenuItem sensitivityToolStripMenuItem,
- ToolStripMenuItem velocityGainToolStripMenuItem,
+ ToolStripMenuItem velocityGainCapToolStripMenuItem,
+ ToolStripMenuItem legacyCapToolStripMenuItem,
+ ToolStripMenuItem gainOffsetToolStripMenuItem,
+ ToolStripMenuItem legacyOffsetToolStripMenuItem,
ToolStripMenuItem autoWriteMenuItem,
ToolStripMenuItem scaleMenuItem,
ToolStripTextBox dpiTextBox,
@@ -173,6 +175,16 @@ namespace grapher.Models
new ActiveValueLabel(offsetActiveLabelY, activeValueTitle),
"Offset");
+ var offsetOptionsX = new OffsetOptions(
+ gainOffsetToolStripMenuItem,
+ legacyOffsetToolStripMenuItem,
+ offsetX);
+
+ var offsetOptionsY = new OffsetOptions(
+ gainOffsetToolStripMenuItem,
+ legacyOffsetToolStripMenuItem,
+ offsetY);
+
// The name and layout of these options is handled by AccelerationOptions object.
var accelerationX = new Option(
new Field(accelerationBoxX, form, 0),
@@ -239,13 +251,13 @@ namespace grapher.Models
new ActiveValueLabel(accelTypeActiveLabelY, activeValueTitle));
var capOptionsX = new CapOptions(
- sensitivityToolStripMenuItem,
- velocityGainToolStripMenuItem,
+ velocityGainCapToolStripMenuItem,
+ legacyCapToolStripMenuItem,
capX);
var capOptionsY = new CapOptions(
- sensitivityToolStripMenuItem,
- velocityGainToolStripMenuItem,
+ velocityGainCapToolStripMenuItem,
+ legacyCapToolStripMenuItem,
capY);
var optionsSetX = new AccelOptionSet(
@@ -255,9 +267,9 @@ namespace grapher.Models
accelerationX,
capOptionsX,
weightX,
- offsetX,
+ offsetOptionsX,
limitOrExponentX,
- midpointX); ;
+ midpointX);
var optionsSetY = new AccelOptionSet(
optionSetYTitle,
@@ -266,7 +278,7 @@ namespace grapher.Models
accelerationY,
capOptionsY,
weightY,
- offsetY,
+ offsetOptionsY,
limitOrExponentY,
midpointY);
diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs
index b1f85a9..838917c 100644
--- a/grapher/Models/Options/AccelOptionSet.cs
+++ b/grapher/Models/Options/AccelOptionSet.cs
@@ -17,7 +17,7 @@ namespace grapher.Models.Options
Option acceleration,
CapOptions cap,
Option weight,
- Option offset,
+ OffsetOptions offset,
Option limitOrExp,
Option midpoint)
{
@@ -50,7 +50,7 @@ namespace grapher.Models.Options
public Option Weight { get; }
- public Option Offset { get; }
+ public OffsetOptions Offset { get; }
public Option LimitOrExponent { get; }
@@ -126,7 +126,8 @@ namespace grapher.Models.Options
args.limit = LimitOrExponent.Field.Data;
args.exponent = LimitOrExponent.Field.Data;
args.powerExponent = LimitOrExponent.Field.Data;
- args.offset = Offset.Field.Data;
+ args.offset = Offset.Offset;
+ args.legacy_offset = Offset.LegacyOffset;
args.midpoint = Midpoint.Field.Data;
args.weight = Weight.Field.Data;
}
@@ -143,7 +144,7 @@ namespace grapher.Models.Options
AccelTypeOptions.SetActiveValue(mode);
Weight.SetActiveValue(args.weight);
Cap.SetActiveValues(args.gainCap, args.scaleCap, args.gainCap > 0);
- Offset.SetActiveValue(args.offset);
+ Offset.SetActiveValue(args.offset, args.legacy_offset);
Acceleration.SetActiveValue(args.accel);
LimitOrExponent.SetActiveValue(args.exponent);
Midpoint.SetActiveValue(args.midpoint);
@@ -155,8 +156,8 @@ namespace grapher.Models.Options
Acceleration.Top = AccelTypeOptions.Top + AccelTypeOptions.Height + Constants.OptionVerticalSeperation;
Cap.SnapTo(Acceleration);
Weight.SnapTo(Cap);
- Offset.SnapTo(Weight);
- LimitOrExponent.SnapTo(Offset);
+ Offset.OffsetOption.SnapTo(Weight);
+ LimitOrExponent.SnapTo(Offset.OffsetOption);
Midpoint.SnapTo(LimitOrExponent);
}
}
diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs
index 713842c..6dc1116 100644
--- a/grapher/Models/Options/CapOptions.cs
+++ b/grapher/Models/Options/CapOptions.cs
@@ -18,29 +18,29 @@ namespace grapher
#region Constructors
public CapOptions(
- ToolStripMenuItem sensitivityCapCheck,
ToolStripMenuItem velocityGainCapCheck,
+ ToolStripMenuItem legacyCapCheck,
Option capOption)
{
- SensitivityCapCheck = sensitivityCapCheck;
VelocityGainCapCheck = velocityGainCapCheck;
+ LegacyCapCheck = legacyCapCheck;
CapOption = capOption;
- SensitivityCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick);
+ LegacyCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick);
VelocityGainCapCheck.Click += new System.EventHandler(OnVelocityGainCapCheckClick);
- SensitivityCapCheck.CheckedChanged += new System.EventHandler(OnSensitivityCapCheckedChange);
+ LegacyCapCheck.CheckedChanged += new System.EventHandler(OnSensitivityCapCheckedChange);
VelocityGainCapCheck.CheckedChanged += new System.EventHandler(OnVelocityGainCapCheckedChange);
- EnableSensitivityCap();
+ EnableVelocityGainCap();
}
#endregion Constructors
#region Properties
- public ToolStripMenuItem SensitivityCapCheck { get; }
+ public ToolStripMenuItem LegacyCapCheck { get; }
public ToolStripMenuItem VelocityGainCapCheck { get; }
@@ -124,7 +124,7 @@ namespace grapher
CapOption.ActiveValueLabel.FormatString = Constants.GainCapFormatString;
CapOption.ActiveValueLabel.Prefix = "Gain";
CapOption.SetActiveValue(gainCap);
- SensitivityCapCheck.Checked = true;
+ LegacyCapCheck.Checked = true;
VelocityGainCapCheck.Checked = false;
}
else
@@ -132,17 +132,17 @@ namespace grapher
CapOption.ActiveValueLabel.FormatString = Constants.DefaultActiveValueFormatString;
CapOption.ActiveValueLabel.Prefix = string.Empty;
CapOption.SetActiveValue(sensCap);
- SensitivityCapCheck.Checked = false;
+ LegacyCapCheck.Checked = false;
VelocityGainCapCheck.Checked = true;
}
}
void OnSensitivityCapCheckClick(object sender, EventArgs e)
{
- if (!SensitivityCapCheck.Checked)
+ if (!LegacyCapCheck.Checked)
{
VelocityGainCapCheck.Checked = false;
- SensitivityCapCheck.Checked = true;
+ LegacyCapCheck.Checked = true;
}
}
@@ -151,13 +151,13 @@ namespace grapher
if (!VelocityGainCapCheck.Checked)
{
VelocityGainCapCheck.Checked = true;
- SensitivityCapCheck.Checked = false;
+ LegacyCapCheck.Checked = false;
}
}
void OnSensitivityCapCheckedChange(object sender, EventArgs e)
{
- if (SensitivityCapCheck.Checked)
+ if (LegacyCapCheck.Checked == true)
{
EnableSensitivityCap();
}
@@ -165,7 +165,7 @@ namespace grapher
void OnVelocityGainCapCheckedChange(object sender, EventArgs e)
{
- if (SensitivityCapCheck.Checked)
+ if (LegacyCapCheck.Checked == true)
{
EnableVelocityGainCap();
}
diff --git a/grapher/Models/Options/OffsetOptions.cs b/grapher/Models/Options/OffsetOptions.cs
new file mode 100644
index 0000000..0b01ab9
--- /dev/null
+++ b/grapher/Models/Options/OffsetOptions.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options
+{
+ public class OffsetOptions
+ {
+ public OffsetOptions(
+ ToolStripMenuItem velocityGainOffsetCheck,
+ ToolStripMenuItem legacyOffsetCheck,
+ Option offsetOption)
+ {
+ VelocityGainOffsetCheck = velocityGainOffsetCheck;
+ LegacyOffsetCheck = legacyOffsetCheck;
+ OffsetOption = offsetOption;
+
+ VelocityGainOffsetCheck.Click += new System.EventHandler(OnVelocityGainOffsetClick);
+ LegacyOffsetCheck.Click += new System.EventHandler(OnLegacyOffsetClick);
+
+ VelocityGainOffsetCheck.CheckedChanged += new System.EventHandler(OnVelocityGainOffsetCheckedChange);
+ LegacyOffsetCheck.CheckedChanged += new System.EventHandler(OnLegacyOffsetCheckedChange);
+
+ VelocityGainOffsetCheck.Checked = true;
+ }
+
+ public ToolStripMenuItem VelocityGainOffsetCheck { get; }
+
+ public ToolStripMenuItem LegacyOffsetCheck { get; }
+
+ public Option OffsetOption { get; }
+
+ public bool IsLegacy { get; private set; }
+
+ public double LegacyOffset
+ {
+ get
+ {
+ if (IsLegacy)
+ {
+ return OffsetOption.Field.Data;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+
+ public double Offset
+ {
+ get
+ {
+ if (IsLegacy)
+ {
+ return 0;
+ }
+ else
+ {
+ return OffsetOption.Field.Data;
+ }
+ }
+ }
+
+ public void SetActiveValue(double offset, double legacyOffset)
+ {
+ if (offset > 0)
+ {
+ OffsetOption.SetActiveValue(offset);
+ }
+ else
+ {
+ OffsetOption.SetActiveValue(legacyOffset);
+ }
+ }
+
+ public void OnVelocityGainOffsetClick(object sender, EventArgs e)
+ {
+ if (!VelocityGainOffsetCheck.Checked)
+ {
+ VelocityGainOffsetCheck.Checked = true;
+ LegacyOffsetCheck.Checked = false;
+ }
+ }
+
+ public void OnLegacyOffsetClick(object sender, EventArgs e)
+ {
+ if (!LegacyOffsetCheck.Checked)
+ {
+ LegacyOffsetCheck.Checked = true;
+ VelocityGainOffsetCheck.Checked = false;
+ }
+ }
+
+ public void OnVelocityGainOffsetCheckedChange(object sender, EventArgs e)
+ {
+ if (VelocityGainOffsetCheck.Checked)
+ {
+ EnableVelocityGainOffset();
+ }
+ }
+
+ public void OnLegacyOffsetCheckedChange(object sender, EventArgs e)
+ {
+ if (LegacyOffsetCheck.Checked)
+ {
+ EnableLegacyOffset();
+ }
+ }
+
+ public void EnableVelocityGainOffset()
+ {
+ IsLegacy = false;
+ }
+
+ public void EnableLegacyOffset()
+ {
+ IsLegacy = true;
+ }
+ }
+}
diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs
index e0b5d4a..ecd4d51 100644
--- a/grapher/Models/Serialized/DriverSettings.cs
+++ b/grapher/Models/Serialized/DriverSettings.cs
@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
+using System.Threading;
namespace grapher.Models.Serialized
{
@@ -18,6 +19,7 @@ namespace grapher.Models.Serialized
public struct AccelArgs
{
public double offset;
+ public double legacy_offset;
public double accel;
public double limit;
public double exponent;
@@ -47,6 +49,7 @@ namespace grapher.Models.Serialized
private static readonly IntPtr UnmanagedSettingsHandle =
Marshal.AllocHGlobal(Marshal.SizeOf<DriverSettings>());
+ private static object UnmanagedSettingsLock = new object();
public double rotation;
public bool combineMagnitudes;
@@ -65,21 +68,32 @@ namespace grapher.Models.Serialized
return Marshal.PtrToStructure<DriverSettings>(UnmanagedSettingsHandle);
}
- public static void SetActive(DriverSettings settings)
+ public static void SetActive(DriverSettings settings, Action<IntPtr> unmanagedActionBefore = null)
{
- Marshal.StructureToPtr(settings, UnmanagedSettingsHandle, false);
- DriverInterop.SetActiveSettings(UnmanagedSettingsHandle);
+ new Thread(() =>
+ {
+ lock (UnmanagedSettingsLock)
+ {
+ Marshal.StructureToPtr(settings, UnmanagedSettingsHandle, false);
+ unmanagedActionBefore?.Invoke(UnmanagedSettingsHandle);
+ DriverInterop.SetActiveSettings(UnmanagedSettingsHandle);
+ }
+ }).Start();
+
}
- public void SendToDriver()
+ public void SendToDriver(Action<IntPtr> unmanagedActionBefore = null)
{
- SetActive(this);
+ SetActive(this, unmanagedActionBefore);
}
- public void SendToDriverAndUpdate(ManagedAccel accel)
+ public void SendToDriverAndUpdate(ManagedAccel accel, Action betweenAccelAndWrite = null)
{
- SendToDriver();
- accel.UpdateFromSettings(UnmanagedSettingsHandle);
+ SendToDriver(settingsHandle =>
+ {
+ accel.UpdateFromSettings(settingsHandle);
+ betweenAccelAndWrite?.Invoke();
+ });
}
public bool verify()
diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs
index 7f018cf..d7cf590 100644
--- a/grapher/Models/Serialized/SettingsManager.cs
+++ b/grapher/Models/Serialized/SettingsManager.cs
@@ -38,12 +38,10 @@ namespace grapher.Models.Serialized
#region Methods
- public void UpdateActiveSettings(DriverSettings settings)
+ public void UpdateActiveSettings(DriverSettings settings, Action afterAccelSettingsUpdate = null)
{
- try
+ settings.SendToDriverAndUpdate(ActiveAccel, () =>
{
- settings.SendToDriverAndUpdate(ActiveAccel);
-
RawAccelSettings.AccelerationSettings = settings;
RawAccelSettings.GUISettings = new GUISettings
{
@@ -53,23 +51,15 @@ namespace grapher.Models.Serialized
};
RawAccelSettings.Save();
- }
- catch (DriverWriteCDException)
- {
- Console.WriteLine("write on cooldown");
- }
+
+ afterAccelSettingsUpdate?.Invoke();
+ });
}
public void UpdateActiveAccelFromFileSettings(DriverSettings settings)
{
- try
- {
- settings.SendToDriverAndUpdate(ActiveAccel);
- }
- catch (DriverWriteCDException)
- {
- Console.WriteLine("write on cd during file init");
- }
+ settings.SendToDriverAndUpdate(ActiveAccel);
+
DpiField.SetToEntered(RawAccelSettings.GUISettings.DPI);
PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate);
AutoWriteMenuItem.Checked = RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup;
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index 8481e75..4717a8b 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -89,6 +89,7 @@
<Compile Include="Layouts\OffLayout.cs" />
<Compile Include="Layouts\PowerLayout.cs" />
<Compile Include="Layouts\SigmoidLayout.cs" />
+ <Compile Include="Models\Options\OffsetOptions.cs" />
<Compile Include="Models\Options\Option.cs" />
<Compile Include="Models\Options\OptionXY.cs" />
<Compile Include="Models\Serialized\GUISettings.cs" />
diff --git a/wrapper/wrapper_io.cpp b/wrapper/wrapper_io.cpp
index 3f5673a..0f257bf 100644
--- a/wrapper/wrapper_io.cpp
+++ b/wrapper/wrapper_io.cpp
@@ -9,10 +9,6 @@ void wrapper_io::writeToDriver(const settings& args)
{
write(args);
}
- catch (const cooldown_error&)
- {
- throw gcnew DriverWriteCDException();
- }
catch (const install_error&)
{
throw gcnew DriverNotInstalledException();
diff --git a/wrapper/wrapper_io.hpp b/wrapper/wrapper_io.hpp
index aff572b..19f096f 100644
--- a/wrapper/wrapper_io.hpp
+++ b/wrapper/wrapper_io.hpp
@@ -17,5 +17,3 @@ public:
};
public ref struct DriverNotInstalledException : public DriverIOException {};
-
-public ref struct DriverWriteCDException : public DriverIOException {};