mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 02:35:36 +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 =
|
||||
Platform.Factory.Default.CreateKeyboardDriver();
|
||||
static readonly object SyncRoot = new object();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the KeyboardState for the default keyboard device.
|
||||
/// Retrieves the combined <see cref="OpenTK.Input.KeyboardState"/> for all keyboard devices.
|
||||
/// </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()
|
||||
{
|
||||
return driver.GetState();
|
||||
lock (SyncRoot)
|
||||
{
|
||||
return driver.GetState();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the KeyboardState for the specified keyboard device.
|
||||
/// Retrieves the <see cref="OpenTK.Input.KeyboardState"/> for the specified keyboard device.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public static KeyboardState GetState(int index)
|
||||
{
|
||||
return driver.GetState(index);
|
||||
if (index < 0)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
|
||||
lock (SyncRoot)
|
||||
{
|
||||
return driver.GetState(index);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -40,30 +40,38 @@ namespace OpenTK.Input
|
|||
|
||||
static readonly IMouseDriver driver =
|
||||
Platform.Factory.Default.CreateMouseDriver();
|
||||
static readonly object SyncRoot = new object();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the MouseState for the specified mouse device.
|
||||
/// Retrieves the combined <see cref="OpenTK.Input.MouseState"/> for all specified mouse devices.
|
||||
/// </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()
|
||||
{
|
||||
return driver.GetState();
|
||||
lock (SyncRoot)
|
||||
{
|
||||
return driver.GetState();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the MouseState for the specified mouse device.
|
||||
/// Retrieves the <see cref="OpenTK.Input.MouseState"/> for the specified mouse device.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
if (index < 0)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
return driver.GetState(index);
|
||||
|
||||
lock (SyncRoot)
|
||||
{
|
||||
return driver.GetState(index);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue