using System;
using StardewModdingAPI.Framework;
using StardewModdingAPI.Utilities;
namespace StardewModdingAPI.Events
{
/// Events raised when the player uses a controller, keyboard, or mouse button.
public static class InputEvents
{
/*********
** Events
*********/
/// Raised when the player presses a button on the keyboard, controller, or mouse.
public static event EventHandler ButtonPressed;
/// Raised when the player releases a keyboard key on the keyboard, controller, or mouse.
public static event EventHandler ButtonReleased;
/*********
** Internal methods
*********/
/// Raise a event.
/// Encapsulates monitoring and logging.
/// The button on the controller, keyboard, or mouse.
/// The cursor position.
/// Whether the input is considered a 'click' by the game for enabling action.
internal static void InvokeButtonPressed(IMonitor monitor, SButton button, ICursorPosition cursor, bool isClick)
{
monitor.SafelyRaiseGenericEvent($"{nameof(InputEvents)}.{nameof(InputEvents.ButtonPressed)}", InputEvents.ButtonPressed?.GetInvocationList(), null, new EventArgsInput(button, cursor, isClick));
}
/// Raise a event.
/// Encapsulates monitoring and logging.
/// The button on the controller, keyboard, or mouse.
/// The cursor position.
/// Whether the input is considered a 'click' by the game for enabling action.
internal static void InvokeButtonReleased(IMonitor monitor, SButton button, ICursorPosition cursor, bool isClick)
{
monitor.SafelyRaiseGenericEvent($"{nameof(InputEvents)}.{nameof(InputEvents.ButtonReleased)}", InputEvents.ButtonReleased?.GetInvocationList(), null, new EventArgsInput(button, cursor, isClick));
}
}
}