Skip to content

Commit

Permalink
Merge pull request #8249 from Maniekko/docs/Input
Browse files Browse the repository at this point in the history
[Documentation] Adds XML documentation to the Input namespace
  • Loading branch information
SimonDarksideJ committed May 10, 2024
2 parents 6009fd6 + 8012490 commit b9b7b8c
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 20 deletions.
7 changes: 6 additions & 1 deletion MonoGame.Framework/Input/GamePadButtons.cs
Expand Up @@ -142,7 +142,12 @@ public ButtonState BigButton
return ((_buttons & Buttons.BigButton) == Buttons.BigButton) ? ButtonState.Pressed : ButtonState.Released;
}
}


/// <summary>
/// Initializes a new instance of the <see cref="GamePadButtons"/> structure,
/// setting the specified buttons to pressed in.
/// </summary>
/// <param name="buttons">Buttons to be set as pressed in.</param>
public GamePadButtons(Buttons buttons)
{
_buttons = buttons;
Expand Down
5 changes: 4 additions & 1 deletion MonoGame.Framework/Input/GamePadDPad.cs
Expand Up @@ -3,7 +3,10 @@
// file 'LICENSE.txt', which is part of this source code package.

namespace Microsoft.Xna.Framework.Input
{
{
/// <summary>
/// A struct that represents which directions on the directional pad of a controller are being pressed.
/// </summary>
public struct GamePadDPad
{
/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions MonoGame.Framework/Input/GamePadThumbSticks.cs
Expand Up @@ -42,6 +42,12 @@ public Vector2 Right
get { return _right; }
}

/// <summary>
/// Initializes a new instance of the <see cref="GamePadThumbSticks"/> struct,
/// setting positions of the sticks.
/// </summary>
/// <param name="leftPosition">Position of the left controller stick.</param>
/// <param name="rightPosition">Position of the right controller stick.</param>
public GamePadThumbSticks(Vector2 leftPosition, Vector2 rightPosition)
: this(leftPosition, rightPosition, GamePadDeadZone.None, GamePadDeadZone.None)
{
Expand Down
6 changes: 6 additions & 0 deletions MonoGame.Framework/Input/KeyboardInput.cs
Expand Up @@ -3,8 +3,14 @@

namespace Microsoft.Xna.Framework.Input
{
/// <summary>
/// Provides access to the keyboard input user interface.
/// </summary>
public static partial class KeyboardInput
{
/// <summary>
/// Determines if a keyboard user interface screen is active.
/// </summary>
public static bool IsVisible { get; private set; }

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion MonoGame.Framework/Input/MessageBox.cs
Expand Up @@ -5,8 +5,14 @@

namespace Microsoft.Xna.Framework.Input
{
/// <summary>
/// Provides access to the message box user interface.
/// </summary>
public static partial class MessageBox
{
/// <summary>
/// Determines if a message box user interface screen is active.
/// </summary>
public static bool IsVisible { get; private set; }

/// <summary>
Expand Down Expand Up @@ -60,4 +66,4 @@ public static void Cancel(int? result)
PlatformCancel(result);
}
}
}
}
6 changes: 5 additions & 1 deletion MonoGame.Framework/Input/MouseCursor.cs
Expand Up @@ -86,6 +86,9 @@ public static MouseCursor FromTexture2D(Texture2D texture, int originx, int orig
return PlatformFromTexture2D(texture, originx, originy);
}

/// <summary>
/// Gets a handle for this cursor.
/// </summary>
public IntPtr Handle { get; private set; }

private bool _disposed;
Expand All @@ -100,6 +103,7 @@ private MouseCursor(IntPtr handle)
Handle = handle;
}

/// <inheritdoc cref="IDisposable.Dispose()"/>
public void Dispose()
{
if (_disposed)
Expand All @@ -109,4 +113,4 @@ public void Dispose()
_disposed = true;
}
}
}
}
62 changes: 54 additions & 8 deletions MonoGame.Framework/Input/Touch/TouchLocation.cs
Expand Up @@ -10,6 +10,9 @@

namespace Microsoft.Xna.Framework.Input.Touch
{
/// <summary>
/// Provides methods and properties for interacting with a touch location on a touch screen device.
/// </summary>
public struct TouchLocation : IEquatable<TouchLocation>
{
/// <summary>
Expand Down Expand Up @@ -67,6 +70,9 @@ internal Vector2 Velocity
get { return _velocity; }
}

/// <summary>
/// Gets the ID of the touch location.
/// </summary>
public int Id
{
get
Expand All @@ -75,40 +81,59 @@ public int Id
}
}

/// <summary>
/// Gets the position of the touch location.
/// </summary>
public Vector2 Position
{
get
{
return _position;
}
}


/// <summary>
/// Gets the pressure of the touch location.
/// </summary>
/// <remarks>Only used in Android devices</remarks>
public float Pressure
{
get
{
return _pressure;
}
}


/// <summary>
/// Gets the current state of the touch location.
/// </summary>
public TouchLocationState State
{
get
{
return _state;
}
}

#endregion

#region Constructors

#endregion

#region Constructors

/// <inheritdoc cref="TouchLocation(int, TouchLocationState, Vector2, TouchLocationState, Vector2)"/>
public TouchLocation(int id, TouchLocationState state, Vector2 position)
: this(id, state, position, TouchLocationState.Invalid, Vector2.Zero)
{
}

public TouchLocation( int id, TouchLocationState state, Vector2 position,
/// <summary>
/// Initializes a new instance of the <see cref="TouchLocation"/> structure.
/// </summary>
/// <param name="id">ID of the touch location.</param>
/// <param name="state">Current state of the touch location.</param>
/// <param name="position">Position of the touch location.</param>
/// <param name="previousState">Previous state of this touch location.</param>
/// <param name="previousPosition">Previous position of this touch location.</param>
public TouchLocation(int id, TouchLocationState state, Vector2 position,
TouchLocationState previousState, Vector2 previousPosition)
: this(id, state, position, previousState, previousPosition, TimeSpan.Zero, false)
{
Expand Down Expand Up @@ -234,6 +259,7 @@ public bool IsHighFrequencyEvent()
return _isHighFrequency;
}

/// <inheritdoc/>
public override bool Equals(object obj)
{
if (obj is TouchLocation)
Expand All @@ -242,6 +268,7 @@ public override bool Equals(object obj)
return false;
}

/// <inheritdoc/>
public bool Equals(TouchLocation other)
{
return _id.Equals(other._id) &&
Expand All @@ -250,17 +277,24 @@ public bool Equals(TouchLocation other)
}



/// <inheritdoc/>
public override int GetHashCode()
{
return _id;
}

/// <summary>
/// Gets a string representation of the <see cref="TouchLocation"/>.
/// </summary>
public override string ToString()
{
return "Touch id:"+_id+" state:"+_state + " position:" + _position + " pressure:" + _pressure +" prevState:"+_previousState+" prevPosition:"+ _previousPosition + " previousPressure:" + _previousPressure;
}

/// <summary>
/// Attempts to get the previous location of this touch location object.
/// </summary>
/// <param name="aPreviousLocation">Previous location data, as a <see cref="TouchLocation"/>.</param>
public bool TryGetPreviousLocation(out TouchLocation aPreviousLocation)
{
if (_previousState == TouchLocationState.Invalid)
Expand Down Expand Up @@ -297,6 +331,12 @@ public bool TryGetPreviousLocation(out TouchLocation aPreviousLocation)
return true;
}

/// <summary>
/// Returns a value that indicates whether the two values are not equal.
/// </summary>
/// <param name="value1">The value on the left of the inequality operator.</param>
/// <param name="value2">The value on the right of the inequality operator.</param>
/// <returns><see langword="true"/> if the two values are not equal; otherwise, <see langword="false"/>.</returns>
public static bool operator !=(TouchLocation value1, TouchLocation value2)
{
return value1._id != value2._id ||
Expand All @@ -306,6 +346,12 @@ public bool TryGetPreviousLocation(out TouchLocation aPreviousLocation)
value1._previousPosition != value2._previousPosition;
}

/// <summary>
/// Returns a value that indicates whether the two values are equal.
/// </summary>
/// <param name="value1">The value on the left of the equality operator.</param>
/// <param name="value2">The value on the right of the equality operator.</param>
/// <returns><see langword="true"/> if the two values are equal; otherwise, <see langword="false"/>.</returns>
public static bool operator ==(TouchLocation value1, TouchLocation value2)
{
return value1._id == value2._id &&
Expand Down
25 changes: 19 additions & 6 deletions MonoGame.Framework/Input/Touch/TouchPanel.cs
Expand Up @@ -21,12 +21,19 @@ public static TouchCollection GetState()
{
return PrimaryWindow.TouchPanelState.GetState();
}


/// <summary>
/// Gets the current state of the touch panel.
/// </summary>
/// <param name="window">Game windows to get state from</param>
public static TouchPanelState GetState(GameWindow window)
{
return window.TouchPanelState;
}


/// <summary>
/// Gets the touch panel capabilities for an available device.
/// </summary>
public static TouchPanelCapabilities GetCapabilities()
{
return PrimaryWindow.TouchPanelState.GetCapabilities();
Expand Down Expand Up @@ -101,13 +108,19 @@ public static GestureType EnabledGestures
get { return PrimaryWindow.TouchPanelState.EnabledGestures; }
set { PrimaryWindow.TouchPanelState.EnabledGestures = value; }
}


/// <summary>
/// Gets or sets a value indicating whether to enable the mouse touch point.
/// </summary>
public static bool EnableMouseTouchPoint
{
get { return PrimaryWindow.TouchPanelState.EnableMouseTouchPoint; }
set { PrimaryWindow.TouchPanelState.EnableMouseTouchPoint = value; }
}

}

/// <summary>
/// Gets or sets a value indicating whether to enable mouse gestures.
/// </summary>
public static bool EnableMouseGestures
{
get { return PrimaryWindow.TouchPanelState.EnableMouseGestures; }
Expand All @@ -132,4 +145,4 @@ public static bool EnableHighFrequencyTouch
set { PrimaryWindow.TouchPanelState.EnableHighFrequencyTouch = value; }
}
}
}
}
7 changes: 5 additions & 2 deletions MonoGame.Framework/Input/Touch/TouchPanelCapabilities.cs
Expand Up @@ -71,7 +71,10 @@ internal void Initialize()
#endif
}
}


/// <summary>
/// Returns <see langword="true"/> if a touch device supports pressure.
/// </summary>
public bool HasPressure
{
get
Expand Down Expand Up @@ -109,4 +112,4 @@ public int MaximumTouchCount
const int SM_MAXIMUMTOUCHES = 95;
#endif
}
}
}
13 changes: 13 additions & 0 deletions MonoGame.Framework/Input/Touch/TouchPanelState.cs
Expand Up @@ -7,6 +7,10 @@

namespace Microsoft.Xna.Framework.Input.Touch
{
/// <summary>
/// Represents specific information about the state of the touch panel,
/// including the current state of touch locations and gestures.
/// </summary>
public class TouchPanelState
{
/// <summary>
Expand Down Expand Up @@ -141,6 +145,9 @@ private void ApplyTouch(List<TouchLocation> state, TouchLocation touch)
}
}

/// <summary>
/// Returns the current touch panel state
/// </summary>
public TouchCollection GetState()
{
//Clear out touches from previous frames that were released on the same frame they were touched that haven't been seen
Expand Down Expand Up @@ -331,8 +338,14 @@ public int DisplayWidth
/// </summary>
public GestureType EnabledGestures { get; set; }

/// <summary>
/// Gets or sets whether mouse touch points are enabled.
/// </summary>
public bool EnableMouseTouchPoint { get; set; }

/// <summary>
/// Gets or sets whether mouse gestures are enabled.
/// </summary>
public bool EnableMouseGestures { get; set; }

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions MonoGame.Framework/Platform/Input/GamePad.SDL.cs
Expand Up @@ -20,6 +20,9 @@ private class GamePadInfo
private static readonly Dictionary<int, GamePadInfo> Gamepads = new Dictionary<int, GamePadInfo>();
private static readonly Dictionary<int, int> _translationTable = new Dictionary<int, int>();

/// <summary>
/// Initialies the internal database of gamepad mappings for an SDL context
/// </summary>
public static void InitDatabase()
{
using (var stream = ReflectionHelpers.GetAssembly(typeof(GamePad)).GetManifestResourceStream("gamecontrollerdb.txt"))
Expand Down

0 comments on commit b9b7b8c

Please sign in to comment.