summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModHelpers/InputHelper.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-12-21 12:25:27 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-12-21 12:25:27 -0500
commit71284e7176c55f66754470b19fd74b5b1fda4964 (patch)
tree848a7ec8c99e0e1f8335fac41f9e417dc1c86e40 /src/SMAPI/Framework/ModHelpers/InputHelper.cs
parent85b947dced10f5398055af36b5fdb6b8d32a6a6b (diff)
parent872a1d5627f20faece618644db1ae4749e124741 (diff)
downloadSMAPI-71284e7176c55f66754470b19fd74b5b1fda4964.tar.gz
SMAPI-71284e7176c55f66754470b19fd74b5b1fda4964.tar.bz2
SMAPI-71284e7176c55f66754470b19fd74b5b1fda4964.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/ModHelpers/InputHelper.cs')
-rw-r--r--src/SMAPI/Framework/ModHelpers/InputHelper.cs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/InputHelper.cs b/src/SMAPI/Framework/ModHelpers/InputHelper.cs
index 09ce3c65..e1317544 100644
--- a/src/SMAPI/Framework/ModHelpers/InputHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/InputHelper.cs
@@ -1,3 +1,4 @@
+using System;
using StardewModdingAPI.Framework.Input;
namespace StardewModdingAPI.Framework.ModHelpers
@@ -8,8 +9,8 @@ namespace StardewModdingAPI.Framework.ModHelpers
/*********
** Accessors
*********/
- /// <summary>Manages the game's input state.</summary>
- private readonly SInputState InputState;
+ /// <summary>Manages the game's input state for the current player instance. That may not be the main player in split-screen mode.</summary>
+ private readonly Func<SInputState> CurrentInputState;
/*********
@@ -17,41 +18,41 @@ namespace StardewModdingAPI.Framework.ModHelpers
*********/
/// <summary>Construct an instance.</summary>
/// <param name="modID">The unique ID of the relevant mod.</param>
- /// <param name="inputState">Manages the game's input state.</param>
- public InputHelper(string modID, SInputState inputState)
+ /// <param name="currentInputState">Manages the game's input state for the current player instance. That may not be the main player in split-screen mode.</param>
+ public InputHelper(string modID, Func<SInputState> currentInputState)
: base(modID)
{
- this.InputState = inputState;
+ this.CurrentInputState = currentInputState;
}
/// <inheritdoc />
public ICursorPosition GetCursorPosition()
{
- return this.InputState.CursorPosition;
+ return this.CurrentInputState().CursorPosition;
}
/// <inheritdoc />
public bool IsDown(SButton button)
{
- return this.InputState.IsDown(button);
+ return this.CurrentInputState().IsDown(button);
}
/// <inheritdoc />
public bool IsSuppressed(SButton button)
{
- return this.InputState.IsSuppressed(button);
+ return this.CurrentInputState().IsSuppressed(button);
}
/// <inheritdoc />
public void Suppress(SButton button)
{
- this.InputState.OverrideButton(button, setDown: false);
+ this.CurrentInputState().OverrideButton(button, setDown: false);
}
/// <inheritdoc />
public SButtonState GetState(SButton button)
{
- return this.InputState.GetState(button);
+ return this.CurrentInputState().GetState(button);
}
}
}