mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 20:05:39 +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
|
||||
{
|
||||
public sealed class Keyboard : IKeyboard
|
||||
public sealed class KeyboardDevice : IInputDevice
|
||||
{
|
||||
//private IKeyboard keyboard;
|
||||
private bool[] keys = new bool[(int)Key.MaxKeys];
|
||||
|
@ -26,7 +26,7 @@ namespace OpenTK.Input
|
|||
|
||||
#region --- Constructors ---
|
||||
|
||||
public Keyboard()
|
||||
public KeyboardDevice()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -34,39 +34,53 @@ namespace OpenTK.Input
|
|||
|
||||
#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
|
||||
{
|
||||
if (keys[(int)k] != value || KeyRepeat)
|
||||
if (keys[(int)key] != value || KeyRepeat)
|
||||
{
|
||||
keys[(int)k] = value;
|
||||
keys[(int)key] = value;
|
||||
|
||||
if (value && KeyDown != null)
|
||||
{
|
||||
KeyDown(this, k);
|
||||
KeyDown(this, key);
|
||||
}
|
||||
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
|
||||
{
|
||||
get { return numKeys; }
|
||||
internal set { numKeys = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an integer representing the number of function keys (F-keys) on this KeyboardDevice.
|
||||
/// </summary>
|
||||
public int NumberOfFunctionKeys
|
||||
{
|
||||
get { return numFKeys; }
|
||||
internal set { numFKeys = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating the number of led indicators on this KeyboardDevice.
|
||||
/// </summary>
|
||||
public int NumberOfLeds
|
||||
{
|
||||
get { return numLeds; }
|
||||
|
@ -74,7 +88,7 @@ namespace OpenTK.Input
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Device dependent ID.
|
||||
/// Gets an IntPtr representing a device dependent ID.
|
||||
/// </summary>
|
||||
public IntPtr DeviceID
|
||||
{
|
||||
|
@ -85,7 +99,7 @@ namespace OpenTK.Input
|
|||
#region public bool KeyRepeat
|
||||
|
||||
/// <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>
|
||||
/// <remarks>
|
||||
/// 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()
|
||||
{
|
||||
//return base.ToString();
|
||||
return String.Format("ID: {0} (keys: {1}, function keys: {2}, leds: {3})",
|
||||
DeviceID, NumberOfKeys, NumberOfFunctionKeys, NumberOfLeds);
|
||||
return String.Format("ID: {0} ({1}). Keys: {2}, Function keys: {3}, Leds: {4}",
|
||||
DeviceID, Description, NumberOfKeys, NumberOfFunctionKeys, NumberOfLeds);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public delegate void KeyDownEvent(KeyboardDevice sender, Key key);
|
||||
public delegate void KeyUpEvent(KeyboardDevice sender, Key key);
|
||||
|
||||
#region public enum Key : int
|
||||
|
||||
/// <summary>
|
|
@ -10,7 +10,10 @@ using System.Text;
|
|||
|
||||
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 int numButtons, numWheels;
|
||||
|
@ -20,12 +23,18 @@ namespace OpenTK.Input
|
|||
|
||||
#region --- IInputDevice Members ---
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string describing this MouseDevice.
|
||||
/// </summary>
|
||||
public string Description
|
||||
{
|
||||
get { return description; }
|
||||
internal set { description = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an value indicating the InputDeviceType of this InputDevice.
|
||||
/// </summary>
|
||||
public InputDeviceType DeviceType
|
||||
{
|
||||
get { return InputDeviceType.Mouse; }
|
||||
|
@ -35,24 +44,36 @@ namespace OpenTK.Input
|
|||
|
||||
#region --- IMouse Members ---
|
||||
|
||||
/// <summary>
|
||||
/// Gets an integer representing the number of buttons on this MouseDevice.
|
||||
/// </summary>
|
||||
public int NumberOfButtons
|
||||
{
|
||||
get { return numButtons; }
|
||||
internal set { numButtons = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an integer representing the number of wheels on this MouseDevice.
|
||||
/// </summary>
|
||||
public int NumberOfWheels
|
||||
{
|
||||
get { return numWheels; }
|
||||
internal set { numWheels = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an IntPtr representing a device dependent ID.
|
||||
/// </summary>
|
||||
public IntPtr DeviceID
|
||||
{
|
||||
get { return id; }
|
||||
internal set { id = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an integer representing the absolute wheel position.
|
||||
/// </summary>
|
||||
public int 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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
get { return x; }
|
||||
internal set { x = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an integer representing the absolute y position of the pointer, in screen pixel coordinates.
|
||||
/// </summary>
|
||||
public int Y
|
||||
{
|
||||
get { return y; }
|
||||
internal set { y = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an integer representing the relative x movement of the pointer, in pixel coordinates.
|
||||
/// </summary>
|
||||
public int XDelta
|
||||
{
|
||||
get { return delta_x; }
|
||||
internal set { delta_x = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an integer representing the relative y movement of the pointer, in pixel coordinates.
|
||||
/// </summary>
|
||||
public int YDelta
|
||||
{
|
||||
get { return delta_y; }
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a button is released.
|
||||
/// </summary>
|
||||
public event MouseButtonUpEvent ButtonUp;
|
||||
|
||||
#endregion
|
||||
|
@ -121,8 +165,8 @@ namespace OpenTK.Input
|
|||
ButtonUp(this, b);
|
||||
}
|
||||
button[(int)b] = value;
|
||||
//System.Diagnostics.Debug.Print("Mouse button {0} {1}", b, value ? "down" : "up");
|
||||
}
|
||||
|
||||
get
|
||||
{
|
||||
return button[(int)b];
|
||||
|
@ -130,8 +174,33 @@ namespace OpenTK.Input
|
|||
}
|
||||
|
||||
#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
|
||||
{
|
||||
Left = 0,
|
||||
|
@ -149,37 +218,20 @@ namespace OpenTK.Input
|
|||
LastButton
|
||||
}
|
||||
|
||||
public class MouseWheel
|
||||
{
|
||||
private int position;
|
||||
private int delta;
|
||||
#endregion
|
||||
|
||||
#region internal class MouseMoveData
|
||||
|
||||
/// <summary>
|
||||
/// Gets the absolute position of the mouse wheel.
|
||||
/// Not used yet.
|
||||
/// </summary>
|
||||
public int Position
|
||||
{
|
||||
get { return position; }
|
||||
internal set { position = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the relative movement of the mouse wheel.
|
||||
/// </summary>
|
||||
public int Delta
|
||||
{
|
||||
get { return delta; }
|
||||
internal set { delta = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public class MouseMoveData
|
||||
internal class MouseMoveData
|
||||
{
|
||||
private int x;
|
||||
private int y;
|
||||
private int deltaX;
|
||||
private int deltaY;
|
||||
private MouseWheel wheel;
|
||||
private int wheel, deltaWheel;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the absolute X position of the mouse in screen pixel coordinates.
|
||||
|
@ -220,10 +272,12 @@ namespace OpenTK.Input
|
|||
/// <summary>
|
||||
/// Gets data relevant to the mouse wheel.
|
||||
/// </summary>
|
||||
public MouseWheel Wheel
|
||||
{
|
||||
get { return wheel; }
|
||||
internal set { wheel = value; }
|
||||
}
|
||||
//public MouseWheel Wheel
|
||||
//{
|
||||
// get { return wheel; }
|
||||
// internal set { wheel = value; }
|
||||
//}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
Loading…
Reference in a new issue