using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; namespace StardewModdingAPI.Events { public static class ControlEvents { public static event EventHandler KeyboardChanged = delegate { }; public static event EventHandler KeyPressed = delegate { }; public static event EventHandler KeyReleased = delegate { }; public static event EventHandler MouseChanged = delegate { }; public static event EventHandler ControllerButtonPressed = delegate { }; public static event EventHandler ControllerButtonReleased = delegate { }; public static event EventHandler ControllerTriggerPressed = delegate { }; public static event EventHandler ControllerTriggerReleased = delegate { }; public static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState) { KeyboardChanged.Invoke(null, new EventArgsKeyboardStateChanged(priorState, newState)); } public static void InvokeMouseChanged(MouseState priorState, MouseState newState) { MouseChanged.Invoke(null, new EventArgsMouseStateChanged(priorState, newState)); } public static void InvokeKeyPressed(Keys key) { KeyPressed.Invoke(null, new EventArgsKeyPressed(key)); } public static void InvokeKeyReleased(Keys key) { KeyReleased.Invoke(null, new EventArgsKeyPressed(key)); } public static void InvokeButtonPressed(PlayerIndex playerIndex, Buttons buttons) { ControllerButtonPressed.Invoke(null, new EventArgsControllerButtonPressed(playerIndex, buttons)); } public static void InvokeButtonReleased(PlayerIndex playerIndex, Buttons buttons) { ControllerButtonReleased.Invoke(null, new EventArgsControllerButtonReleased(playerIndex, buttons)); } public static void InvokeTriggerPressed(PlayerIndex playerIndex, Buttons buttons, float value) { ControllerTriggerPressed.Invoke(null, new EventArgsControllerTriggerPressed(playerIndex, buttons, value)); } public static void InvokeTriggerReleased(PlayerIndex playerIndex, Buttons buttons, float value) { ControllerTriggerReleased.Invoke(null, new EventArgsControllerTriggerReleased(playerIndex, buttons, value)); } } }