#if !SMAPI_3_0_STRICT using System; using Microsoft.Xna.Framework.Input; using StardewModdingAPI.Framework; using StardewModdingAPI.Framework.Events; namespace StardewModdingAPI.Events { /// Events raised when the player uses a controller, keyboard, or mouse. [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")] public static class ControlEvents { /********* ** Properties *********/ /// The core event manager. private static EventManager EventManager; /// Manages deprecation warnings. private static DeprecationManager DeprecationManager; /********* ** Events *********/ /// Raised when the changes. That happens when the player presses or releases a key. public static event EventHandler KeyboardChanged { add { ControlEvents.DeprecationManager.WarnForOldEvents(); ControlEvents.EventManager.Legacy_KeyboardChanged.Add(value); } remove => ControlEvents.EventManager.Legacy_KeyboardChanged.Remove(value); } /// Raised after the player presses a keyboard key. public static event EventHandler KeyPressed { add { ControlEvents.DeprecationManager.WarnForOldEvents(); ControlEvents.EventManager.Legacy_KeyPressed.Add(value); } remove => ControlEvents.EventManager.Legacy_KeyPressed.Remove(value); } /// Raised after the player releases a keyboard key. public static event EventHandler KeyReleased { add { ControlEvents.DeprecationManager.WarnForOldEvents(); ControlEvents.EventManager.Legacy_KeyReleased.Add(value); } remove => ControlEvents.EventManager.Legacy_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.DeprecationManager.WarnForOldEvents(); ControlEvents.EventManager.Legacy_MouseChanged.Add(value); } remove => ControlEvents.EventManager.Legacy_MouseChanged.Remove(value); } /// The player pressed a controller button. This event isn't raised for trigger buttons. public static event EventHandler ControllerButtonPressed { add { ControlEvents.DeprecationManager.WarnForOldEvents(); ControlEvents.EventManager.Legacy_ControllerButtonPressed.Add(value); } remove => ControlEvents.EventManager.Legacy_ControllerButtonPressed.Remove(value); } /// The player released a controller button. This event isn't raised for trigger buttons. public static event EventHandler ControllerButtonReleased { add { ControlEvents.DeprecationManager.WarnForOldEvents(); ControlEvents.EventManager.Legacy_ControllerButtonReleased.Add(value); } remove => ControlEvents.EventManager.Legacy_ControllerButtonReleased.Remove(value); } /// The player pressed a controller trigger button. public static event EventHandler ControllerTriggerPressed { add { ControlEvents.DeprecationManager.WarnForOldEvents(); ControlEvents.EventManager.Legacy_ControllerTriggerPressed.Add(value); } remove => ControlEvents.EventManager.Legacy_ControllerTriggerPressed.Remove(value); } /// The player released a controller trigger button. public static event EventHandler ControllerTriggerReleased { add { ControlEvents.DeprecationManager.WarnForOldEvents(); ControlEvents.EventManager.Legacy_ControllerTriggerReleased.Add(value); } remove => ControlEvents.EventManager.Legacy_ControllerTriggerReleased.Remove(value); } /********* ** Public methods *********/ /// Initialise the events. /// The core event manager. /// Manages deprecation warnings. internal static void Init(EventManager eventManager, DeprecationManager deprecationManager) { ControlEvents.EventManager = eventManager; ControlEvents.DeprecationManager = deprecationManager; } } } #endif