summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Input
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-11-30 17:12:49 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-11-30 17:12:49 -0500
commit919bbe94aa027c8a4ff8db4bdb50e8e2a28c48d9 (patch)
tree5c03ee1bd3cd658586755694940ac329491d6493 /src/SMAPI/Framework/Input
parent3ca6fb562417748c87567d6bb6915d56b2c1b57c (diff)
parentd1d09ae1df63826dd453aa0347d668f420754ed7 (diff)
downloadSMAPI-919bbe94aa027c8a4ff8db4bdb50e8e2a28c48d9.tar.gz
SMAPI-919bbe94aa027c8a4ff8db4bdb50e8e2a28c48d9.tar.bz2
SMAPI-919bbe94aa027c8a4ff8db4bdb50e8e2a28c48d9.zip
Merge branch 'beta' into develop
Diffstat (limited to 'src/SMAPI/Framework/Input')
-rw-r--r--src/SMAPI/Framework/Input/GamePadStateBuilder.cs19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/SMAPI/Framework/Input/GamePadStateBuilder.cs b/src/SMAPI/Framework/Input/GamePadStateBuilder.cs
index f5f2d916..b0bb7f80 100644
--- a/src/SMAPI/Framework/Input/GamePadStateBuilder.cs
+++ b/src/SMAPI/Framework/Input/GamePadStateBuilder.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
@@ -157,11 +158,8 @@ namespace StardewModdingAPI.Framework.Input
yield break;
// buttons
- foreach (var pair in this.ButtonStates)
- {
- if (pair.Value == ButtonState.Pressed && pair.Key.TryGetController(out Buttons button))
- yield return button.ToSButton();
- }
+ foreach (Buttons button in this.GetPressedGamePadButtons())
+ yield return button.ToSButton();
// triggers
if (this.LeftTrigger > 0.2f)
@@ -201,7 +199,7 @@ namespace StardewModdingAPI.Framework.Input
rightThumbStick: this.RightStickPos,
leftTrigger: this.LeftTrigger,
rightTrigger: this.RightTrigger,
- buttons: this.GetButtonBitmask() // MonoGame requires one bitmask here; don't specify multiple values
+ buttons: this.GetPressedGamePadButtons().ToArray()
);
return this.State.Value;
@@ -211,17 +209,14 @@ namespace StardewModdingAPI.Framework.Input
/*********
** Private methods
*********/
- /// <summary>Get a bitmask representing the pressed buttons.</summary>
- private Buttons GetButtonBitmask()
+ /// <summary>Get the pressed gamepad buttons.</summary>
+ private IEnumerable<Buttons> GetPressedGamePadButtons()
{
- Buttons flag = 0;
foreach (var pair in this.ButtonStates)
{
if (pair.Value == ButtonState.Pressed && pair.Key.TryGetController(out Buttons button))
- flag |= button;
+ yield return button;
}
-
- return flag;
}
}
}