summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacobPalecki <[email protected]>2020-09-22 19:59:47 -0700
committerGitHub <[email protected]>2020-09-22 19:59:47 -0700
commit77f420cf45a1a0bee00602965e687097367e2a70 (patch)
treefa088af8f2feb54df5bcb6a036715fd32d0511e8
parentMerge pull request #21 from JacobPalecki/GUI (diff)
parentUpdate credits (diff)
downloadrawaccel-77f420cf45a1a0bee00602965e687097367e2a70.tar.xz
rawaccel-77f420cf45a1a0bee00602965e687097367e2a70.zip
Merge pull request #22 from JacobPalecki/GUI
Replace SigmoidGain with Motivity & Cleanup
-rw-r--r--common/accel-experimentone.hpp33
-rw-r--r--common/accel-motivity.hpp89
-rw-r--r--common/accel-sigmoidgain.hpp34
-rw-r--r--common/common.vcxitems3
-rw-r--r--common/rawaccel-settings.h2
-rw-r--r--common/rawaccel.hpp31
-rw-r--r--driver/driver.cpp29
-rw-r--r--grapher/Constants/Constants.cs8
-rw-r--r--grapher/Form1.Designer.cs42
-rw-r--r--grapher/Layouts/DefaultLayout.cs1
-rw-r--r--grapher/Layouts/LayoutBase.cs34
-rw-r--r--grapher/Layouts/LinearLayout.cs1
-rw-r--r--grapher/Layouts/LogarithmLayout.cs1
-rw-r--r--grapher/Layouts/MotivityLayout.cs (renamed from grapher/Layouts/SigmoidGainLayout.cs)16
-rw-r--r--grapher/Layouts/NaturalGainLayout.cs1
-rw-r--r--grapher/Layouts/NaturalLayout.cs1
-rw-r--r--grapher/Layouts/OffLayout.cs1
-rw-r--r--grapher/Layouts/PowerLayout.cs1
-rw-r--r--grapher/Models/AccelGUIFactory.cs3
-rw-r--r--grapher/Models/Calculations/AccelCalculator.cs85
-rw-r--r--grapher/Models/Calculations/AccelChartData.cs10
-rw-r--r--grapher/Models/Charts/AccelCharts.cs5
-rw-r--r--grapher/Models/Charts/ChartState/ChartState.cs24
-rw-r--r--grapher/Models/Charts/ChartState/CombinedState.cs2
-rw-r--r--grapher/Models/Charts/ChartState/XYOneGraphState.cs2
-rw-r--r--grapher/Models/Charts/ChartState/XYTwoGraphState.cs3
-rw-r--r--grapher/Models/Charts/ChartXY.cs53
-rw-r--r--grapher/Models/Mouse/MouseData.cs49
-rw-r--r--grapher/Models/Mouse/MouseWatcher.cs3
-rw-r--r--grapher/Models/Mouse/PointData.cs4
-rw-r--r--grapher/Models/Options/AccelOptionSet.cs11
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs12
-rw-r--r--grapher/Models/Options/ActiveValueLabel.cs5
-rw-r--r--grapher/Models/Options/ApplyOptions.cs4
-rw-r--r--grapher/Models/Serialized/DriverSettings.cs2
-rw-r--r--grapher/Models/Serialized/GUISettings.cs3
-rw-r--r--grapher/Models/Serialized/SettingsManager.cs8
-rw-r--r--grapher/Program.cs10
-rw-r--r--grapher/ReadMe/ReadMe.md9
-rw-r--r--grapher/grapher.csproj3
-rw-r--r--wrapper/wrapper.cpp21
41 files changed, 543 insertions, 116 deletions
diff --git a/common/accel-experimentone.hpp b/common/accel-experimentone.hpp
new file mode 100644
index 0000000..7d21b58
--- /dev/null
+++ b/common/accel-experimentone.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <math.h>
+
+#include "accel-base.hpp"
+
+namespace rawaccel {
+
+ /// <summary> Struct to hold sigmoid (s-shaped) gain implementation. </summary>
+ struct experimentone_impl {
+ double rate;
+ double limit;
+ double midpoint;
+ double subtractive_constant;
+
+ experimentone_impl(const accel_args& args) :
+ rate(pow(10,args.rate)), limit(2*log10(args.limit)), midpoint(log10(args.midpoint))
+ {
+ subtractive_constant = limit / 2;
+ }
+
+ inline double operator()(double speed) const {
+ double log_speed = log10(speed);
+ return pow(10, limit / (exp(-rate * (log_speed - midpoint)) + 1) - subtractive_constant);
+
+ }
+
+ inline double legacy_offset(double speed) const { return operator()(speed); }
+ };
+
+ using accel_experimentone = nonadditive_accel<experimentone_impl>;
+
+}
diff --git a/common/accel-motivity.hpp b/common/accel-motivity.hpp
new file mode 100644
index 0000000..a37d1ce
--- /dev/null
+++ b/common/accel-motivity.hpp
@@ -0,0 +1,89 @@
+#pragma once
+
+#include <math.h>
+
+#include "accel-base.hpp"
+
+#define RA_LOOKUP
+
+namespace rawaccel {
+
+ constexpr size_t LUT_SIZE = 601;
+
+ struct si_pair {
+ double slope = 0;
+ double intercept = 0;
+ };
+
+ /// <summary> Struct to hold sigmoid (s-shaped) gain implementation. </summary>
+ struct motivity_impl {
+ double rate;
+ double limit;
+ double midpoint;
+ double subtractive_constant;
+
+ motivity_impl(const accel_args& args) :
+ rate(pow(10,args.rate)), limit(2*log10(args.limit)), midpoint(log10(args.midpoint))
+ {
+ subtractive_constant = limit / 2;
+ }
+
+ inline double operator()(double speed) const {
+ double log_speed = log10(speed);
+ return pow(10, limit / (exp(-rate * (log_speed - midpoint)) + 1) - subtractive_constant);
+
+ }
+
+ inline double legacy_offset(double speed) const { return operator()(speed); }
+
+ inline double apply(si_pair* lookup, double speed) const
+ {
+ si_pair pair = lookup[map(speed)];
+ return pair.slope + pair.intercept / speed;
+ }
+
+ inline int map(double speed) const
+ {
+ int index = speed > 0 ? (int)(100 * log10(speed) + 201) : 0;
+
+ if (index < 0) return 0;
+ if (index >= LUT_SIZE) return LUT_SIZE - 1;
+
+ return index;
+ }
+
+ inline void fill(si_pair* lookup) const
+ {
+ double lookup_speed = 0;
+ double gain_integral_speed = 0;
+ double gain = 0;
+ double intercept = 0;
+ double output = 0;
+ double x = -2;
+
+ lookup[0] = {};
+
+ for (size_t i = 1; i < LUT_SIZE; i++)
+ {
+ x += 0.01;
+
+ lookup_speed = pow(10, x);
+
+ while (gain_integral_speed < lookup_speed)
+ {
+ gain_integral_speed += 0.001;
+ gain = operator()(gain_integral_speed);
+ output += gain * 0.001;
+ }
+
+ intercept = output - gain * lookup_speed;
+
+ lookup[i] = { gain, intercept };
+ }
+
+ }
+ };
+
+ using accel_motivity = nonadditive_accel<motivity_impl>;
+
+}
diff --git a/common/accel-sigmoidgain.hpp b/common/accel-sigmoidgain.hpp
deleted file mode 100644
index bed2f16..0000000
--- a/common/accel-sigmoidgain.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-
-#include <math.h>
-
-#include "accel-base.hpp"
-
-namespace rawaccel {
-
- /// <summary> Struct to hold sigmoid (s-shaped) gain implementation. </summary>
- struct sigmoidgain_impl {
- double rate;
- double limit;
- double additive_constant;
- double integration_constant;
-
- sigmoidgain_impl(const accel_args& args) :
- rate(args.rate), limit(args.limit - 1)
- {
- additive_constant = exp(rate * args.midpoint);
- integration_constant = log(1 + additive_constant);
- }
-
- inline double operator()(double speed) const {
- //f(x) = k/(1+e^(-m(c-x)))
- double scaled_speed = rate * speed;
- 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/common.vcxitems b/common/common.vcxitems
index fcd3ae8..3407cf2 100644
--- a/common/common.vcxitems
+++ b/common/common.vcxitems
@@ -16,13 +16,14 @@
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)accel-base.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-classic.hpp" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)accel-experimentone.hpp" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)accel-motivity.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-linear.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-logarithm.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-natural.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-naturalgain.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-noaccel.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-power.hpp" />
- <ClInclude Include="$(MSBuildThisFileDirectory)accel-sigmoidgain.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-error.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-io.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)rawaccel-settings.h" />
diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h
index 8c483eb..2ba6a98 100644
--- a/common/rawaccel-settings.h
+++ b/common/rawaccel-settings.h
@@ -6,7 +6,7 @@
namespace rawaccel {
enum class accel_mode {
- linear, classic, natural, naturalgain, sigmoidgain, power, logarithm, noaccel
+ linear, classic, natural, naturalgain, power, logarithm, motivity, noaccel
};
struct settings {
diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp
index 8819302..2e627c9 100644
--- a/common/rawaccel.hpp
+++ b/common/rawaccel.hpp
@@ -12,7 +12,7 @@
#include "accel-natural.hpp"
#include "accel-naturalgain.hpp"
#include "accel-power.hpp"
-#include "accel-sigmoidgain.hpp"
+#include "accel-motivity.hpp"
#include "accel-noaccel.hpp"
namespace rawaccel {
@@ -83,14 +83,16 @@ namespace rawaccel {
case accel_mode::classic: return vis(var.u.classic);
case accel_mode::natural: return vis(var.u.natural);
case accel_mode::naturalgain: return vis(var.u.naturalgain);
- case accel_mode::sigmoidgain: return vis(var.u.sigmoidgain);
case accel_mode::power: return vis(var.u.power);
case accel_mode::logarithm: return vis(var.u.logarithm);
+ case accel_mode::motivity: return vis(var.u.motivity);
default: return vis(var.u.noaccel);
}
}
struct accel_variant {
+ si_pair* lookup;
+
accel_mode tag = accel_mode::noaccel;
union union_t {
@@ -98,21 +100,30 @@ namespace rawaccel {
accel_classic classic;
accel_natural natural;
accel_naturalgain naturalgain;
- accel_sigmoidgain sigmoidgain;
accel_power power;
accel_logarithm logarithm;
+ accel_motivity motivity;
accel_noaccel noaccel = {};
} u = {};
- accel_variant(const accel_args& args, accel_mode mode) :
- tag(mode)
+ accel_variant(const accel_args& args, accel_mode mode, si_pair* lut = nullptr) :
+ tag(mode), lookup(lut)
{
visit_accel([&](auto& impl) {
impl = { args };
}, *this);
+
+ if (lookup && tag == accel_mode::motivity) {
+ u.motivity.fn.fill(lookup);
+ }
+
}
inline double apply(double speed) const {
+ if (lookup && tag == accel_mode::motivity) {
+ return u.motivity.fn.apply(lookup, speed);
+ }
+
return visit_accel([=](auto&& impl) {
return impl(speed);
}, *this);
@@ -190,8 +201,8 @@ namespace rawaccel {
velocity_gain_cap gain_cap;
accel_scale_clamp clamp;
- accelerator(const accel_args& args, accel_mode mode) :
- accel(args, mode), gain_cap(args.gain_cap, accel), clamp(args.scale_cap)
+ accelerator(const accel_args& args, accel_mode mode, si_pair* lut = nullptr) :
+ accel(args, mode, lut), gain_cap(args.gain_cap, accel), clamp(args.scale_cap)
{}
inline double apply(double speed) const {
@@ -213,7 +224,7 @@ namespace rawaccel {
vec2<accelerator> accels;
vec2d sensitivity = { 1, 1 };
- mouse_modifier(const settings& args) :
+ mouse_modifier(const settings& args, vec2<si_pair*> luts = {}) :
combine_magnitudes(args.combine_mags)
{
if (args.degrees_rotation != 0) {
@@ -230,8 +241,8 @@ namespace rawaccel {
return;
}
- accels.x = accelerator(args.argsv.x, args.modes.x);
- accels.y = accelerator(args.argsv.y, args.modes.y);
+ accels.x = accelerator(args.argsv.x, args.modes.x, luts.x);
+ accels.y = accelerator(args.argsv.y, args.modes.y, luts.y);
apply_accel = true;
}
diff --git a/driver/driver.cpp b/driver/driver.cpp
index fb47477..4dd3d62 100644
--- a/driver/driver.cpp
+++ b/driver/driver.cpp
@@ -12,11 +12,13 @@
namespace ra = rawaccel;
using milliseconds = double;
+using lut_value_t = ra::si_pair;
struct {
ra::settings args;
milliseconds tick_interval = 0; // set in DriverEntry
ra::mouse_modifier modifier;
+ vec2<lut_value_t*> lookups = {};
} global;
VOID
@@ -168,8 +170,14 @@ Return Value:
return;
}
- global.args = *reinterpret_cast<ra::settings*>(buffer);
- global.modifier = { global.args };
+ ra::settings new_settings = *reinterpret_cast<ra::settings*>(buffer);
+
+ if (new_settings.time_min <= 0 || _isnanf(new_settings.time_min)) {
+ new_settings.time_min = ra::settings{}.time_min;
+ }
+
+ global.args = new_settings;
+ global.modifier = { global.args, global.lookups };
WdfRequestComplete(Request, STATUS_SUCCESS);
}
@@ -251,6 +259,23 @@ Routine Description:
KeQueryPerformanceCounter(&freq);
global.tick_interval = 1e3 / freq.QuadPart;
+ auto make_lut = [] {
+ const size_t POOL_SIZE = sizeof(lut_value_t) * ra::LUT_SIZE;
+
+ auto pool = ExAllocatePoolWithTag(NonPagedPool, POOL_SIZE, 'AR');
+
+ if (!pool) {
+ DebugPrint(("RA - failed to allocate LUT\n"));
+ }
+ else {
+ RtlZeroMemory(pool, POOL_SIZE);
+ }
+
+ return reinterpret_cast<lut_value_t*>(pool);
+ };
+
+ global.lookups = { make_lut(), make_lut() };
+
CreateControlDevice(driver);
}
else {
diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs
index a51b09c..b41ffa2 100644
--- a/grapher/Constants/Constants.cs
+++ b/grapher/Constants/Constants.cs
@@ -21,9 +21,6 @@ namespace grapher
/// <summary> Ratio of max (X, Y) used in "by component" calulations to those used in "whole vector" calculations. </summary>
public const double XYToCombinedRatio = 1.4;
- /// <summary> Possible options to display in a layout. </summary>
- public const int PossibleOptionsCount = 6;
-
/// <summary> Separation between X and Y active value labels, in pixels. </summary>
public const int ActiveLabelXYSeparation = 2;
@@ -60,7 +57,8 @@ namespace grapher
/// <summary> Left placement of charts when narrowed </summary>
public const int NarrowChartLeft = 482;
- public const int WriteButtonVerticalOffset = 50;
+ /// <summary> Vertical placement of write button above bottom of sensitivity graph </summary>
+ public const int WriteButtonVerticalOffset = 80;
/// <summary> Format string for shortened x and y textboxes. </summary>
public const string ShortenedFormatString = "0.###";
@@ -84,7 +82,7 @@ namespace grapher
public const string AccelDropDownDefaultShortText = "Accel Type";
/// <summary> Default text to be displayed on write button. </summary>
- public const string WriteButtonDefaultText = "Write To Driver";
+ public const string WriteButtonDefaultText = "Apply";
/// <summary> Default text to be displayed on write button. </summary>
public const string WriteButtonDelayText = "Delay";
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index 535ee15..c6a895d 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -98,13 +98,13 @@ namespace grapher
this.GainChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.graphsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.showVelocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.scaleByDPIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dPIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DPITextBox = new System.Windows.Forms.ToolStripTextBox();
this.pollRateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.PollRateTextBox = new System.Windows.Forms.ToolStripTextBox();
this.ScaleMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.showVelocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.showLastMouseMoveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.capStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -166,7 +166,7 @@ namespace grapher
//
// AccelerationChart
//
- chartArea1.AxisX.Title = "Speed (counts/ms)";
+ chartArea1.AxisX.Title = "Input Speed (counts/ms)";
chartArea1.AxisY.Title = "Ratio of Output to Input";
chartArea1.Name = "ChartArea1";
this.AccelerationChart.ChartAreas.Add(chartArea1);
@@ -357,11 +357,11 @@ namespace grapher
//
// writeButton
//
- this.writeButton.Location = new System.Drawing.Point(153, 293);
+ this.writeButton.Location = new System.Drawing.Point(154, 270);
this.writeButton.Name = "writeButton";
- this.writeButton.Size = new System.Drawing.Size(102, 23);
+ this.writeButton.Size = new System.Drawing.Size(76, 23);
this.writeButton.TabIndex = 21;
- this.writeButton.Text = "Write To Driver";
+ this.writeButton.Text = "Apply";
this.writeButton.UseVisualStyleBackColor = true;
//
// sensitivityBoxY
@@ -400,7 +400,7 @@ namespace grapher
//
// VelocityChart
//
- chartArea2.AxisX.Title = "Speed (count/ms)";
+ chartArea2.AxisX.Title = "Input Speed (count/ms)";
chartArea2.AxisY.Title = "Output Speed (counts/ms)";
chartArea2.Name = "ChartArea1";
this.VelocityChart.ChartAreas.Add(chartArea2);
@@ -441,7 +441,7 @@ namespace grapher
//
// GainChart
//
- chartArea3.AxisX.Title = "Speed (counts/ms)";
+ chartArea3.AxisX.Title = "Input Speed (counts/ms)";
chartArea3.AxisY.Title = "Slope of Velocity Chart";
chartArea3.Name = "ChartArea1";
this.GainChart.ChartAreas.Add(chartArea3);
@@ -497,20 +497,14 @@ namespace grapher
//
this.graphsToolStripMenuItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.graphsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.showVelocityGainToolStripMenuItem,
this.scaleByDPIToolStripMenuItem,
+ this.showVelocityGainToolStripMenuItem,
this.showLastMouseMoveToolStripMenuItem});
this.graphsToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.graphsToolStripMenuItem.Name = "graphsToolStripMenuItem";
this.graphsToolStripMenuItem.Size = new System.Drawing.Size(53, 20);
this.graphsToolStripMenuItem.Text = "Charts";
//
- // showVelocityGainToolStripMenuItem
- //
- this.showVelocityGainToolStripMenuItem.Name = "showVelocityGainToolStripMenuItem";
- this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
- this.showVelocityGainToolStripMenuItem.Text = "Show Velocity && Gain";
- //
// scaleByDPIToolStripMenuItem
//
this.scaleByDPIToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -555,6 +549,12 @@ namespace grapher
this.ScaleMenuItem.Size = new System.Drawing.Size(169, 22);
this.ScaleMenuItem.Text = "Re-scale by above";
//
+ // showVelocityGainToolStripMenuItem
+ //
+ this.showVelocityGainToolStripMenuItem.Name = "showVelocityGainToolStripMenuItem";
+ this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
+ this.showVelocityGainToolStripMenuItem.Text = "Show Velocity && Gain";
+ //
// showLastMouseMoveToolStripMenuItem
//
this.showLastMouseMoveToolStripMenuItem.Checked = true;
@@ -661,7 +661,7 @@ namespace grapher
//
// AccelerationChartY
//
- chartArea4.AxisX.Title = "Speed (counts/ms)";
+ chartArea4.AxisX.Title = "Input Speed (counts/ms)";
chartArea4.AxisY.Title = "Ratio of Output to Input)";
chartArea4.Name = "ChartArea1";
this.AccelerationChartY.ChartAreas.Add(chartArea4);
@@ -697,7 +697,7 @@ namespace grapher
//
// VelocityChartY
//
- chartArea5.AxisX.Title = "Speed (count/ms)";
+ chartArea5.AxisX.Title = "Input Speed (count/ms)";
chartArea5.AxisY.Title = "Output Speed (counts/ms)";
chartArea5.Name = "ChartArea1";
this.VelocityChartY.ChartAreas.Add(chartArea5);
@@ -733,7 +733,7 @@ namespace grapher
//
// GainChartY
//
- chartArea6.AxisX.Title = "Speed (counts/ms)";
+ chartArea6.AxisX.Title = "Input Speed (counts/ms)";
chartArea6.AxisY.Title = "Slope of Velocity Chart";
chartArea6.Name = "ChartArea1";
this.GainChartY.ChartAreas.Add(chartArea6);
@@ -781,9 +781,9 @@ namespace grapher
this.ActiveValueTitle.AutoSize = true;
this.ActiveValueTitle.Location = new System.Drawing.Point(187, 30);
this.ActiveValueTitle.Name = "ActiveValueTitle";
- this.ActiveValueTitle.Size = new System.Drawing.Size(37, 13);
+ this.ActiveValueTitle.Size = new System.Drawing.Size(41, 13);
this.ActiveValueTitle.TabIndex = 35;
- this.ActiveValueTitle.Text = "Active";
+ this.ActiveValueTitle.Text = "Current";
//
// SensitivityActiveXLabel
//
@@ -1063,9 +1063,9 @@ namespace grapher
this.ActiveValueTitleY.AutoSize = true;
this.ActiveValueTitleY.Location = new System.Drawing.Point(428, 30);
this.ActiveValueTitleY.Name = "ActiveValueTitleY";
- this.ActiveValueTitleY.Size = new System.Drawing.Size(37, 13);
+ this.ActiveValueTitleY.Size = new System.Drawing.Size(41, 13);
this.ActiveValueTitleY.TabIndex = 67;
- this.ActiveValueTitleY.Text = "Active";
+ this.ActiveValueTitleY.Text = "Current";
//
// RawAcceleration
//
diff --git a/grapher/Layouts/DefaultLayout.cs b/grapher/Layouts/DefaultLayout.cs
index 83535c2..cf6f87f 100644
--- a/grapher/Layouts/DefaultLayout.cs
+++ b/grapher/Layouts/DefaultLayout.cs
@@ -10,6 +10,7 @@ namespace grapher.Layouts
Name = "Default";
Index = (int)AccelMode.noaccel;
ButtonEnabled = false;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(true, Cap);
diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs
index 6ed8fee..b89e2f7 100644
--- a/grapher/Layouts/LayoutBase.cs
+++ b/grapher/Layouts/LayoutBase.cs
@@ -10,6 +10,7 @@ namespace grapher.Layouts
public const string Exponent = "Exponent";
public const string Limit = "Limit";
public const string Midpoint = "Midpoint";
+ public const string Motility = "Motility";
public const string Offset = "Offset";
public const string Cap = "Cap";
public const string Weight = "Weight";
@@ -24,15 +25,18 @@ namespace grapher.Layouts
MidpointLayout = new OptionLayout(false, string.Empty);
ButtonEnabled = true;
+ LogarithmicCharts = false;
}
/// <summary>
/// Gets or sets mapping from acceleration type to identifying integer.
/// Must match accel_mode defined in rawaccel-settings.h
/// </summary>
- public int Index { get; internal set; }
+ public int Index { get; protected set; }
- public string Name { get; internal set; }
+ public string Name { get; protected set; }
+
+ public bool LogarithmicCharts { get; protected set; }
protected bool ButtonEnabled { get; set; }
@@ -58,30 +62,32 @@ namespace grapher.Layouts
Button button,
int top)
{
- AccelLayout.Layout(accelOption);
- CapLayout.Layout(capOption);
- WeightLayout.Layout(weightOption);
- OffsetLayout.Layout(offsetOption);
- LimExpLayout.Layout(limExpOption);
- MidpointLayout.Layout(midpointOption);
-
button.Enabled = ButtonEnabled;
IOption previous = null;
- foreach (var option in new IOption[] { accelOption, capOption, weightOption, offsetOption, limExpOption, midpointOption})
+
+ foreach (var option in new (OptionLayout, IOption)[] {
+ (AccelLayout, accelOption),
+ (CapLayout, capOption),
+ (WeightLayout, weightOption),
+ (OffsetLayout, offsetOption),
+ (LimExpLayout, limExpOption),
+ (MidpointLayout, midpointOption)})
{
- if (option.Visible)
+ option.Item1.Layout(option.Item2);
+
+ if (option.Item2.Visible)
{
if (previous != null)
{
- option.SnapTo(previous);
+ option.Item2.SnapTo(previous);
}
else
{
- option.Top = top;
+ option.Item2.Top = top;
}
- previous = option;
+ previous = option.Item2;
}
}
}
diff --git a/grapher/Layouts/LinearLayout.cs b/grapher/Layouts/LinearLayout.cs
index 8afdc79..e87c851 100644
--- a/grapher/Layouts/LinearLayout.cs
+++ b/grapher/Layouts/LinearLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "Linear";
Index = (int)AccelMode.linear;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(true, Cap);
diff --git a/grapher/Layouts/LogarithmLayout.cs b/grapher/Layouts/LogarithmLayout.cs
index 5b25d60..e39dbe7 100644
--- a/grapher/Layouts/LogarithmLayout.cs
+++ b/grapher/Layouts/LogarithmLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "Logarithm";
Index = (int)AccelMode.logarithm;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Scale);
CapLayout = new OptionLayout(true, Cap);
diff --git a/grapher/Layouts/SigmoidGainLayout.cs b/grapher/Layouts/MotivityLayout.cs
index c807439..dfef2de 100644
--- a/grapher/Layouts/SigmoidGainLayout.cs
+++ b/grapher/Layouts/MotivityLayout.cs
@@ -1,20 +1,26 @@
using grapher.Models.Serialized;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
namespace grapher.Layouts
{
- public class SigmoidGainLayout : LayoutBase
+ public class MotivityLayout : LayoutBase
{
- public SigmoidGainLayout()
+ public MotivityLayout()
: base()
{
- Name = "SigmoidGain";
- Index = (int)AccelMode.sigmoidgain;
+ Name = "Motivity";
+ Index = (int)AccelMode.motivity;
+ LogarithmicCharts = true;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(false, string.Empty);
WeightLayout = new OptionLayout(true, Weight);
OffsetLayout = new OptionLayout(false, string.Empty);
- LimExpLayout = new OptionLayout(true, Limit);
+ LimExpLayout = new OptionLayout(true, Motility);
MidpointLayout = new OptionLayout(true, Midpoint);
}
}
diff --git a/grapher/Layouts/NaturalGainLayout.cs b/grapher/Layouts/NaturalGainLayout.cs
index dd2cc05..b9cf75e 100644
--- a/grapher/Layouts/NaturalGainLayout.cs
+++ b/grapher/Layouts/NaturalGainLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "NaturalGain";
Index = (int)AccelMode.naturalgain;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Layouts/NaturalLayout.cs b/grapher/Layouts/NaturalLayout.cs
index faa4730..59895df 100644
--- a/grapher/Layouts/NaturalLayout.cs
+++ b/grapher/Layouts/NaturalLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "Natural";
Index = (int)AccelMode.natural;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Layouts/OffLayout.cs b/grapher/Layouts/OffLayout.cs
index 85c8d3f..c47ea39 100644
--- a/grapher/Layouts/OffLayout.cs
+++ b/grapher/Layouts/OffLayout.cs
@@ -10,6 +10,7 @@ namespace grapher.Layouts
Name = "Off";
Index = (int)AccelMode.noaccel;
ButtonEnabled = true;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(false, string.Empty);
CapLayout = new OptionLayout(false, string.Empty);
diff --git a/grapher/Layouts/PowerLayout.cs b/grapher/Layouts/PowerLayout.cs
index 2004f23..5391506 100644
--- a/grapher/Layouts/PowerLayout.cs
+++ b/grapher/Layouts/PowerLayout.cs
@@ -9,6 +9,7 @@ namespace grapher.Layouts
{
Name = "Power";
Index = (int)AccelMode.power;
+ LogarithmicCharts = false;
AccelLayout = new OptionLayout(true, Acceleration);
CapLayout = new OptionLayout(true, Cap);
diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs
index eb30864..d986369 100644
--- a/grapher/Models/AccelGUIFactory.cs
+++ b/grapher/Models/AccelGUIFactory.cs
@@ -286,7 +286,8 @@ namespace grapher.Models
accelCalculator.DPI,
accelCalculator.PollRate,
autoWriteMenuItem,
- showLastMouseMoveMenuItem);
+ showLastMouseMoveMenuItem,
+ showVelocityGainToolStripMenuItem);
return new AccelGUI(
form,
diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs
index a140c90..f2a6c7c 100644
--- a/grapher/Models/Calculations/AccelCalculator.cs
+++ b/grapher/Models/Calculations/AccelCalculator.cs
@@ -62,16 +62,47 @@ namespace grapher.Models.Calculations
double lastInputMagnitude = 0;
double lastOutputMagnitude = 0;
+ double maxRatio = 0.0;
+ double minRatio = Double.MaxValue;
+ double maxSlope = 0.0;
+ double minSlope = Double.MaxValue;
+
foreach (var magnitudeDatum in magnitudeData)
{
+ if (magnitudeDatum.magnitude <=0)
+ {
+ continue;
+ }
+
var output = accel.Accelerate(magnitudeDatum.x, magnitudeDatum.y, MeasurementTime);
var outMagnitude = Magnitude(output.Item1, output.Item2);
+
var ratio = magnitudeDatum.magnitude > 0 ? outMagnitude / magnitudeDatum.magnitude : starter;
+
+ if (ratio > maxRatio)
+ {
+ maxRatio = ratio;
+ }
+
+ if (ratio < minRatio)
+ {
+ minRatio = ratio;
+ }
var inDiff = magnitudeDatum.magnitude - lastInputMagnitude;
var outDiff = outMagnitude - lastOutputMagnitude;
var slope = inDiff > 0 ? outDiff / inDiff : starter;
+ if (slope > maxSlope)
+ {
+ maxSlope = slope;
+ }
+
+ if (slope < minSlope)
+ {
+ minSlope = slope;
+ }
+
if (!data.AccelPoints.ContainsKey(magnitudeDatum.magnitude))
{
data.AccelPoints.Add(magnitudeDatum.magnitude, ratio);
@@ -92,6 +123,10 @@ namespace grapher.Models.Calculations
}
data.OrderedVelocityPointsList.AddRange(data.VelocityPoints.Values.ToList());
+ data.MaxAccel = maxRatio;
+ data.MinAccel = minRatio;
+ data.MaxGain = maxSlope;
+ data.MinGain = minSlope;
}
public void CalculateCombinedDiffSens(AccelData data, ManagedAccel accel, DriverSettings settings, ICollection<MagnitudeData> magnitudeData)
@@ -100,6 +135,12 @@ namespace grapher.Models.Calculations
double lastOutputMagnitudeX = 0;
double lastOutputMagnitudeY = 0;
+ double maxRatio = 0.0;
+ double minRatio = Double.MaxValue;
+ double maxSlope = 0.0;
+ double minSlope = Double.MaxValue;
+
+
Sensitivity = GetSens(ref settings);
foreach (var magnitudeDatum in magnitudeData)
@@ -118,6 +159,26 @@ namespace grapher.Models.Calculations
var xRatio = settings.sensitivity.x * ratio;
var yRatio = settings.sensitivity.y * ratio;
+ if (xRatio > maxRatio)
+ {
+ maxRatio = xRatio;
+ }
+
+ if (xRatio < minRatio)
+ {
+ minRatio = xRatio;
+ }
+
+ if (yRatio > maxRatio)
+ {
+ maxRatio = yRatio;
+ }
+
+ if (yRatio < minRatio)
+ {
+ minRatio = yRatio;
+ }
+
if (!data.X.AccelPoints.ContainsKey(magnitudeDatum.magnitude))
{
data.X.AccelPoints.Add(magnitudeDatum.magnitude, xRatio);
@@ -137,6 +198,26 @@ namespace grapher.Models.Calculations
var xSlope = inDiff > 0 ? xOutDiff / inDiff : settings.sensitivity.x;
var ySlope = inDiff > 0 ? yOutDiff / inDiff : settings.sensitivity.y;
+ if (xSlope > maxSlope)
+ {
+ maxSlope = xSlope;
+ }
+
+ if (xSlope < minSlope)
+ {
+ minSlope = xSlope;
+ }
+
+ if (ySlope > maxSlope)
+ {
+ maxSlope = ySlope;
+ }
+
+ if (ySlope < minSlope)
+ {
+ minSlope = ySlope;
+ }
+
if (!data.X.VelocityPoints.ContainsKey(magnitudeDatum.magnitude))
{
data.X.VelocityPoints.Add(magnitudeDatum.magnitude, xOut);
@@ -163,6 +244,10 @@ namespace grapher.Models.Calculations
}
data.Combined.OrderedVelocityPointsList.AddRange(data.Combined.VelocityPoints.Values.ToList());
+ data.Combined.MaxAccel = maxRatio;
+ data.Combined.MinAccel = minRatio;
+ data.Combined.MaxGain = maxSlope;
+ data.Combined.MinGain = minSlope;
}
public ReadOnlyCollection<MagnitudeData> GetMagnitudes()
diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs
index fbf1944..54685a2 100644
--- a/grapher/Models/Calculations/AccelChartData.cs
+++ b/grapher/Models/Calculations/AccelChartData.cs
@@ -23,6 +23,14 @@ namespace grapher.Models.Calculations
public SortedDictionary<double, double> AccelPoints { get; }
+ public double MaxAccel { get; set; }
+
+ public double MinAccel { get; set; }
+
+ public double MaxGain { get; set; }
+
+ public double MinGain { get; set; }
+
public SortedDictionary<double, double> VelocityPoints { get; }
public SortedDictionary<double, double> GainPoints { get; }
@@ -54,7 +62,6 @@ namespace grapher.Models.Calculations
{
var velIdx = GetVelocityIndex(outVelocityValue);
- velIdx = Math.Min(velIdx, VelocityPoints.Count - 1);
values = (VelocityPoints.ElementAt(velIdx).Key, AccelPoints.ElementAt(velIdx).Value, GainPoints.ElementAt(velIdx).Value);
OutVelocityToPoints.Add(outVelocityValue, values);
return values;
@@ -81,6 +88,7 @@ namespace grapher.Models.Calculations
}
velIdx = Math.Min(velIdx, VelocityPoints.Count - 1);
+ velIdx = Math.Max(velIdx, 0);
return velIdx;
}
diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs
index d22ab78..a0e99c8 100644
--- a/grapher/Models/Charts/AccelCharts.cs
+++ b/grapher/Models/Charts/AccelCharts.cs
@@ -149,6 +149,11 @@ namespace grapher
ChartState.Calculate(accel, settings);
}
+ public void SetLogarithmic(bool x, bool y)
+ {
+ ChartState.SetLogarithmic(x, y);
+ }
+
private static void SetupCharts(
ChartXY sensitivityChart,
ChartXY velocityChart,
diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs
index ea67e83..e1c7d01 100644
--- a/grapher/Models/Charts/ChartState/ChartState.cs
+++ b/grapher/Models/Charts/ChartState/ChartState.cs
@@ -100,5 +100,29 @@ namespace grapher.Models.Charts.ChartState
GainChart.Hide();
form.Height = SensitivityChart.Height + borderHeight;
}
+
+ public void SetLogarithmic(bool x, bool y)
+ {
+ if (x)
+ {
+ ChartXY.SetLogarithmic(SensitivityChart.ChartX);
+ ChartXY.SetLogarithmic(GainChart.ChartX);
+ }
+ else
+ {
+ ChartXY.SetStandard(SensitivityChart.ChartX);
+ ChartXY.SetStandard(GainChart.ChartX);
+ }
+
+ if (y)
+ {
+ ChartXY.SetLogarithmic(SensitivityChart.ChartY);
+ ChartXY.SetLogarithmic(GainChart.ChartY);
+ }
+ {
+ ChartXY.SetStandard(SensitivityChart.ChartY);
+ ChartXY.SetStandard(GainChart.ChartY);
+ }
+ }
}
}
diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs
index 17cd68a..f4b6b8f 100644
--- a/grapher/Models/Charts/ChartState/CombinedState.cs
+++ b/grapher/Models/Charts/ChartState/CombinedState.cs
@@ -36,6 +36,8 @@ namespace grapher.Models.Charts.ChartState
SensitivityChart.Bind(Data.Combined.AccelPoints);
VelocityChart.Bind(Data.Combined.VelocityPoints);
GainChart.Bind(Data.Combined.GainPoints);
+ SensitivityChart.SetMinMax(Data.Combined.MinAccel, Data.Combined.MaxAccel);
+ GainChart.SetMinMax(Data.Combined.MinGain, Data.Combined.MaxGain);
}
public override void Calculate(ManagedAccel accel, DriverSettings settings)
diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
index bbc0c28..6bfaac5 100644
--- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs
+++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
@@ -38,6 +38,8 @@ namespace grapher.Models.Charts.ChartState
SensitivityChart.BindXYCombined(Data.X.AccelPoints, Data.Y.AccelPoints);
VelocityChart.BindXYCombined(Data.X.VelocityPoints, Data.Y.VelocityPoints);
GainChart.BindXYCombined(Data.X.GainPoints, Data.Y.GainPoints);
+ SensitivityChart.SetMinMax(Data.Combined.MinAccel, Data.Combined.MaxAccel);
+ GainChart.SetMinMax(Data.Combined.MinGain, Data.Combined.MaxGain);
}
public override void Calculate(ManagedAccel accel, DriverSettings settings)
diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
index 69dc335..b775853 100644
--- a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
+++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
@@ -65,6 +65,9 @@ namespace grapher.Models.Charts.ChartState
SensitivityChart.BindXY(Data.X.AccelPoints, Data.Y.AccelPoints);
VelocityChart.BindXY(Data.X.VelocityPoints, Data.Y.VelocityPoints);
GainChart.BindXY(Data.X.GainPoints, Data.Y.GainPoints);
+
+ SensitivityChart.SetMinMaxXY(Data.X.MinAccel, Data.X.MaxAccel, Data.Y.MinAccel, Data.Y.MaxAccel);
+ GainChart.SetMinMaxXY(Data.X.MinGain, Data.X.MaxGain, Data.Y.MinGain, Data.Y.MaxGain);
}
public override void Calculate(ManagedAccel accel, DriverSettings settings)
diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs
index fdd0258..c30c993 100644
--- a/grapher/Models/Charts/ChartXY.cs
+++ b/grapher/Models/Charts/ChartXY.cs
@@ -100,6 +100,9 @@ namespace grapher
chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01;
chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001;
+ chart.ChartAreas[0].AxisX.LabelStyle.Format = "0.##";
+ chart.ChartAreas[0].AxisY.LabelStyle.Format = "0.##";
+
chart.ChartAreas[0].CursorY.Interval = 0.001;
chart.ChartAreas[0].CursorX.AutoScroll = true;
@@ -128,10 +131,29 @@ namespace grapher
pointTwo.Get(out x, out y);
chart.Series[3].Points.DataBindXY(x, y);
}
- chart.Update();
}
}
+ public static void SetLogarithmic(Chart chart)
+ {
+ /*
+ chart.ChartAreas[0].AxisX.Minimum = 0.001;
+ chart.ChartAreas[0].AxisX.Maximum = 3500;
+ chart.ChartAreas[0].AxisY.Minimum = 0.001;
+ chart.ChartAreas[0].AxisY.Maximum = 10;
+ chart.ChartAreas[0].AxisX.IsLogarithmic = true;
+ chart.ChartAreas[0].AxisY.IsLogarithmic = true;
+ */
+ }
+
+ public static void SetStandard(Chart chart)
+ {
+ /*
+ chart.ChartAreas[0].AxisX.IsLogarithmic = false;
+ chart.ChartAreas[0].AxisY.IsLogarithmic = false;
+ */
+ }
+
public void SetPointBinds(PointData combined, PointData x, PointData y)
{
CombinedPointData = combined;
@@ -168,18 +190,47 @@ namespace grapher
public void Bind(IDictionary data)
{
ChartX.Series[0].Points.DataBindXY(data.Keys, data.Values);
+ ChartX.Series[2].IsVisibleInLegend = false;
+ ChartX.Series[2].Points.Clear();
}
public void BindXY(IDictionary dataX, IDictionary dataY)
{
ChartX.Series[0].Points.DataBindXY(dataX.Keys, dataX.Values);
ChartY.Series[0].Points.DataBindXY(dataY.Keys, dataY.Values);
+ ChartX.Series[2].IsVisibleInLegend = false;
+ ChartX.Series[2].Points.Clear();
}
public void BindXYCombined(IDictionary dataX, IDictionary dataY)
{
ChartX.Series[0].Points.DataBindXY(dataX.Keys, dataX.Values);
ChartX.Series[2].Points.DataBindXY(dataY.Keys, dataY.Values);
+ ChartX.Series[2].IsVisibleInLegend = true;
+ }
+
+ public void SetMinMax(double min, double max)
+ {
+ if (min < max)
+ {
+ ChartX.ChartAreas[0].AxisY.Minimum = min;
+ ChartX.ChartAreas[0].AxisY.Maximum = max;
+ }
+ }
+
+ public void SetMinMaxXY(double minX, double maxX, double minY, double maxY)
+ {
+ if (minX < maxX)
+ {
+ ChartX.ChartAreas[0].AxisY.Minimum = minX;
+ ChartX.ChartAreas[0].AxisY.Maximum = maxX;
+ }
+
+ if (minY < maxY)
+ {
+ ChartY.ChartAreas[0].AxisY.Minimum = minY;
+ ChartY.ChartAreas[0].AxisY.Maximum = maxY;
+ }
}
public void SetCombined()
diff --git a/grapher/Models/Mouse/MouseData.cs b/grapher/Models/Mouse/MouseData.cs
new file mode 100644
index 0000000..e59a969
--- /dev/null
+++ b/grapher/Models/Mouse/MouseData.cs
@@ -0,0 +1,49 @@
+using System;
+
+namespace grapher.Models.Mouse
+{
+ public class MouseData
+ {
+ #region Constructors
+
+ public MouseData()
+ {
+ Lock = new Object();
+ X = 0;
+ Y = 0;
+ }
+
+ #endregion Constructors
+
+ #region Properties
+
+ public Object Lock { get; }
+
+ private int X { get; set; }
+ private int Y { get; set; }
+
+ public void Set(int x, int y)
+ {
+ lock (Lock)
+ {
+ X = x;
+ Y = y;
+ }
+ }
+
+ #endregion Properties
+
+ #region Methods
+
+ public void Get(out int x, out int y)
+ {
+ lock (Lock)
+ {
+ x = X;
+ y = Y;
+ }
+ }
+
+ #endregion Methods
+ }
+}
diff --git a/grapher/Models/Mouse/MouseWatcher.cs b/grapher/Models/Mouse/MouseWatcher.cs
index 405110e..86b1c2e 100644
--- a/grapher/Models/Mouse/MouseWatcher.cs
+++ b/grapher/Models/Mouse/MouseWatcher.cs
@@ -682,6 +682,7 @@ namespace grapher.Models.Mouse
ContainingForm = containingForm;
Display = display;
AccelCharts = accelCharts;
+ MouseData = new MouseData();
RAWINPUTDEVICE device = new RAWINPUTDEVICE();
device.WindowHandle = ContainingForm.Handle;
@@ -705,6 +706,8 @@ namespace grapher.Models.Mouse
private AccelCharts AccelCharts { get; }
+ private MouseData MouseData { get; }
+
private double PollTime { get; }
#endregion Properties
diff --git a/grapher/Models/Mouse/PointData.cs b/grapher/Models/Mouse/PointData.cs
index 374c52e..e3f44ea 100644
--- a/grapher/Models/Mouse/PointData.cs
+++ b/grapher/Models/Mouse/PointData.cs
@@ -9,8 +9,8 @@ namespace grapher.Models.Mouse
public PointData()
{
Lock = new Object();
- X = new double[] { 0 };
- Y = new double[] { 0 };
+ X = new double[] { 0.01 };
+ Y = new double[] { 0.01 };
}
#endregion Constructors
diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs
index bc0d368..11a7f10 100644
--- a/grapher/Models/Options/AccelOptionSet.cs
+++ b/grapher/Models/Options/AccelOptionSet.cs
@@ -24,6 +24,7 @@ namespace grapher.Models.Options
OptionsTitle.Top = TopAnchor;
IsTitleMode = true;
+ Hidden = false;
SetRegularMode();
}
@@ -35,9 +36,10 @@ namespace grapher.Models.Options
public AccelTypeOptions Options { get; }
-
public bool IsTitleMode { get; private set; }
+ private bool Hidden { get; set; }
+
public void SetRegularMode()
{
if (IsTitleMode)
@@ -67,6 +69,7 @@ namespace grapher.Models.Options
OptionsTitle.Hide();
ActiveValuesTitle.Hide();
Options.Hide();
+ Hidden = true;
}
public void Show()
@@ -78,6 +81,7 @@ namespace grapher.Models.Options
ActiveValuesTitle.Show();
Options.Show();
+ Hidden = false;
}
public void DisplayTitle()
@@ -106,7 +110,10 @@ namespace grapher.Models.Options
public void SetActiveValues(int mode, AccelArgs args)
{
- Options.SetActiveValues(mode, args);
+ if (!Hidden)
+ {
+ Options.SetActiveValues(mode, args);
+ }
}
public void AlignActiveValues()
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index 917ac5c..9bd42f5 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -17,10 +17,10 @@ namespace grapher
new LinearLayout(),
new ClassicLayout(),
new NaturalLayout(),
+ new NaturalGainLayout(),
new PowerLayout(),
new LogarithmLayout(),
- new NaturalGainLayout(),
- new SigmoidGainLayout(),
+ new MotivityLayout(),
new OffLayout()
}.ToDictionary(k => k.Name);
@@ -63,6 +63,7 @@ namespace grapher
#endregion Constructors
#region Properties
+ public AccelCharts AccelCharts { get; }
public Button WriteButton { get; }
@@ -179,11 +180,12 @@ namespace grapher
public void SetActiveValues(int index, AccelArgs args)
{
- var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name;
- AccelTypeActiveValue.SetValue(name);
+ AccelerationType = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value;
+ AccelTypeActiveValue.SetValue(AccelerationType.Name);
+ AccelDropdown.SelectedIndex = AccelerationType.Index;
Weight.SetActiveValue(args.weight);
- Cap.SetActiveValues(args.gainCap, args.scaleCap, args.gainCap > 0);
+ Cap.SetActiveValues(args.gainCap, args.scaleCap, args.gainCap > 0 || args.scaleCap <= 0);
Offset.SetActiveValue(args.offset, args.legacy_offset);
Acceleration.SetActiveValue(args.accel);
LimitOrExponent.SetActiveValue(args.exponent);
diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs
index 18a4400..66817ab 100644
--- a/grapher/Models/Options/ActiveValueLabel.cs
+++ b/grapher/Models/Options/ActiveValueLabel.cs
@@ -5,11 +5,6 @@ namespace grapher.Models.Options
{
public class ActiveValueLabel
{
- #region Constants
-
-
- #endregion Constants
-
#region Fields
private string _prefix;
diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs
index 6ec9d31..720cb13 100644
--- a/grapher/Models/Options/ApplyOptions.cs
+++ b/grapher/Models/Options/ApplyOptions.cs
@@ -130,6 +130,10 @@ namespace grapher.Models.Options
settings.args.x,
settings.args.y,
settings.combineMagnitudes);
+
+ AccelCharts.SetLogarithmic(
+ OptionSetX.Options.AccelerationType.LogarithmicCharts,
+ OptionSetY.Options.AccelerationType.LogarithmicCharts);
}
public void OnWholeClicked(object sender, EventArgs e)
diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs
index d42187c..5f9307c 100644
--- a/grapher/Models/Serialized/DriverSettings.cs
+++ b/grapher/Models/Serialized/DriverSettings.cs
@@ -8,7 +8,7 @@ namespace grapher.Models.Serialized
public enum AccelMode
{
- linear, classic, natural, naturalgain, sigmoidgain, power, logarithm, noaccel
+ linear, classic, natural, naturalgain, power, logarithm, motivity, noaccel
}
#endregion Enumerations
diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs
index 2543104..84e681b 100644
--- a/grapher/Models/Serialized/GUISettings.cs
+++ b/grapher/Models/Serialized/GUISettings.cs
@@ -33,6 +33,9 @@ namespace grapher.Models.Serialized
[JsonProperty(Order = 4)]
public bool ShowLastMouseMove { get; set; }
+ [JsonProperty(Order = 4)]
+ public bool ShowVelocityAndGain { get; set; }
+
#endregion Properties
}
}
diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs
index ccffc3f..cac2bd0 100644
--- a/grapher/Models/Serialized/SettingsManager.cs
+++ b/grapher/Models/Serialized/SettingsManager.cs
@@ -13,13 +13,15 @@ namespace grapher.Models.Serialized
Field dpiField,
Field pollRateField,
ToolStripMenuItem autoWrite,
- ToolStripMenuItem showLastMouseMove)
+ ToolStripMenuItem showLastMouseMove,
+ ToolStripMenuItem showVelocityAndGain)
{
ActiveAccel = activeAccel;
DpiField = dpiField;
PollRateField = pollRateField;
AutoWriteMenuItem = autoWrite;
ShowLastMouseMoveMenuItem = showLastMouseMove;
+ ShowVelocityAndGainMoveMenuItem = showVelocityAndGain;
}
#endregion Constructors
@@ -38,6 +40,8 @@ namespace grapher.Models.Serialized
private ToolStripMenuItem ShowLastMouseMoveMenuItem { get; set; }
+ private ToolStripMenuItem ShowVelocityAndGainMoveMenuItem { get; set; }
+
#endregion Properties
#region Methods
@@ -53,6 +57,7 @@ namespace grapher.Models.Serialized
DPI = (int)DpiField.Data,
PollRate = (int)PollRateField.Data,
ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked,
+ ShowVelocityAndGain = ShowVelocityAndGainMoveMenuItem.Checked,
};
RawAccelSettings.Save();
@@ -69,6 +74,7 @@ namespace grapher.Models.Serialized
PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate);
AutoWriteMenuItem.Checked = RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup;
ShowLastMouseMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowLastMouseMove;
+ ShowVelocityAndGainMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowVelocityAndGain;
}
public void Startup()
diff --git a/grapher/Program.cs b/grapher/Program.cs
index 85fd040..485e074 100644
--- a/grapher/Program.cs
+++ b/grapher/Program.cs
@@ -11,9 +11,19 @@ namespace grapher
[STAThread]
static void Main()
{
+ var mutex = new System.Threading.Mutex(true, "RawAccelGrapher", out bool result);
+
+ if (!result)
+ {
+ MessageBox.Show("Another instance of the Raw Accel Grapher is already running.");
+ return;
+ }
+
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new RawAcceleration());
+
+ GC.KeepAlive(mutex);
}
}
}
diff --git a/grapher/ReadMe/ReadMe.md b/grapher/ReadMe/ReadMe.md
index 1d0c282..84afc2a 100644
--- a/grapher/ReadMe/ReadMe.md
+++ b/grapher/ReadMe/ReadMe.md
@@ -11,4 +11,11 @@ Raw Accel will be signed to run as a fully trusted driver. It modifies mouse inp
Development of Raw Accel is ongoing at https://github.com/a1xd/rawaccel. Being a signed driver, the guts of the Raw Accel driver will be updated infrequently. The GUI can be updated as often was we like, however, so please let us know if you find any bugs.
## Further Help
-For an overview of everything Raw Accel has to offer, please see the guide (guide.md). For a list of frequently asked questions, please see the FAQ (FAQ.md). \ No newline at end of file
+For an overview of everything Raw Accel has to offer, please see the guide (guide.md). For a list of frequently asked questions, please see the FAQ (FAQ.md).
+
+## Credits
+simon - Driver & Acceleration Logic
+\_m00se\_ - GUI, Gain features, Acceleration types
+Sidiouth - Primary tester and sounding board
+TauntyAmordillo - Originator of the alternate curve ideas (Natural and Motivity types)
+Kovaak - Brought us together \ No newline at end of file
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index d451a91..bc9fcf2 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -54,9 +54,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Constants\Constants.cs" />
+ <Compile Include="Layouts\MotivityLayout.cs" />
<Compile Include="Layouts\LogarithmLayout.cs" />
<Compile Include="Layouts\NaturalGainLayout.cs" />
- <Compile Include="Layouts\SigmoidGainLayout.cs" />
<Compile Include="Models\AccelGUIFactory.cs" />
<Compile Include="Models\Calculations\AccelCalculator.cs" />
<Compile Include="Models\Calculations\AccelChartData.cs" />
@@ -69,6 +69,7 @@
<Compile Include="Models\Charts\EstimatedPoints.cs" />
<Compile Include="Models\Charts\ChartState\XYOneGraphState.cs" />
<Compile Include="Models\Charts\ChartState\XYTwoGraphState.cs" />
+ <Compile Include="Models\Mouse\MouseData.cs" />
<Compile Include="Models\Mouse\MouseWatcher.cs" />
<Compile Include="Models\Mouse\PointData.cs" />
<Compile Include="Models\Options\AccelTypeOptions.cs" />
diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp
index 3108bda..0778bc3 100644
--- a/wrapper/wrapper.cpp
+++ b/wrapper/wrapper.cpp
@@ -22,6 +22,13 @@ public ref struct DriverInterop
public ref class ManagedAccel
{
mouse_modifier* const modifier_instance = new mouse_modifier();
+#ifdef RA_LOOKUP
+ si_pair* const lut_x = new si_pair[LUT_SIZE];
+ si_pair* const lut_y = new si_pair[LUT_SIZE];
+#else
+ si_pair* lut_x = nullptr;
+ si_pair* lut_y = nullptr;
+#endif
public:
static initonly double WriteDelay = -10000000 / -10000.0;
@@ -29,11 +36,15 @@ public:
virtual ~ManagedAccel()
{
delete modifier_instance;
+ delete[] lut_x;
+ delete[] lut_y;
}
!ManagedAccel()
{
delete modifier_instance;
+ delete[] lut_x;
+ delete[] lut_y;
}
Tuple<double, double>^ Accelerate(int x, int y, double time)
@@ -49,7 +60,10 @@ public:
void UpdateFromSettings(IntPtr argsIn)
{
- *modifier_instance = { *reinterpret_cast<settings*>(argsIn.ToPointer()) };
+ *modifier_instance = {
+ *reinterpret_cast<settings*>(argsIn.ToPointer())
+ , vec2<si_pair*>{ lut_x, lut_y }
+ };
}
static ManagedAccel^ GetActiveAccel()
@@ -58,7 +72,10 @@ public:
wrapper_io::readFromDriver(args);
auto active = gcnew ManagedAccel();
- *active->modifier_instance = { args };
+ *active->modifier_instance = {
+ args
+ , vec2<si_pair*> { active->lut_x, active->lut_y }
+ };
return active;
}
};