diff --git a/docs/release-notes.md b/docs/release-notes.md
index 6674f8bd..3aca6f9b 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -10,6 +10,7 @@
## Upcoming release
* For players:
* In multiplayer, the game/SMAPI window titles now show whether you're the main player or a farmhand.
+ * The `test_input` console command now logs player input until the command is run again, instead of only 30 seconds.
* Fixed wezterm terminal support on Linux/macoS (thanks to romangraef!).
* Fixed logged SMAPI errors not having line numbers on Linux/macOS.
* Fixed install error if a game folder has an invalid symlink.
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs
index 8bf9f5db..67325c7c 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/TestInputCommand.cs
@@ -1,4 +1,3 @@
-using System;
using System.Diagnostics.CodeAnalysis;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
@@ -10,11 +9,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
/*********
** Fields
*********/
- /// The number of seconds for which to log input.
- private readonly int LogSeconds = 30;
-
- /// When the command should stop printing input, or null if currently disabled.
- private long? ExpiryTicks;
+ /// Whether the command should print input.
+ private bool Enabled;
/*********
@@ -30,21 +26,12 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
/// The command arguments.
public override void Handle(IMonitor monitor, string command, ArgumentParser args)
{
- this.ExpiryTicks = DateTime.UtcNow.Add(TimeSpan.FromSeconds(this.LogSeconds)).Ticks;
- monitor.Log($"OK, logging all player input for {this.LogSeconds} seconds.", LogLevel.Info);
- }
+ this.Enabled = !this.Enabled;
- /// Perform any logic needed on update tick.
- /// Writes messages to the console and log file.
- public override void OnUpdated(IMonitor monitor)
- {
- // handle expiry
- if (this.ExpiryTicks != null && this.ExpiryTicks <= DateTime.UtcNow.Ticks)
- {
- monitor.Log("No longer logging input.", LogLevel.Info);
- this.ExpiryTicks = null;
- return;
- }
+ monitor.Log(
+ this.Enabled ? "OK, logging all player input until you run this command again." : "OK, no longer logging player input.",
+ LogLevel.Info
+ );
}
/// Perform any logic when input is received.
@@ -52,7 +39,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
/// The button that was pressed.
public override void OnButtonPressed(IMonitor monitor, SButton button)
{
- if (this.ExpiryTicks != null)
+ if (this.Enabled)
monitor.Log($"Pressed {button}", LogLevel.Info);
}
}