summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grapher/Constants/Constants.cs6
-rw-r--r--grapher/Form1.Designer.cs1
-rw-r--r--grapher/Form1.cs9
-rw-r--r--grapher/Models/AccelGUI.cs40
-rw-r--r--wrapper/wrapper.cpp2
5 files changed, 50 insertions, 8 deletions
diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs
index 51cd0cb..d74d045 100644
--- a/grapher/Constants/Constants.cs
+++ b/grapher/Constants/Constants.cs
@@ -80,6 +80,12 @@ namespace grapher
/// <summary> Format string for default dropdowns. </summary>
public const string AccelDropDownDefaultShortText = "Accel Type";
+ /// <summary> Default text to be displayed on write button. </summary>
+ public const string WriteButtonDefaultText = "Write To Driver";
+
+ /// <summary> Default text to be displayed on write button. </summary>
+ public const string WriteButtonDelayText = "Delay";
+
/// <summary> Default name of settings file. </summary>
public const string DefaultSettingsFileName = @"settings.json";
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index 6ad2953..ad68b2c 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -330,7 +330,6 @@ namespace grapher
this.writeButton.TabIndex = 21;
this.writeButton.Text = "Write To Driver";
this.writeButton.UseVisualStyleBackColor = true;
- this.writeButton.Click += new System.EventHandler(this.writeButton_Click);
//
// sensitivityBoxY
//
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index 1bdb05c..65212d5 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -141,16 +141,11 @@ namespace grapher
}
- private void writeButton_Click(object sender, EventArgs e)
- {
- AccelGUI.UpdateActiveSettingsFromFields();
- }
-
- #endregion Methods
-
private void RawAcceleration_Paint(object sender, PaintEventArgs e)
{
AccelGUI.AccelCharts.DrawPoints();
}
+
+ #endregion Method
}
}
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 634aabf..a7fe5f9 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -35,6 +35,14 @@ namespace grapher
MouseWatcher = new MouseWatcher(AccelForm, mouseMoveLabel, AccelCharts);
ScaleMenuItem.Click += new System.EventHandler(OnScaleMenuItemClick);
+ WriteButton.Click += new System.EventHandler(OnWriteButtonClick);
+
+ ButtonTimer = new Timer();
+ ButtonTimer.Enabled = true;
+ ButtonTimer.Interval = Convert.ToInt32(ManagedAccel.WriteDelay);
+ ButtonTimer.Tick += new System.EventHandler(OnButtonTimerTick);
+
+ SetWriteButtonDefault();
}
#endregion Constructors
@@ -53,6 +61,8 @@ namespace grapher
public Button WriteButton { get; }
+ public Timer ButtonTimer { get; }
+
public MouseWatcher MouseWatcher { get; }
public ToolStripMenuItem ScaleMenuItem { get; }
@@ -81,6 +91,7 @@ namespace grapher
{
AccelForm.Invoke((MethodInvoker)delegate
{
+ WriteButtonDelay();
UpdateGraph();
});
});
@@ -113,6 +124,35 @@ namespace grapher
UpdateGraph();
}
+ private void OnWriteButtonClick(object sender, EventArgs e)
+ {
+ UpdateActiveSettingsFromFields();
+ }
+
+ private void OnButtonTimerTick(object sender, EventArgs e)
+ {
+ ButtonTimer.Stop();
+ SetWriteButtonDefault();
+ }
+
+ private void WriteButtonDelay()
+ {
+ SetWriteButtonDelay();
+ ButtonTimer.Start();
+ }
+
+ private void SetWriteButtonDefault()
+ {
+ WriteButton.Text = Constants.WriteButtonDefaultText;
+ WriteButton.Enabled = true;
+ }
+
+ private void SetWriteButtonDelay()
+ {
+ WriteButton.Enabled = false;
+ WriteButton.Text = $"{Constants.WriteButtonDelayText} : {ButtonTimer.Interval} ms";
+ }
+
#endregion Methods
}
diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp
index 757d3f1..3108bda 100644
--- a/wrapper/wrapper.cpp
+++ b/wrapper/wrapper.cpp
@@ -24,6 +24,8 @@ public ref class ManagedAccel
mouse_modifier* const modifier_instance = new mouse_modifier();
public:
+ static initonly double WriteDelay = -10000000 / -10000.0;
+
virtual ~ManagedAccel()
{
delete modifier_instance;