From 71bcfc11dea8c189152a9aa2534c87e1b1486018 Mon Sep 17 00:00:00 2001 From: ClxS Date: Mon, 7 Mar 2016 13:49:45 +0000 Subject: Partially completed events for gamepad input --- StardewModdingAPI/Events/Controls.cs | 15 ++++++++++++++- StardewModdingAPI/Events/EventArgs.cs | 24 +++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'StardewModdingAPI/Events') diff --git a/StardewModdingAPI/Events/Controls.cs b/StardewModdingAPI/Events/Controls.cs index 8cf0f431..fa344bab 100644 --- a/StardewModdingAPI/Events/Controls.cs +++ b/StardewModdingAPI/Events/Controls.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input; using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,8 @@ namespace StardewModdingAPI.Events 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 void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState) { @@ -33,5 +36,15 @@ namespace StardewModdingAPI.Events { 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)); + } } } diff --git a/StardewModdingAPI/Events/EventArgs.cs b/StardewModdingAPI/Events/EventArgs.cs index 66d057a7..6c5e1401 100644 --- a/StardewModdingAPI/Events/EventArgs.cs +++ b/StardewModdingAPI/Events/EventArgs.cs @@ -30,7 +30,29 @@ namespace StardewModdingAPI.Events } public Keys KeyPressed { get; private set; } } - + + public class EventArgsControllerButtonPressed : EventArgs + { + public EventArgsControllerButtonPressed(PlayerIndex playerIndex, Buttons buttonPressed) + { + PlayerIndex = playerIndex; + ButtonPressed = buttonPressed; + } + public PlayerIndex PlayerIndex; + public Buttons ButtonPressed { get; private set; } + } + + public class EventArgsControllerButtonReleased : EventArgs + { + public EventArgsControllerButtonReleased(PlayerIndex playerIndex, Buttons buttonReleased) + { + PlayerIndex = playerIndex; + ButtonReleased = buttonReleased; + } + public PlayerIndex PlayerIndex; + public Buttons ButtonReleased { get; private set; } + } + public class EventArgsMouseStateChanged : EventArgs { public EventArgsMouseStateChanged(MouseState priorState, MouseState newState) -- cgit