From c6989395df2c88bc504f19f2e09034d6d65c617b Mon Sep 17 00:00:00 2001 From: thefiddler Date: Thu, 11 Sep 2014 01:03:24 +0200 Subject: [PATCH] [Input] Added GameWindow.Mouse/Keyboard.GetState() GameWindow.Mouse/Keyboard hide OpenTK.Input.Mouse/Keyboard. To simplify usage, the former now provide the same methods as the latter. --- Source/OpenTK/GameWindow.cs | 10 ++++++++-- Source/OpenTK/Input/KeyboardDevice.cs | 23 +++++++++++++++++++++++ Source/OpenTK/Input/MouseDevice.cs | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs index cfab224..2a6df0c 100644 --- a/Source/OpenTK/GameWindow.cs +++ b/Source/OpenTK/GameWindow.cs @@ -596,28 +596,34 @@ namespace OpenTK #region Keyboard + #pragma warning disable 0612 + /// /// Gets the primary Keyboard device, or null if no Keyboard exists. /// - [Obsolete("Use KeyDown, KeyUp and KeyPress events or OpenTK.Input.Keyboard instead.")] public KeyboardDevice Keyboard { get { return InputDriver.Keyboard.Count > 0 ? InputDriver.Keyboard[0] : null; } } + #pragma warning restore 0612 + #endregion #region Mouse + #pragma warning disable 0612 + /// /// Gets the primary Mouse device, or null if no Mouse exists. /// - [Obsolete("Use MouseMove, MouseDown, MouseUp and MouseWheel events or OpenTK.Input.Mouse, instead.")] public MouseDevice Mouse { get { return InputDriver.Mouse.Count > 0 ? InputDriver.Mouse[0] : null; } } + #pragma warning restore 0612 + #endregion #region --- GameWindow Timing --- diff --git a/Source/OpenTK/Input/KeyboardDevice.cs b/Source/OpenTK/Input/KeyboardDevice.cs index cb64f17..04b5d18 100644 --- a/Source/OpenTK/Input/KeyboardDevice.cs +++ b/Source/OpenTK/Input/KeyboardDevice.cs @@ -161,6 +161,29 @@ namespace OpenTK.Input #region --- Public Methods --- + /// + /// Retrieves the combined for all keyboard devices. + /// This method is equivalent to . + /// + /// An structure containing the combined state for all keyboard devices. + /// + public KeyboardState GetState() + { + return Keyboard.GetState(); + } + + /// + /// Retrieves the for the specified keyboard device. + /// This method is equivalent to . + /// + /// The index of the keyboard device. + /// An structure containing the combined state for all keyboard devices. + /// + public KeyboardState GetState(int index) + { + return Keyboard.GetState(index); + } + /// Returns the hash code for this KeyboardDevice. /// A 32-bit signed integer hash code. public override int GetHashCode() diff --git a/Source/OpenTK/Input/MouseDevice.cs b/Source/OpenTK/Input/MouseDevice.cs index f5b3207..32585a0 100644 --- a/Source/OpenTK/Input/MouseDevice.cs +++ b/Source/OpenTK/Input/MouseDevice.cs @@ -88,6 +88,40 @@ namespace OpenTK.Input #region --- Public Members --- + /// + /// Retrieves the combined hardware for all specified mouse devices. + /// This method is equivalent to . + /// + /// A structure representing the state for the specified mouse device. + /// + public MouseState GetState() + { + return Mouse.GetState(); + } + + /// + /// Retrieves the hardware for the specified mouse device. + /// This method is equivalent to . + /// + /// The index of the mouse device. + /// A structure representing the state for the specified mouse device. + /// + public MouseState GetState(int index) + { + return Mouse.GetState(index); + } + + /// + /// Retreves the for the mouse cursor. + /// This method is equivalent to . + /// + /// A structure representing the state of the mouse cursor. + /// + public MouseState GetCursorState() + { + return Mouse.GetCursorState(); + } + #region public int NumberOfButtons /// -- 2.7.4