mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 08:45:37 +00:00
[Input] Documented all public members
This commit is contained in:
parent
b35aad1503
commit
3095afa18a
|
@ -28,7 +28,7 @@ using System;
|
|||
namespace OpenTK.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumerates available buttons for a canonical <c>GamePad</c> device.
|
||||
/// Enumerates available buttons for a <c>GamePad</c> device.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum Buttons
|
||||
|
|
|
@ -1,29 +1,31 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
#region License
|
||||
//
|
||||
// GamePadButtons.cs
|
||||
//
|
||||
// Author:
|
||||
// Stefanos A. <stapostol@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2006-2014 Stefanos Apostolopoulos
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -31,6 +33,14 @@ namespace OpenTK.Input
|
|||
{
|
||||
/// <summary>
|
||||
/// Provides access to GamePad devices.
|
||||
/// A GamePad device offers a well-defined layout with
|
||||
/// one direction-pad, two thumbsticks, two triggers,
|
||||
/// four main buttons (A, B, X, Y) and up to seven
|
||||
/// auxilliary buttons.
|
||||
/// Use <c>GetCapabilities</c> to retrieve the exact
|
||||
/// capabilities of a given device.
|
||||
/// Use <c>GetState</c> to retrieve the current state
|
||||
/// of a given device.
|
||||
/// </summary>
|
||||
public sealed class GamePad
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// #region License
|
||||
#region License
|
||||
//
|
||||
// GamePadButtons.cs
|
||||
//
|
||||
// Author:
|
||||
// Stefanos A. <stapostol@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2006-2013 Stefanos Apostolopoulos
|
||||
// Copyright (c) 2006-2014 Stefanos Apostolopoulos
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,16 +25,23 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
// #endregion
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenTK.Input
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Describes the <see cref="ButtonState"/> of <see cref="GamePad"/> <see cref="Buttons"/>.
|
||||
/// </summary>
|
||||
public struct GamePadButtons : IEquatable<GamePadButtons>
|
||||
{
|
||||
Buttons buttons;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="OpenTK.Input.GamePadButtons"/> structure.
|
||||
/// </summary>
|
||||
/// <param name="state">A bitmask containing the button state.</param>
|
||||
public GamePadButtons(Buttons state)
|
||||
{
|
||||
buttons = state;
|
||||
|
@ -42,81 +49,136 @@ namespace OpenTK.Input
|
|||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the A button.
|
||||
/// </summary>
|
||||
public ButtonState A
|
||||
{
|
||||
get { return GetButton(Buttons.A); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the B button.
|
||||
/// </summary>
|
||||
public ButtonState B
|
||||
{
|
||||
get { return GetButton(Buttons.B); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the X button.
|
||||
/// </summary>
|
||||
public ButtonState X
|
||||
{
|
||||
get { return GetButton(Buttons.X); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the Y button.
|
||||
/// </summary>
|
||||
public ButtonState Y
|
||||
{
|
||||
get { return GetButton(Buttons.Y); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the Back button.
|
||||
/// </summary>
|
||||
public ButtonState Back
|
||||
{
|
||||
get { return GetButton(Buttons.Back); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the big button.
|
||||
/// This button is also known as Home or Guide.
|
||||
/// </summary>
|
||||
public ButtonState BigButton
|
||||
{
|
||||
get { return GetButton(Buttons.BigButton); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the left shoulder button.
|
||||
/// </summary>
|
||||
public ButtonState LeftShoulder
|
||||
{
|
||||
get { return GetButton(Buttons.LeftShoulder); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the left stick button.
|
||||
/// This button represents a left stick that is pressed in.
|
||||
/// </summary>
|
||||
public ButtonState LeftStick
|
||||
{
|
||||
get { return GetButton(Buttons.LeftStick); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the right shoulder button.
|
||||
/// </summary>
|
||||
public ButtonState RightShoulder
|
||||
{
|
||||
get { return GetButton(Buttons.RightShoulder); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the right stick button.
|
||||
/// This button represents a right stick that is pressed in.
|
||||
/// </summary>
|
||||
public ButtonState RightStick
|
||||
{
|
||||
get { return GetButton(Buttons.RightStick); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the starth button.
|
||||
/// </summary>
|
||||
public ButtonState Start
|
||||
{
|
||||
get { return GetButton(Buttons.Start); }
|
||||
}
|
||||
|
||||
/// <param name="left">A <see cref="GamePadButtons"/> instance to test for equality.</param>
|
||||
/// <param name="right">A <see cref="GamePadButtons"/> instance to test for equality.</param>
|
||||
public static bool operator ==(GamePadButtons left, GamePadButtons right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <param name="left">A <see cref="GamePadButtons"/> instance to test for inequality.</param>
|
||||
/// <param name="right">A <see cref="GamePadButtons"/> instance to test for inequality.</param>
|
||||
public static bool operator !=(GamePadButtons left, GamePadButtons right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadButtons"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadButtons"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Convert.ToString((int)buttons, 2).PadLeft(10, '0');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a hash function for a <see cref="OpenTK.Input.GamePadButtons"/> 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 buttons.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OpenTK.Input.GamePadButtons"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="OpenTK.Input.GamePadButtons"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadButtons"/>; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return
|
||||
|
@ -128,6 +190,12 @@ namespace OpenTK.Input
|
|||
|
||||
#region IEquatable<GamePadButtons> Members
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="OpenTK.Input.GamePadButtons"/> is equal to the current <see cref="OpenTK.Input.GamePadButtons"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="OpenTK.Input.GamePadButtons"/> to compare with the current <see cref="OpenTK.Input.GamePadButtons"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="OpenTK.Input.GamePadButtons"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadButtons"/>; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(GamePadButtons other)
|
||||
{
|
||||
return buttons == other.buttons;
|
||||
|
|
|
@ -31,7 +31,9 @@ using System;
|
|||
|
||||
namespace OpenTK.Input
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Describes the state of a <see cref="GamePad"/> directional pad.
|
||||
/// </summary>
|
||||
public struct GamePadDPad : IEquatable<GamePadDPad>
|
||||
{
|
||||
[Flags]
|
||||
|
@ -45,7 +47,7 @@ namespace OpenTK.Input
|
|||
|
||||
DPadButtons buttons;
|
||||
|
||||
#region Public Members
|
||||
#region Internal Members
|
||||
|
||||
internal GamePadDPad(Buttons state)
|
||||
{
|
||||
|
@ -54,40 +56,104 @@ namespace OpenTK.Input
|
|||
buttons = (DPadButtons)((int)state & 0x0f);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the up button.
|
||||
/// </summary>
|
||||
/// <value><c>ButtonState.Pressed</c> if the up button is pressed; otherwise, <c>ButtonState.Released</c>.</value>
|
||||
public ButtonState Up
|
||||
{
|
||||
get { return IsUp ? ButtonState.Pressed : ButtonState.Released; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the down button.
|
||||
/// </summary>
|
||||
/// <value><c>ButtonState.Pressed</c> if the down button is pressed; otherwise, <c>ButtonState.Released</c>.</value>
|
||||
public ButtonState Down
|
||||
{
|
||||
get { return IsDown ? ButtonState.Pressed : ButtonState.Released; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the left button.
|
||||
/// </summary>
|
||||
/// <value><c>ButtonState.Pressed</c> if the left button is pressed; otherwise, <c>ButtonState.Released</c>.</value>
|
||||
public ButtonState Left
|
||||
{
|
||||
get { return IsLeft ? ButtonState.Pressed : ButtonState.Released; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ButtonState"/> for the right button.
|
||||
/// </summary>
|
||||
/// <value><c>ButtonState.Pressed</c> if the right button is pressed; otherwise, <c>ButtonState.Released</c>.</value>
|
||||
public ButtonState Right
|
||||
{
|
||||
get { return IsRight ? ButtonState.Pressed : ButtonState.Released; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the up button is pressed.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if the up button is pressed; otherwise, <c>false</c>.</value>
|
||||
public bool IsUp
|
||||
{
|
||||
get { return (buttons & DPadButtons.Up) != 0; }
|
||||
internal set { SetButton(DPadButtons.Up, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the down button is pressed.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if the down button is pressed; otherwise, <c>false</c>.</value>
|
||||
public bool IsDown
|
||||
{
|
||||
get { return (buttons & DPadButtons.Down) != 0; }
|
||||
internal set { SetButton(DPadButtons.Down, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the left button is pressed.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if the left button is pressed; otherwise, <c>false</c>.</value>
|
||||
public bool IsLeft
|
||||
{
|
||||
get { return (buttons & DPadButtons.Left) != 0; }
|
||||
internal set { SetButton(DPadButtons.Left, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the right button is pressed.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if the right button is pressed; otherwise, <c>false</c>.</value>
|
||||
public bool IsRight
|
||||
{
|
||||
get { return (buttons & DPadButtons.Right) != 0; }
|
||||
internal set { SetButton(DPadButtons.Right, value); }
|
||||
}
|
||||
|
||||
/// <param name="left">A <see cref="GamePadDPad"/> instance to test for equality.</param>
|
||||
/// <param name="right">A <see cref="GamePadDPad"/> instance to test for equality.</param>
|
||||
public static bool operator ==(GamePadDPad left, GamePadDPad right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <param name="left">A <see cref="GamePadDPad"/> instance to test for inequality.</param>
|
||||
/// <param name="right">A <see cref="GamePadDPad"/> instance to test for inequality.</param>
|
||||
public static bool operator !=(GamePadDPad left, GamePadDPad right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadDPad"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadDPad"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format(
|
||||
|
@ -98,11 +164,22 @@ namespace OpenTK.Input
|
|||
IsRight ? "R" : String.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a hash function for a <see cref="OpenTK.Input.GamePadDPad"/> 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 buttons.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OpenTK.Input.GamePadDPad"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="OpenTK.Input.GamePadDPad"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadDPad"/>; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return
|
||||
|
@ -130,6 +207,12 @@ namespace OpenTK.Input
|
|||
|
||||
#region IEquatable<GamePadDPad> Members
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="OpenTK.Input.GamePadDPad"/> is equal to the current <see cref="OpenTK.Input.GamePadDPad"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="OpenTK.Input.GamePadDPad"/> to compare with the current <see cref="OpenTK.Input.GamePadDPad"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="OpenTK.Input.GamePadDPad"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadDPad"/>; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(GamePadDPad other)
|
||||
{
|
||||
return buttons == other.buttons;
|
||||
|
|
|
@ -30,7 +30,7 @@ using System;
|
|||
namespace OpenTK.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Encapsulates the state of a GamePad device.
|
||||
/// Describes the current state of a <see cref="GamePad"/> device.
|
||||
/// </summary>
|
||||
public struct GamePadState : IEquatable<GamePadState>
|
||||
{
|
||||
|
@ -48,36 +48,65 @@ namespace OpenTK.Input
|
|||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="GamePadThumbSticks"/> structure describing the
|
||||
/// state of the <c>GamePad</c> thumb sticks.
|
||||
/// </summary>
|
||||
public GamePadThumbSticks ThumbSticks
|
||||
{
|
||||
get { return new GamePadThumbSticks(left_stick_x, left_stick_y, right_stick_x, right_stick_y); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="GamePadButtons"/> structure describing the
|
||||
/// state of the <c>GamePad</c> buttons.
|
||||
/// </summary>
|
||||
public GamePadButtons Buttons
|
||||
{
|
||||
get { return new GamePadButtons(buttons); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="GamePadDPad"/> structure describing the
|
||||
/// state of the <c>GamePad</c> directional pad.
|
||||
/// </summary>
|
||||
public GamePadDPad DPad
|
||||
{
|
||||
get { return new GamePadDPad(buttons); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="GamePadTriggers"/> structure describing the
|
||||
/// state of the <c>GamePad</c> triggers.
|
||||
/// </summary>
|
||||
public GamePadTriggers Triggers
|
||||
{
|
||||
get { return new GamePadTriggers(left_trigger, right_trigger); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this <c>GamePad</c> instance is connected.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value>
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return is_connected; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the packet number for this <c>GamePadState</c> instance.
|
||||
/// Use the packet number to determine whether the state of a
|
||||
/// <c>GamePad</c> device has changed.
|
||||
/// </summary>
|
||||
public int PacketNumber
|
||||
{
|
||||
get { return packet_number; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadState"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadState"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format(
|
||||
|
@ -85,6 +114,11 @@ namespace OpenTK.Input
|
|||
ThumbSticks, Buttons, DPad, IsConnected);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a hash function for a <see cref="OpenTK.Input.GamePadState"/> 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
|
||||
|
@ -92,6 +126,12 @@ namespace OpenTK.Input
|
|||
DPad.GetHashCode() ^ IsConnected.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OpenTK.Input.GamePadState"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="OpenTK.Input.GamePadState"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadState"/>; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return
|
||||
|
@ -102,6 +142,13 @@ namespace OpenTK.Input
|
|||
#endregion
|
||||
|
||||
#region IEquatable<GamePadState> Members
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="OpenTK.Input.GamePadState"/> is equal to the current <see cref="OpenTK.Input.GamePadState"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="OpenTK.Input.GamePadState"/> to compare with the current <see cref="OpenTK.Input.GamePadState"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="OpenTK.Input.GamePadState"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadState"/>; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(GamePadState other)
|
||||
{
|
||||
return
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// #region License
|
||||
#region License
|
||||
//
|
||||
// GamePadThumbSticks.cs
|
||||
//
|
||||
|
@ -25,13 +25,15 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
// #endregion
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenTK.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the current thumb stick state of a <see cref="GamePad"/> device
|
||||
/// </summary>
|
||||
public struct GamePadThumbSticks : IEquatable<GamePadThumbSticks>
|
||||
{
|
||||
const float ConversionFactor = 1.0f / short.MaxValue;
|
||||
|
@ -50,26 +52,40 @@ namespace OpenTK.Input
|
|||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Vector2"/> describing the state of the left thumb stick.
|
||||
/// </summary>
|
||||
public Vector2 Left
|
||||
{
|
||||
get { return new Vector2(left_x * ConversionFactor, left_y * ConversionFactor); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Vector2"/> describing the state of the right thumb stick.
|
||||
/// </summary>
|
||||
public Vector2 Right
|
||||
{
|
||||
get { return new Vector2(right_x * ConversionFactor, right_y * ConversionFactor); }
|
||||
}
|
||||
|
||||
/// <param name="left">A <see cref="GamePadThumbSticks"/> instance to test for equality.</param>
|
||||
/// <param name="right">A <see cref="GamePadThumbSticks"/> instance to test for equality.</param>
|
||||
public static bool operator ==(GamePadThumbSticks left, GamePadThumbSticks right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <param name="left">A <see cref="GamePadThumbSticks"/> instance to test for inequality.</param>
|
||||
/// <param name="right">A <see cref="GamePadThumbSticks"/> instance to test for inequality.</param>
|
||||
public static bool operator !=(GamePadThumbSticks left, GamePadThumbSticks right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadThumbSticks"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadThumbSticks"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format(
|
||||
|
@ -77,6 +93,11 @@ namespace OpenTK.Input
|
|||
Left.X, Left.Y, Right.X, Right.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a hash function for a <see cref="OpenTK.Input.GamePadThumbSticks"/> 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
|
||||
|
@ -84,6 +105,12 @@ namespace OpenTK.Input
|
|||
right_x.GetHashCode() ^ right_y.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OpenTK.Input.GamePadThumbSticks"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="OpenTK.Input.GamePadThumbSticks"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadThumbSticks"/>; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return
|
||||
|
@ -95,6 +122,12 @@ namespace OpenTK.Input
|
|||
|
||||
#region IEquatable<GamePadThumbSticks> Members
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="OpenTK.Input.GamePadThumbSticks"/> is equal to the current <see cref="OpenTK.Input.GamePadThumbSticks"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="OpenTK.Input.GamePadThumbSticks"/> to compare with the current <see cref="OpenTK.Input.GamePadThumbSticks"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="OpenTK.Input.GamePadThumbSticks"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadThumbSticks"/>; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(GamePadThumbSticks other)
|
||||
{
|
||||
return
|
||||
|
|
|
@ -32,6 +32,9 @@ using System;
|
|||
|
||||
namespace OpenTK.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the state of a <see cref="GamePad"/> trigger buttons.
|
||||
/// </summary>
|
||||
public struct GamePadTriggers : IEquatable<GamePadTriggers>
|
||||
{
|
||||
const float ConversionFactor = 1.0f / short.MaxValue;
|
||||
|
@ -46,26 +49,40 @@ namespace OpenTK.Input
|
|||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the offset of the left trigger button, between 0.0 and 1.0.
|
||||
/// </summary>
|
||||
public float Left
|
||||
{
|
||||
get { return left * ConversionFactor; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the offset of the left trigger button, between 0.0 and 1.0.
|
||||
/// </summary>
|
||||
public float Right
|
||||
{
|
||||
get { return right * ConversionFactor; }
|
||||
}
|
||||
|
||||
/// <param name="left">A <see cref="GamePadTriggers"/> instance to test for equality.</param>
|
||||
/// <param name="right">A <see cref="GamePadTriggers"/> instance to test for equality.</param>
|
||||
public static bool operator ==(GamePadTriggers left, GamePadTriggers right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <param name="left">A <see cref="GamePadTriggers"/> instance to test for equality.</param>
|
||||
/// <param name="right">A <see cref="GamePadTriggers"/> instance to test for equality.</param>
|
||||
public static bool operator !=(GamePadTriggers left, GamePadTriggers right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadTriggers"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadTriggers"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format(
|
||||
|
@ -73,12 +90,23 @@ namespace OpenTK.Input
|
|||
Left, Right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a hash function for a <see cref="OpenTK.Input.GamePadTriggers"/> 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
|
||||
left.GetHashCode() ^ right.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OpenTK.Input.GamePadTriggers"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="OpenTK.Input.GamePadTriggers"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadTriggers"/>; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return
|
||||
|
@ -90,6 +118,12 @@ namespace OpenTK.Input
|
|||
|
||||
#region IEquatable<GamePadTriggers> Members
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="OpenTK.Input.GamePadTriggers"/> is equal to the current <see cref="OpenTK.Input.GamePadTriggers"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="OpenTK.Input.GamePadTriggers"/> to compare with the current <see cref="OpenTK.Input.GamePadTriggers"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="OpenTK.Input.GamePadTriggers"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.GamePadTriggers"/>; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(GamePadTriggers other)
|
||||
{
|
||||
return
|
||||
|
|
|
@ -29,19 +29,69 @@
|
|||
|
||||
namespace OpenTK.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumerates available <see cref="GamePad"/> types.
|
||||
/// </summary>
|
||||
public enum GamePadType
|
||||
{
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is of an unknown type.
|
||||
/// </summary>
|
||||
Unknown = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is an arcade stick.
|
||||
/// </summary>
|
||||
ArcadeStick,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is a dance pad.
|
||||
/// </summary>
|
||||
DancePad,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is a flight stick.
|
||||
/// </summary>
|
||||
FlightStick,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is a guitar.
|
||||
/// </summary>
|
||||
Guitar,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is a driving wheel.
|
||||
/// </summary>
|
||||
Wheel,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is an alternate guitar.
|
||||
/// </summary>
|
||||
AlternateGuitar,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is a big button pad.
|
||||
/// </summary>
|
||||
BigButtonPad,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is a drum kit.
|
||||
/// </summary>
|
||||
DrumKit,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is a game pad.
|
||||
/// </summary>
|
||||
GamePad,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is an arcade pad.
|
||||
/// </summary>
|
||||
ArcadePad,
|
||||
|
||||
/// <summary>
|
||||
/// The <c>GamePad</c> is a bass guitar.
|
||||
/// </summary>
|
||||
BassGuitar,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,14 @@ using System.Text;
|
|||
|
||||
namespace OpenTK.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to Joystick devices.
|
||||
/// Joystick devices provide a varying number of axes and buttons.
|
||||
/// Use <c>GetCapabilities</c> to retrieve the number of supported
|
||||
/// axes and buttons on a given device.
|
||||
/// Use <c>GetState</c> to retrieve the current state of a given device.
|
||||
/// <seealso cref="GamePad"/>
|
||||
/// </summary>
|
||||
public sealed class Joystick
|
||||
{
|
||||
static readonly IJoystickDriver2 implementation =
|
||||
|
@ -40,11 +48,32 @@ namespace OpenTK.Input
|
|||
|
||||
private Joystick() { }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="JoystickCapabilities"/> of the device connected
|
||||
/// at the specified index.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A <see cref="JoystickCapabilities"/> structure describing
|
||||
/// the capabilities of the device at the specified index.
|
||||
/// If no device is connected at the specified index, the <c>IsConnected</c>
|
||||
/// property of the returned structure will be false.
|
||||
/// </returns>
|
||||
/// <param name="index">The zero-based index of the device to poll.</param>
|
||||
public static JoystickCapabilities GetCapabilities(int index)
|
||||
{
|
||||
return implementation.GetCapabilities(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="JoystickState"/> of the device connected
|
||||
/// at the specified index.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="JoystickState"/> structure describing
|
||||
/// the current state of the device at the specified index.
|
||||
/// If no device is connected at this index, the <c>IsConnected</c>
|
||||
/// property of the returned structure will be false.
|
||||
/// </returns>
|
||||
/// <param name="index">The zero-based index of the device to poll.</param>
|
||||
public static JoystickState GetState(int index)
|
||||
{
|
||||
return implementation.GetState(index);
|
||||
|
|
|
@ -33,6 +33,9 @@ using System.Text;
|
|||
|
||||
namespace OpenTK.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the <c>JoystickCapabilities</c> of a <see cref="JoystickDevice"/>.
|
||||
/// </summary>
|
||||
public struct JoystickCapabilities : IEquatable<JoystickCapabilities>
|
||||
{
|
||||
byte axis_count;
|
||||
|
@ -42,7 +45,7 @@ namespace OpenTK.Input
|
|||
|
||||
#region Constructors
|
||||
|
||||
public JoystickCapabilities(int axis_count, int button_count, bool is_connected)
|
||||
internal JoystickCapabilities(int axis_count, int button_count, bool is_connected)
|
||||
{
|
||||
if (axis_count < 0 || axis_count >= JoystickState.MaxAxes)
|
||||
throw new ArgumentOutOfRangeException("axis_count");
|
||||
|
@ -59,21 +62,35 @@ namespace OpenTK.Input
|
|||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of axes supported by this <see cref="JoystickDevice"/>.
|
||||
/// </summary>
|
||||
public int AxisCount
|
||||
{
|
||||
get { return axis_count; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of buttons supported by this <see cref="JoystickDevice"/>.
|
||||
/// </summary>
|
||||
public int ButtonCount
|
||||
{
|
||||
get { return button_count; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this <see cref="JoystickDevice"/> is connected.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value>
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return is_connected; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.JoystickCapabilities"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.JoystickCapabilities"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format(
|
||||
|
@ -81,6 +98,11 @@ namespace OpenTK.Input
|
|||
AxisCount, ButtonCount, IsConnected);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a hash function for a <see cref="OpenTK.Input.JoystickCapabilities"/> 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
|
||||
|
@ -89,6 +111,12 @@ namespace OpenTK.Input
|
|||
IsConnected.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OpenTK.Input.JoystickCapabilities"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="OpenTK.Input.JoystickCapabilities"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.JoystickCapabilities"/>; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return
|
||||
|
@ -109,6 +137,12 @@ namespace OpenTK.Input
|
|||
|
||||
#region IEquatable<JoystickCapabilities> Members
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="OpenTK.Input.JoystickCapabilities"/> is equal to the current <see cref="OpenTK.Input.JoystickCapabilities"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="OpenTK.Input.JoystickCapabilities"/> to compare with the current <see cref="OpenTK.Input.JoystickCapabilities"/>.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="OpenTK.Input.JoystickCapabilities"/> is equal to the current
|
||||
/// <see cref="OpenTK.Input.JoystickCapabilities"/>; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(JoystickCapabilities other)
|
||||
{
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue