#region License /* FNA - XNA4 Reimplementation for Desktop Platforms * Copyright 2009-2016 Ethan Lee and the MonoGame Team * * Released under the Microsoft Public License. * See LICENSE for details. */ #endregion namespace Microsoft.Xna.Framework.Input { /// /// Represents a mouse state with cursor position and button press information. /// public struct MouseState { #region Public Properties /// /// Gets horizontal position of the cursor. /// public int X { get; internal set; } /// /// Gets vertical position of the cursor. /// public int Y { get; internal set; } /// /// Gets state of the left mouse button. /// public ButtonState LeftButton { get; internal set; } /// /// Gets state of the middle mouse button. /// public ButtonState MiddleButton { get; internal set; } /// /// Gets state of the right mouse button. /// public ButtonState RightButton { get; internal set; } /// /// Returns cumulative scroll wheel value since the game start. /// public int ScrollWheelValue { get; internal set; } /// /// Gets state of the XButton1. /// public ButtonState XButton1 { get; internal set; } /// /// Gets state of the XButton2. /// public ButtonState XButton2 { get; internal set; } #endregion #region Public Constructor /// /// Initializes a new instance of the MouseState. /// /// Horizontal position of the mouse. /// Vertical position of the mouse. /// Mouse scroll wheel's value. /// Left mouse button's state. /// Middle mouse button's state. /// Right mouse button's state. /// XBUTTON1's state. /// XBUTTON2's state. /// /// Normally should be used to get mouse current /// state. The constructor is provided for simulating mouse input. /// public MouseState ( int x, int y, int scrollWheel, ButtonState leftButton, ButtonState middleButton, ButtonState rightButton, ButtonState xButton1, ButtonState xButton2 ) : this() { X = x; Y = y; ScrollWheelValue = scrollWheel; LeftButton = leftButton; MiddleButton = middleButton; RightButton = rightButton; XButton1 = xButton1; XButton2 = xButton2; } #endregion #region Public Static Operators and Override Methods /// /// Compares whether two MouseState instances are equal. /// /// MouseState instance on the left of the equal sign. /// MouseState instance on the right of the equal sign. /// true if the instances are equal; false otherwise. public static bool operator ==(MouseState left, MouseState right) { return ( left.X == right.X && left.Y == right.Y && left.LeftButton == right.LeftButton && left.MiddleButton == right.MiddleButton && left.RightButton == right.RightButton && left.ScrollWheelValue == right.ScrollWheelValue ); } /// /// Compares whether two MouseState instances are not equal. /// /// MouseState instance on the left of the equal sign. /// MouseState instance on the right of the equal sign. /// true if the objects are not equal; false otherwise. public static bool operator !=(MouseState left, MouseState right) { return !(left == right); } /// /// Compares whether current instance is equal to specified object. /// /// The MouseState to compare. /// public override bool Equals(object obj) { return (obj is MouseState) && (this == (MouseState) obj); } /// /// Gets the hash code for MouseState instance. /// /// Hash code of the object. public override int GetHashCode() { return base.GetHashCode(); } #endregion } }