From 2ee9a7ba4e7445a4833a257e2c34c46a3471f043 Mon Sep 17 00:00:00 2001 From: Martiandweller Date: Fri, 31 Oct 2025 11:58:30 +0300 Subject: [PATCH 1/2] Expose OverrideButton. --- src/SMAPI/Framework/ModHelpers/InputHelper.cs | 6 ++++++ src/SMAPI/IInputHelper.cs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/SMAPI/Framework/ModHelpers/InputHelper.cs b/src/SMAPI/Framework/ModHelpers/InputHelper.cs index 8713cc483..c9cac9c1d 100644 --- a/src/SMAPI/Framework/ModHelpers/InputHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/InputHelper.cs @@ -85,4 +85,10 @@ public SButtonState GetState(SButton button) { return this.CurrentInputState().GetState(button); } + + /// + public void OverrideButton(SButton button, bool setDown) + { + this.CurrentInputState().OverrideButton(button, setDown); + } } diff --git a/src/SMAPI/IInputHelper.cs b/src/SMAPI/IInputHelper.cs index 053c371e4..dbcf13506 100644 --- a/src/SMAPI/IInputHelper.cs +++ b/src/SMAPI/IInputHelper.cs @@ -30,4 +30,9 @@ public interface IInputHelper : IModLinked /// Get the state of a button. /// The button to check. SButtonState GetState(SButton button); + + /// Override the state of a button. + /// The button to override. + /// A new button state. + void OverrideButton(SButton button, bool setDown); } From 5acfa914388a63e1a36dd993ec57869013e64012 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 28 Dec 2025 12:20:58 -0500 Subject: [PATCH 2/2] replace `OverrideButton` with `Press` to match existing API, expand docs --- src/SMAPI/Framework/ModHelpers/InputHelper.cs | 12 ++++++------ src/SMAPI/IInputHelper.cs | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/SMAPI/Framework/ModHelpers/InputHelper.cs b/src/SMAPI/Framework/ModHelpers/InputHelper.cs index c9cac9c1d..9f634f458 100644 --- a/src/SMAPI/Framework/ModHelpers/InputHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/InputHelper.cs @@ -46,6 +46,12 @@ public bool IsSuppressed(SButton button) return this.CurrentInputState().IsSuppressed(button); } + /// + public void Press(SButton button) + { + this.CurrentInputState().OverrideButton(button, setDown: true); + } + /// public void Suppress(SButton button) { @@ -85,10 +91,4 @@ public SButtonState GetState(SButton button) { return this.CurrentInputState().GetState(button); } - - /// - public void OverrideButton(SButton button, bool setDown) - { - this.CurrentInputState().OverrideButton(button, setDown); - } } diff --git a/src/SMAPI/IInputHelper.cs b/src/SMAPI/IInputHelper.cs index dbcf13506..fdcd383fa 100644 --- a/src/SMAPI/IInputHelper.cs +++ b/src/SMAPI/IInputHelper.cs @@ -16,8 +16,22 @@ public interface IInputHelper : IModLinked /// The button. bool IsSuppressed(SButton button); + /// Mark a button as pressed. + /// The button to press. + /// + /// For both mods and the base game, this is equivalent to the button being physically pressed by the player. It will be released on the next input tick by default; it can be pressed again each tick to hold it down. + /// + /// See for the inverse. + /// + void Press(SButton button); + /// Prevent the game from handling a button press. This doesn't prevent other mods from receiving the event. /// The button to suppress. + /// + /// If the button is being held, it'll remain suppressed until the player releases it or until is called for the same button. + /// + /// See for the inverse. + /// void Suppress(SButton button); /// Suppress the immediate change to a scroll wheel value. @@ -30,9 +44,4 @@ public interface IInputHelper : IModLinked /// Get the state of a button. /// The button to check. SButtonState GetState(SButton button); - - /// Override the state of a button. - /// The button to override. - /// A new button state. - void OverrideButton(SButton button, bool setDown); }