using System; using Microsoft.Xna.Framework.Input; namespace MLEM.Input { /// /// A set of extension methods for dealing with and /// public static class MouseExtensions { /// /// All enum values of /// public static readonly MouseButton[] MouseButtons = {MouseButton.Left, MouseButton.Middle, MouseButton.Right, MouseButton.Extra1, MouseButton.Extra2}; /// /// Returns the of the given mouse button. /// /// The mouse's current state /// The button whose state to query /// The state of the button /// If a mouse button out of range is passed public static ButtonState GetState(this MouseState state, MouseButton button) { switch (button) { case MouseButton.Left: return state.LeftButton; case MouseButton.Middle: return state.MiddleButton; case MouseButton.Right: return state.RightButton; case MouseButton.Extra1: return state.XButton1; case MouseButton.Extra2: return state.XButton2; default: throw new ArgumentException(nameof(button)); } } } /// /// This enum is a list of possible mouse buttons. /// It serves as a wrapper around 's button properties. /// public enum MouseButton { /// /// The left mouse button, or /// Left, /// /// The middle mouse button, or /// Middle, /// /// The right mouse button, or /// Right, /// /// The first extra mouse button, or /// Extra1, /// /// The second extra mouse button, or /// Extra2 } }