blob: f8ff03555428b1de70cd34ec421974c1f2ede594 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
using StardewModdingAPI.Framework.Input;
namespace StardewModdingAPI.Framework.ModHelpers
{
/// <summary>Provides an API for checking and changing input state.</summary>
internal class InputHelper : BaseHelper, IInputHelper
{
/*********
** Accessors
*********/
/// <summary>Manages the game's input state.</summary>
private readonly SInputState InputState;
/*********
** Public methods
*********/
/// <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)
: base(modID)
{
this.InputState = inputState;
}
/// <summary>Get the current cursor position.</summary>
public ICursorPosition GetCursorPosition()
{
return this.InputState.CursorPosition;
}
/// <summary>Get whether a button is currently pressed.</summary>
/// <param name="button">The button.</param>
public bool IsDown(SButton button)
{
return this.InputState.IsDown(button);
}
/// <summary>Get whether a button is currently suppressed, so the game won't see it.</summary>
/// <param name="button">The button.</param>
public bool IsSuppressed(SButton button)
{
return this.InputState.SuppressButtons.Contains(button);
}
/// <summary>Prevent the game from handling a button press. This doesn't prevent other mods from receiving the event.</summary>
/// <param name="button">The button to suppress.</param>
public void Suppress(SButton button)
{
this.InputState.SuppressButtons.Add(button);
}
/// <summary>Get the state of a button.</summary>
/// <param name="button">The button to check.</param>
public SButtonState GetState(SButton button)
{
return this.InputState.GetState(button);
}
}
}
|