mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-06-06 16:18:17 +00:00
Added argument validation for GetState(index) and serializes access to GetState() implementation. Clarified GetState() documentation to explain that it returns combined device state.
This commit is contained in:
parent
bb1619161f
commit
a7427707ef
|
@ -40,28 +40,38 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
static readonly IKeyboardDriver driver =
|
static readonly IKeyboardDriver driver =
|
||||||
Platform.Factory.Default.CreateKeyboardDriver();
|
Platform.Factory.Default.CreateKeyboardDriver();
|
||||||
|
static readonly object SyncRoot = new object();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Members
|
#region Public Members
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the KeyboardState for the default keyboard device.
|
/// Retrieves the combined <see cref="OpenTK.Input.KeyboardState"/> for all keyboard devices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A <see cref="OpenTK.Input.KeyboardState"/> structure containing the state of the keyboard device.</returns>
|
/// <returns>A <see cref="OpenTK.Input.KeyboardState"/> structure containing the combined state for all keyboard devices.</returns>
|
||||||
public static KeyboardState GetState()
|
public static KeyboardState GetState()
|
||||||
{
|
{
|
||||||
return driver.GetState();
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
return driver.GetState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the KeyboardState for the specified keyboard device.
|
/// Retrieves the <see cref="OpenTK.Input.KeyboardState"/> for the specified keyboard device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index">The index of the keyboard device.</param>
|
/// <param name="index">The index of the keyboard device.</param>
|
||||||
/// <returns>A <see cref="OpenTK.Input.KeyboardState"/> structure containing the state of the keyboard device.</returns>
|
/// <returns>A <see cref="OpenTK.Input.KeyboardState"/> structure containing the state of the keyboard device.</returns>
|
||||||
public static KeyboardState GetState(int index)
|
public static KeyboardState GetState(int index)
|
||||||
{
|
{
|
||||||
return driver.GetState(index);
|
if (index < 0)
|
||||||
|
throw new ArgumentOutOfRangeException("index");
|
||||||
|
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
return driver.GetState(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -40,30 +40,38 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
static readonly IMouseDriver driver =
|
static readonly IMouseDriver driver =
|
||||||
Platform.Factory.Default.CreateMouseDriver();
|
Platform.Factory.Default.CreateMouseDriver();
|
||||||
|
static readonly object SyncRoot = new object();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Members
|
#region Public Members
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the MouseState for the specified mouse device.
|
/// Retrieves the combined <see cref="OpenTK.Input.MouseState"/> for all specified mouse devices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A <see cref="OpenTK.Input.MouseState"/> structure containing the state of the mouse device.</returns>
|
/// <returns>A <see cref="OpenTK.Input.MouseState"/> structure containing the combined state of all mouse devices.</returns>
|
||||||
public static MouseState GetState()
|
public static MouseState GetState()
|
||||||
{
|
{
|
||||||
return driver.GetState();
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
return driver.GetState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the MouseState for the specified mouse device.
|
/// Retrieves the <see cref="OpenTK.Input.MouseState"/> for the specified mouse device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index">The index of the mouse device.</param>
|
/// <param name="index">The index of the mouse device.</param>
|
||||||
/// <returns>A <see cref="OpenTK.Input.MouseState"/> structure containing the state of the mouse device.</returns>
|
/// <returns>A <see cref="OpenTK.Input.MouseState"/> structure containing the state for the specified mouse device.</returns>
|
||||||
public static MouseState GetState(int index)
|
public static MouseState GetState(int index)
|
||||||
{
|
{
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
throw new ArgumentOutOfRangeException("index");
|
throw new ArgumentOutOfRangeException("index");
|
||||||
return driver.GetState(index);
|
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
return driver.GetState(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue