Skip to content

Commit

Permalink
Make UpdateInterval configurable via NohBoard.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ThoNohT committed Apr 7, 2020
1 parent c785d19 commit eafcac2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions NohBoard/Extra/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ namespace ThoNohT.NohBoard.Extra
[DataContract(Name = "GlobalSettings", Namespace = "")]
public partial class GlobalSettings
{
/// <summary>
/// Field for <see cref="UpdateInterval"/>.
/// </summary>
private int? updateInterval;

/// <summary>
/// Indicates whether there were changes made to the definition since the last save or load action.
/// Changes are tracked when undo history is pushed, and reset when a keyboard is loaded or saved.
Expand Down Expand Up @@ -106,6 +111,17 @@ public partial class GlobalSettings
[DataMember]
public int PressHold { get; set; }

/// <summary>
/// The time in milliseconds between which the keyboard is updated and rendered again.
/// Minimum: 5ms (200fps), maximum: 60s, default: 33ms (30fps).
/// </summary>
[DataMember]
public int UpdateInterval
{
get => this.updateInterval ?? 33;
set => this.updateInterval = Math.Max(5, Math.Min(60000, value));
}

#endregion Input

#region Trapping
Expand Down
1 change: 1 addition & 0 deletions NohBoard/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ private void MainForm_Load(object sender, EventArgs e)
HookManager.EnableKeyboardHook();
}

this.UpdateTimer.Interval = GlobalSettings.Settings.UpdateInterval;
this.UpdateTimer.Enabled = true;
this.KeyCheckTimer.Enabled = true;

Expand Down

0 comments on commit eafcac2

Please sign in to comment.