using StardewModdingAPI.Framework.Input;
namespace StardewModdingAPI.Framework.ModHelpers
{
/// Provides an API for checking and changing input state.
internal class InputHelper : BaseHelper, IInputHelper
{
/*********
** Accessors
*********/
/// Manages the game's input state.
private readonly SInputState InputState;
/*********
** Public methods
*********/
/// Construct an instance.
/// The unique ID of the relevant mod.
/// Manages the game's input state.
public InputHelper(string modID, SInputState inputState)
: base(modID)
{
this.InputState = inputState;
}
/// Get the current cursor position.
public ICursorPosition GetCursorPosition()
{
return this.InputState.CursorPosition;
}
/// Get whether a button is currently pressed.
/// The button.
public bool IsDown(SButton button)
{
return this.InputState.IsDown(button);
}
/// Get whether a button is currently suppressed, so the game won't see it.
/// The button.
public bool IsSuppressed(SButton button)
{
return this.InputState.IsSuppressed(button);
}
/// Prevent the game from handling a button press. This doesn't prevent other mods from receiving the event.
/// The button to suppress.
public void Suppress(SButton button)
{
this.InputState.OverrideButton(button, setDown: false);
}
/// Get the state of a button.
/// The button to check.
public SButtonState GetState(SButton button)
{
return this.InputState.GetState(button);
}
}
}