using System; using Microsoft.Xna.Framework.Input; using StardewModdingAPI.Framework.Events; namespace StardewModdingAPI.Events { /// Events raised when the player uses a controller, keyboard, or mouse. public static class ControlEvents { /********* ** Properties *********/ /// The core event manager. private static EventManager EventManager; /********* ** Events *********/ /// Raised when the changes. That happens when the player presses or releases a key. public static event EventHandler KeyboardChanged { add => ControlEvents.EventManager.Legacy_Control_KeyboardChanged.Add(value); remove => ControlEvents.EventManager.Legacy_Control_KeyboardChanged.Remove(value); } /// Raised after the player presses a keyboard key. public static event EventHandler KeyPressed { add => ControlEvents.EventManager.Legacy_Control_KeyPressed.Add(value); remove => ControlEvents.EventManager.Legacy_Control_KeyPressed.Remove(value); } /// Raised after the player releases a keyboard key. public static event EventHandler KeyReleased { add => ControlEvents.EventManager.Legacy_Control_KeyReleased.Add(value); remove => ControlEvents.EventManager.Legacy_Control_KeyReleased.Remove(value); } /// Raised when the changes. That happens when the player moves the mouse, scrolls the mouse wheel, or presses/releases a button. public static event EventHandler MouseChanged { add => ControlEvents.EventManager.Legacy_Control_MouseChanged.Add(value); remove => ControlEvents.EventManager.Legacy_Control_MouseChanged.Remove(value); } /// The player pressed a controller button. This event isn't raised for trigger buttons. public static event EventHandler ControllerButtonPressed { add => ControlEvents.EventManager.Legacy_Control_ControllerButtonPressed.Add(value); remove => ControlEvents.EventManager.Legacy_Control_ControllerButtonPressed.Remove(value); } /// The player released a controller button. This event isn't raised for trigger buttons. public static event EventHandler ControllerButtonReleased { add => ControlEvents.EventManager.Legacy_Control_ControllerButtonReleased.Add(value); remove => ControlEvents.EventManager.Legacy_Control_ControllerButtonReleased.Remove(value); } /// The player pressed a controller trigger button. public static event EventHandler ControllerTriggerPressed { add => ControlEvents.EventManager.Legacy_Control_ControllerTriggerPressed.Add(value); remove => ControlEvents.EventManager.Legacy_Control_ControllerTriggerPressed.Remove(value); } /// The player released a controller trigger button. public static event EventHandler ControllerTriggerReleased { add => ControlEvents.EventManager.Legacy_Control_ControllerTriggerReleased.Add(value); remove => ControlEvents.EventManager.Legacy_Control_ControllerTriggerReleased.Remove(value); } /********* ** Public methods *********/ /// Initialise the events. /// The core event manager. internal static void Init(EventManager eventManager) { ControlEvents.EventManager = eventManager; } } }