Skip to content

Commit 7f1054e

Browse files
committed
Added ability to customize the repeat output.
1 parent 927cc3b commit 7f1054e

File tree

6 files changed

+131
-110
lines changed

6 files changed

+131
-110
lines changed

Format/OutputConfig.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public enum MouseButton
7070
/// <summary>
7171
/// Constructor for an InputConfig
7272
/// </summary>
73-
/// <param name="byFlags">The flags defining the input</param>
73+
/// <param name="nFlags">The flags defining the input</param>
7474
/// <param name="byVirtualKey">The value of the input</param>
7575
/// <param name="eKeyArgs">The input key arguments from user input</param>
7676
public OutputConfig(int nFlags, byte byVirtualKey, int nParameter, KeyEventArgs eKeyArgs)
@@ -91,17 +91,17 @@ public OutputConfig(int nFlags, byte byVirtualKey, int nParameter, KeyEventArgs
9191
/// <summary>
9292
/// Constructor for an InputConfig
9393
/// </summary>
94-
/// <param name="byFlags">The flags defining the input</param>
94+
/// <param name="nFlags">The flags defining the input</param>
9595
/// <param name="byVirtualKey">The value of the input</param>
9696
/// <param name="nParameter"></param>
97-
public OutputConfig(byte byFlags, byte byVirtualKey, int nParameter) : this(byFlags, byVirtualKey, nParameter, null) { }
97+
public OutputConfig(int nFlags, byte byVirtualKey, int nParameter) : this(nFlags, byVirtualKey, nParameter, null) { }
9898

9999
/// <summary>
100100
/// Constructor for an InputConfig
101101
/// </summary>
102-
/// <param name="byFlags">The flags defining the input</param>
102+
/// <param name="nFlags">The flags defining the input</param>
103103
/// <param name="byVirtualKey">The value of the input</param>
104-
public OutputConfig(byte byFlags, byte byVirtualKey):this(byFlags, byVirtualKey, 0, null) { }
104+
public OutputConfig(int nFlags, byte byVirtualKey):this(nFlags, byVirtualKey, 0, null) { }
105105

106106
public OutputConfig(Stream zStream) : base(zStream) { }
107107

@@ -114,7 +114,7 @@ public override string GetDescription()
114114
// delay (every other flag ignored)
115115
if (IsFlaggedAs(OutputFlag.Delay))
116116
{
117-
return "[Delay: " + (int)Parameter + "]";
117+
return "[Delay({0}s)]".FormatString(Parameter);
118118
}
119119

120120
if (IsFlaggedAs(OutputFlag.MouseOut))
@@ -157,7 +157,9 @@ private string GetOutputDescriptionText(Enum eInputId, string sActionPrefix)
157157
(IsFlaggedAs(OutputFlag.Alt) ? "+Alt" : string.Empty) +
158158
(IsFlaggedAs(OutputFlag.Control) ? "+Control" : string.Empty) +
159159
(IsFlaggedAs(OutputFlag.Toggle) ? "+Toggle" : string.Empty) +
160-
(IsFlaggedAs(OutputFlag.Repeat) ? "+Repeat" : string.Empty) +
160+
(IsFlaggedAs(OutputFlag.Repeat) ? "+Repeat"
161+
+ (Parameter > 0 ? "({0}ms)".FormatString(Parameter) : "")
162+
: string.Empty) +
161163
"]";
162164
}
163165
}

Forms/KeyCaptureConfig.cs

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private void txtKeyIn_KeyDown(object sender, KeyEventArgs e)
190190
private void txtKeyOut_KeyDown(object sender, KeyEventArgs e)
191191
{
192192
// Console.Out.WriteLine("Key Input: {0} 0x{1}".FormatString(e.KeyCode, e.KeyCode.ToString("x")));
193-
UpdateTextBox((TextBox)sender, e, new OutputConfig(0x00, (byte)e.KeyCode, 0, e));
193+
UpdateTextBox((TextBox)sender, e, new OutputConfig(0, (byte)e.KeyCode, 0, e));
194194
}
195195

196196
private void UpdateTextBox<T>(TextBox txtBox, KeyEventArgs e, T config) where T : BaseIOConfig
@@ -321,7 +321,7 @@ private void comboBoxMouseOut_SelectedIndexChanged(object sender, EventArgs e)
321321
else
322322
{
323323
var zOutputConfig = new OutputConfig(
324-
(byte)OutputConfig.OutputFlag.MouseOut,
324+
(int)OutputConfig.OutputFlag.MouseOut,
325325
(byte)(OutputConfig.MouseButton)comboBoxOutMouse.SelectedItem);
326326
txtKeyOut.Text = zOutputConfig.GetDescription();
327327
txtKeyOut.Tag = zOutputConfig;
@@ -330,10 +330,22 @@ private void comboBoxMouseOut_SelectedIndexChanged(object sender, EventArgs e)
330330

331331
private void numericUpDownDelay_ValueChanged(object sender, EventArgs e)
332332
{
333+
var nFlag = 0;
334+
if (checkOutputDelay.Checked)
335+
{
336+
nFlag = (int) OutputConfig.OutputFlag.Delay;
337+
}
338+
// TODO: support other types that use the param this way...
339+
if (nFlag == 0)
340+
{
341+
return;
342+
}
343+
333344
var zOutputConfig = new OutputConfig(
334-
(byte)OutputConfig.OutputFlag.Delay,
345+
nFlag,
335346
0,
336-
(int)numericUpDownDelay.Value);
347+
(int) numericUpDownOutputParameter.Value);
348+
337349
var zDisplay = txtKeyOut;
338350
zDisplay.Text = zOutputConfig.GetDescription();
339351
zDisplay.Tag = zOutputConfig;
@@ -427,29 +439,38 @@ private void checkOutputToggle_CheckedChanged(object sender, EventArgs e)
427439
{
428440
checkOutputUp.Checked = checkOutputToggle.Checked;
429441
checkOutputDown.Checked = checkOutputToggle.Checked;
442+
430443
checkOutputUp.Enabled = !checkOutputToggle.Checked;
431444
checkOutputDown.Enabled = !checkOutputToggle.Checked;
445+
checkOutputRepeat.Enabled = !checkOutputToggle.Checked;
446+
checkOutputDelay.Enabled = !checkOutputToggle.Checked;
447+
checkOutputNothing.Enabled = !checkOutputToggle.Checked;
432448

433449
checkOutputAlt.Enabled = !checkOutputToggle.Checked;
434450
checkOutputShift.Enabled = !checkOutputToggle.Checked;
435451
checkOutputControl.Enabled = !checkOutputToggle.Checked;
436452
if (checkOutputToggle.Checked)
437453
{
438-
checkOutputAlt.Checked = false;
439-
checkOutputShift.Checked = false;
440-
checkOutputControl.Checked = false;
454+
checkOutputAlt.Checked =
455+
checkOutputShift.Checked =
456+
checkOutputControl.Checked =
457+
checkOutputRepeat.Checked =
458+
checkOutputDelay.Checked =
459+
checkOutputNothing.Checked = false;
441460
}
442461
}
443462

444463
private void checkOutputDoNothing_CheckedChanged(object sender, EventArgs e)
445464
{
446-
comboBoxOutMouse.Enabled = !checkOutputDoNothing.Checked;
447-
checkOutputAlt.Enabled = !checkOutputDoNothing.Checked;
448-
checkOutputShift.Enabled = !checkOutputDoNothing.Checked;
449-
checkOutputControl.Enabled = !checkOutputDoNothing.Checked;
450-
checkOutputUp.Enabled = !checkOutputDoNothing.Checked;
451-
checkOutputDown.Enabled = !checkOutputDoNothing.Checked;
452-
checkOutputToggle.Enabled = !checkOutputDoNothing.Checked;
465+
comboBoxOutMouse.Enabled =
466+
checkOutputAlt.Enabled =
467+
checkOutputShift.Enabled =
468+
checkOutputControl.Enabled =
469+
checkOutputUp.Enabled =
470+
checkOutputDown.Enabled =
471+
checkOutputToggle.Enabled =
472+
checkOutputDelay.Enabled =
473+
checkOutputRepeat.Enabled = !checkOutputNothing.Checked;
453474
}
454475

455476
#endregion
@@ -496,7 +517,7 @@ private OutputConfig UpdateOutputFlags(OutputConfig zOutputConfig)
496517
var bAlt = checkOutputAlt.Checked;
497518
var bControl = checkOutputControl.Checked;
498519
var bShift = checkOutputShift.Checked;
499-
var bNone = checkOutputDoNothing.Checked;
520+
var bNone = checkOutputNothing.Checked;
500521
var bToggle = checkOutputToggle.Checked;
501522
var bRepeat = checkOutputRepeat.Checked;
502523
var bDown = checkOutputDown.Checked;
@@ -515,6 +536,12 @@ private OutputConfig UpdateOutputFlags(OutputConfig zOutputConfig)
515536
nFlags = BitUtil.UpdateFlag(nFlags, bDown, OutputConfig.OutputFlag.Down);
516537
nFlags = BitUtil.UpdateFlag(nFlags, bUp, OutputConfig.OutputFlag.Up);
517538
zOutputConfig.Flags = nFlags;
539+
540+
if (bRepeat)
541+
{
542+
zOutputConfig.Parameter = (int)numericUpDownOutputParameter.Value;
543+
}
544+
518545
return zOutputConfig;
519546
}
520547

0 commit comments

Comments
 (0)