mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-06-21 07:37:49 +00:00
[Input] JoystickHatState is now IEquatable
This commit is contained in:
parent
01c3b51be6
commit
f93d464f62
|
@ -34,7 +34,7 @@ namespace OpenTK.Input
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Describes the state of a joystick hat.
|
/// Describes the state of a joystick hat.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct JoystickHatState
|
public struct JoystickHatState : IEquatable<JoystickHatState>
|
||||||
{
|
{
|
||||||
HatPosition position;
|
HatPosition position;
|
||||||
|
|
||||||
|
@ -113,6 +113,58 @@ namespace OpenTK.Input
|
||||||
Position == HatPosition.DownRight;
|
Position == HatPosition.DownRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.JoystickHatState"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.JoystickHatState"/>.</returns>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return String.Format(
|
||||||
|
"{{{0}{1}{2}{3}}}",
|
||||||
|
IsUp ? "U" : String.Empty,
|
||||||
|
IsLeft ? "L" : String.Empty,
|
||||||
|
IsDown ? "D" : String.Empty,
|
||||||
|
IsRight ? "R" : String.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Serves as a hash function for a <see cref="OpenTK.Input.JoystickHatState"/> object.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
|
||||||
|
/// hash table.</returns>
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return Position.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OpenTK.Input.JoystickHatState"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="OpenTK.Input.JoystickHatState"/>.</param>
|
||||||
|
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
|
||||||
|
/// <see cref="OpenTK.Input.JoystickHatState"/>; otherwise, <c>false</c>.</returns>
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
obj is JoystickHatState &&
|
||||||
|
Equals((JoystickHatState)obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IEquatable<JoystickHatState> implementation
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the specified <see cref="OpenTK.Input.JoystickHatState"/> is equal to the current <see cref="OpenTK.Input.JoystickHatState"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="other">The <see cref="OpenTK.Input.JoystickHatState"/> to compare with the current <see cref="OpenTK.Input.JoystickHatState"/>.</param>
|
||||||
|
/// <returns><c>true</c> if the specified <see cref="OpenTK.Input.JoystickHatState"/> is equal to the current
|
||||||
|
/// <see cref="OpenTK.Input.JoystickHatState"/>; otherwise, <c>false</c>.</returns>
|
||||||
|
public bool Equals(JoystickHatState other)
|
||||||
|
{
|
||||||
|
return Position == other.Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue