summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--StardewModdingAPI/Events/Controls.cs6
-rw-r--r--StardewModdingAPI/Inheritance/SGame.cs10
2 files changed, 15 insertions, 1 deletions
diff --git a/StardewModdingAPI/Events/Controls.cs b/StardewModdingAPI/Events/Controls.cs
index ace890ca..8cf0f431 100644
--- a/StardewModdingAPI/Events/Controls.cs
+++ b/StardewModdingAPI/Events/Controls.cs
@@ -11,6 +11,7 @@ namespace StardewModdingAPI.Events
{
public static event EventHandler<EventArgsKeyboardStateChanged> KeyboardChanged = delegate { };
public static event EventHandler<EventArgsKeyPressed> KeyPressed = delegate { };
+ public static event EventHandler<EventArgsKeyPressed> KeyReleased = delegate { };
public static event EventHandler<EventArgsMouseStateChanged> MouseChanged = delegate { };
public static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState)
@@ -27,5 +28,10 @@ namespace StardewModdingAPI.Events
{
KeyPressed.Invoke(null, new EventArgsKeyPressed(key));
}
+
+ public static void InvokeKeyReleased(Keys key)
+ {
+ KeyReleased.Invoke(null, new EventArgsKeyPressed(key));
+ }
}
}
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs
index c7b07c43..120f4a6e 100644
--- a/StardewModdingAPI/Inheritance/SGame.cs
+++ b/StardewModdingAPI/Inheritance/SGame.cs
@@ -43,6 +43,10 @@ namespace StardewModdingAPI.Inheritance
{
get { return CurrentlyPressedKeys.Where(x => !PreviouslyPressedKeys.Contains(x)).ToArray(); }
}
+ public Keys[] FrameReleasedKeys
+ {
+ get { return PreviouslyPressedKeys.Where(x => !CurrentlyPressedKeys.Contains(x)).ToArray(); }
+ }
public int PreviousGameLocations { get; private set; }
public int PreviousLocationObjects { get; private set; }
@@ -233,11 +237,15 @@ namespace StardewModdingAPI.Inheritance
{
KStateNow = Keyboard.GetState();
CurrentlyPressedKeys = KStateNow.GetPressedKeys();
+
MStateNow = Mouse.GetState();
foreach (Keys k in FramePressedKeys)
Events.ControlEvents.InvokeKeyPressed(k);
-
+
+ foreach (Keys k in FrameReleasedKeys)
+ Events.ControlEvents.InvokeKeyReleased(k);
+
if (KStateNow != KStatePrior)
{
Events.ControlEvents.InvokeKeyboardChanged(KStatePrior, KStateNow);