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.SuppressButtons.Contains(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.SuppressButtons.Add(button); } /// Get the status of a button. /// The button to check. public InputStatus GetStatus(SButton button) { return this.InputState.GetStatus(button); } } }