mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-12 00:15:40 +00:00
Renamed Keyboard and Mouse to KeyboardDevice and MouseDevice respectively, to avoid name classes.
This commit is contained in:
parent
346c7c15c8
commit
f7f7dd4d31
|
@ -15,7 +15,7 @@ using System.Diagnostics;
|
||||||
|
|
||||||
namespace OpenTK.Input
|
namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
public sealed class Keyboard : IKeyboard
|
public sealed class KeyboardDevice : IInputDevice
|
||||||
{
|
{
|
||||||
//private IKeyboard keyboard;
|
//private IKeyboard keyboard;
|
||||||
private bool[] keys = new bool[(int)Key.MaxKeys];
|
private bool[] keys = new bool[(int)Key.MaxKeys];
|
||||||
|
@ -26,7 +26,7 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
#region --- Constructors ---
|
#region --- Constructors ---
|
||||||
|
|
||||||
public Keyboard()
|
public KeyboardDevice()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,39 +34,53 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
#region --- IKeyboard members ---
|
#region --- IKeyboard members ---
|
||||||
|
|
||||||
public bool this[Key k]
|
/// <summary>
|
||||||
|
/// Gets a value indicating the status of the specified Key.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The Key to check.</param>
|
||||||
|
/// <returns>True if the Key is pressed, false otherwise.</returns>
|
||||||
|
public bool this[Key key]
|
||||||
{
|
{
|
||||||
get { return keys[(int)k]; }
|
get { return keys[(int)key]; }
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (keys[(int)k] != value || KeyRepeat)
|
if (keys[(int)key] != value || KeyRepeat)
|
||||||
{
|
{
|
||||||
keys[(int)k] = value;
|
keys[(int)key] = value;
|
||||||
|
|
||||||
if (value && KeyDown != null)
|
if (value && KeyDown != null)
|
||||||
{
|
{
|
||||||
KeyDown(this, k);
|
KeyDown(this, key);
|
||||||
}
|
}
|
||||||
else if (!value && KeyUp != null)
|
else if (!value && KeyUp != null)
|
||||||
{
|
{
|
||||||
KeyUp(this, k);
|
KeyUp(this, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an integer representing the number of keys on this KeyboardDevice.
|
||||||
|
/// </summary>
|
||||||
public int NumberOfKeys
|
public int NumberOfKeys
|
||||||
{
|
{
|
||||||
get { return numKeys; }
|
get { return numKeys; }
|
||||||
internal set { numKeys = value; }
|
internal set { numKeys = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an integer representing the number of function keys (F-keys) on this KeyboardDevice.
|
||||||
|
/// </summary>
|
||||||
public int NumberOfFunctionKeys
|
public int NumberOfFunctionKeys
|
||||||
{
|
{
|
||||||
get { return numFKeys; }
|
get { return numFKeys; }
|
||||||
internal set { numFKeys = value; }
|
internal set { numFKeys = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating the number of led indicators on this KeyboardDevice.
|
||||||
|
/// </summary>
|
||||||
public int NumberOfLeds
|
public int NumberOfLeds
|
||||||
{
|
{
|
||||||
get { return numLeds; }
|
get { return numLeds; }
|
||||||
|
@ -74,7 +88,7 @@ namespace OpenTK.Input
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Device dependent ID.
|
/// Gets an IntPtr representing a device dependent ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IntPtr DeviceID
|
public IntPtr DeviceID
|
||||||
{
|
{
|
||||||
|
@ -85,7 +99,7 @@ namespace OpenTK.Input
|
||||||
#region public bool KeyRepeat
|
#region public bool KeyRepeat
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether key repeat is turned on or off.
|
/// Gets or sets a value indicating whether key repeat status.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Setting key repeat to on will generate multiple KeyDown events when a key is held pressed.
|
/// Setting key repeat to on will generate multiple KeyDown events when a key is held pressed.
|
||||||
|
@ -137,13 +151,16 @@ namespace OpenTK.Input
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
//return base.ToString();
|
//return base.ToString();
|
||||||
return String.Format("ID: {0} (keys: {1}, function keys: {2}, leds: {3})",
|
return String.Format("ID: {0} ({1}). Keys: {2}, Function keys: {3}, Leds: {4}",
|
||||||
DeviceID, NumberOfKeys, NumberOfFunctionKeys, NumberOfLeds);
|
DeviceID, Description, NumberOfKeys, NumberOfFunctionKeys, NumberOfLeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public delegate void KeyDownEvent(KeyboardDevice sender, Key key);
|
||||||
|
public delegate void KeyUpEvent(KeyboardDevice sender, Key key);
|
||||||
|
|
||||||
#region public enum Key : int
|
#region public enum Key : int
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
|
@ -10,7 +10,10 @@ using System.Text;
|
||||||
|
|
||||||
namespace OpenTK.Input
|
namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
public sealed class Mouse : IMouse
|
/// <summary>
|
||||||
|
/// The MouseDevice class represents a mouse device and provides methods to query its status.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class MouseDevice : IInputDevice
|
||||||
{
|
{
|
||||||
private string description;
|
private string description;
|
||||||
private int numButtons, numWheels;
|
private int numButtons, numWheels;
|
||||||
|
@ -20,12 +23,18 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
#region --- IInputDevice Members ---
|
#region --- IInputDevice Members ---
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a string describing this MouseDevice.
|
||||||
|
/// </summary>
|
||||||
public string Description
|
public string Description
|
||||||
{
|
{
|
||||||
get { return description; }
|
get { return description; }
|
||||||
internal set { description = value; }
|
internal set { description = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an value indicating the InputDeviceType of this InputDevice.
|
||||||
|
/// </summary>
|
||||||
public InputDeviceType DeviceType
|
public InputDeviceType DeviceType
|
||||||
{
|
{
|
||||||
get { return InputDeviceType.Mouse; }
|
get { return InputDeviceType.Mouse; }
|
||||||
|
@ -35,24 +44,36 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
#region --- IMouse Members ---
|
#region --- IMouse Members ---
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an integer representing the number of buttons on this MouseDevice.
|
||||||
|
/// </summary>
|
||||||
public int NumberOfButtons
|
public int NumberOfButtons
|
||||||
{
|
{
|
||||||
get { return numButtons; }
|
get { return numButtons; }
|
||||||
internal set { numButtons = value; }
|
internal set { numButtons = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an integer representing the number of wheels on this MouseDevice.
|
||||||
|
/// </summary>
|
||||||
public int NumberOfWheels
|
public int NumberOfWheels
|
||||||
{
|
{
|
||||||
get { return numWheels; }
|
get { return numWheels; }
|
||||||
internal set { numWheels = value; }
|
internal set { numWheels = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an IntPtr representing a device dependent ID.
|
||||||
|
/// </summary>
|
||||||
public IntPtr DeviceID
|
public IntPtr DeviceID
|
||||||
{
|
{
|
||||||
get { return id; }
|
get { return id; }
|
||||||
internal set { id = value; }
|
internal set { id = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an integer representing the absolute wheel position.
|
||||||
|
/// </summary>
|
||||||
public int Wheel
|
public int Wheel
|
||||||
{
|
{
|
||||||
get { return wheel; }
|
get { return wheel; }
|
||||||
|
@ -62,7 +83,10 @@ namespace OpenTK.Input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int WheelDelta
|
/// <summary>
|
||||||
|
/// Gets an integer representing the relative wheel movement.
|
||||||
|
/// </summary>
|
||||||
|
public int WheelDelta
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -76,32 +100,52 @@ namespace OpenTK.Input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an integer representing the absolute x position of the pointer, in screen pixel coordinates.
|
||||||
|
/// </summary>
|
||||||
public int X
|
public int X
|
||||||
{
|
{
|
||||||
get { return x; }
|
get { return x; }
|
||||||
internal set { x = value; }
|
internal set { x = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an integer representing the absolute y position of the pointer, in screen pixel coordinates.
|
||||||
|
/// </summary>
|
||||||
public int Y
|
public int Y
|
||||||
{
|
{
|
||||||
get { return y; }
|
get { return y; }
|
||||||
internal set { y = value; }
|
internal set { y = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an integer representing the relative x movement of the pointer, in pixel coordinates.
|
||||||
|
/// </summary>
|
||||||
public int XDelta
|
public int XDelta
|
||||||
{
|
{
|
||||||
get { return delta_x; }
|
get { return delta_x; }
|
||||||
internal set { delta_x = value; }
|
internal set { delta_x = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an integer representing the relative y movement of the pointer, in pixel coordinates.
|
||||||
|
/// </summary>
|
||||||
public int YDelta
|
public int YDelta
|
||||||
{
|
{
|
||||||
get { return delta_y; }
|
get { return delta_y; }
|
||||||
internal set { delta_y = value; }
|
internal set { delta_y = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public event MouseMoveEvent Move;
|
//public event MouseMoveEvent Move;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when a button is pressed.
|
||||||
|
/// </summary>
|
||||||
public event MouseButtonDownEvent ButtonDown;
|
public event MouseButtonDownEvent ButtonDown;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when a button is released.
|
||||||
|
/// </summary>
|
||||||
public event MouseButtonUpEvent ButtonUp;
|
public event MouseButtonUpEvent ButtonUp;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -121,8 +165,8 @@ namespace OpenTK.Input
|
||||||
ButtonUp(this, b);
|
ButtonUp(this, b);
|
||||||
}
|
}
|
||||||
button[(int)b] = value;
|
button[(int)b] = value;
|
||||||
|
//System.Diagnostics.Debug.Print("Mouse button {0} {1}", b, value ? "down" : "up");
|
||||||
}
|
}
|
||||||
|
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return button[(int)b];
|
return button[(int)b];
|
||||||
|
@ -130,8 +174,33 @@ namespace OpenTK.Input
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region --- Public Methods ---
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
//return base.GetHashCode();
|
||||||
|
return (int)(numButtons ^ numWheels ^ id.GetHashCode() ^ description.GetHashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return String.Format("ID: {0} ({1}). Buttons: {2}, Wheels: {3}",
|
||||||
|
DeviceID, Description, NumberOfButtons, NumberOfWheels);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public delegate void MouseMoveEvent(MouseDevice sender, MouseMoveData key);
|
||||||
|
public delegate void MouseButtonDownEvent(MouseDevice sender, MouseButton button);
|
||||||
|
public delegate void MouseButtonUpEvent(MouseDevice sender, MouseButton button);
|
||||||
|
|
||||||
|
#region public enum MouseButton
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enumerates all possible mouse buttons.
|
||||||
|
/// </summary>
|
||||||
public enum MouseButton
|
public enum MouseButton
|
||||||
{
|
{
|
||||||
Left = 0,
|
Left = 0,
|
||||||
|
@ -149,37 +218,20 @@ namespace OpenTK.Input
|
||||||
LastButton
|
LastButton
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MouseWheel
|
#endregion
|
||||||
{
|
|
||||||
private int position;
|
|
||||||
private int delta;
|
|
||||||
|
|
||||||
/// <summary>
|
#region internal class MouseMoveData
|
||||||
/// Gets the absolute position of the mouse wheel.
|
|
||||||
/// </summary>
|
|
||||||
public int Position
|
|
||||||
{
|
|
||||||
get { return position; }
|
|
||||||
internal set { position = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the relative movement of the mouse wheel.
|
/// Not used yet.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Delta
|
internal class MouseMoveData
|
||||||
{
|
|
||||||
get { return delta; }
|
|
||||||
internal set { delta = value; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MouseMoveData
|
|
||||||
{
|
{
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
private int deltaX;
|
private int deltaX;
|
||||||
private int deltaY;
|
private int deltaY;
|
||||||
private MouseWheel wheel;
|
private int wheel, deltaWheel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the absolute X position of the mouse in screen pixel coordinates.
|
/// Gets the absolute X position of the mouse in screen pixel coordinates.
|
||||||
|
@ -220,10 +272,12 @@ namespace OpenTK.Input
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets data relevant to the mouse wheel.
|
/// Gets data relevant to the mouse wheel.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MouseWheel Wheel
|
//public MouseWheel Wheel
|
||||||
{
|
//{
|
||||||
get { return wheel; }
|
// get { return wheel; }
|
||||||
internal set { wheel = value; }
|
// internal set { wheel = value; }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
Loading…
Reference in a new issue