diff --git a/Source/OpenTK/Input/IInputDevice.cs b/Source/OpenTK/Input/IInputDevice.cs
index c4c6829f..c27fe1d2 100644
--- a/Source/OpenTK/Input/IInputDevice.cs
+++ b/Source/OpenTK/Input/IInputDevice.cs
@@ -10,9 +10,19 @@ using System.Text;
namespace OpenTK.Input
{
+ ///
+ /// Defines a common interface for all input devices.
+ ///
public interface IInputDevice
{
+ ///
+ /// Gets a System.String with a unique description of this IInputDevice instance.
+ ///
string Description { get; }
+
+ ///
+ /// Gets an OpenTK.Input.InputDeviceType value, representing the device type of this IInputDevice instance.
+ ///
InputDeviceType DeviceType { get; }
}
@@ -33,6 +43,6 @@ namespace OpenTK.Input
/// Device is a Human Interface Device. Joysticks, joypads, pens
/// and some specific usb keyboards/mice fall into this category.
///
- HID
+ Hid
}
}
diff --git a/Source/OpenTK/Input/IInputDriver.cs b/Source/OpenTK/Input/IInputDriver.cs
index c2ad0a2e..327ee1fa 100644
--- a/Source/OpenTK/Input/IInputDriver.cs
+++ b/Source/OpenTK/Input/IInputDriver.cs
@@ -10,9 +10,8 @@ using System.Text;
namespace OpenTK.Input
{
- public interface IInputDriver : IKeyboardDriver, IMouseDriver, IDisposable
+ public interface IInputDriver : IKeyboardDriver, IMouseDriver, IJoystickDriver, IDisposable
{
- //IList InputDevices { get; }
void Poll();
}
}
diff --git a/Source/OpenTK/Input/IJoystickDriver.cs b/Source/OpenTK/Input/IJoystickDriver.cs
new file mode 100644
index 00000000..ecc6bbcd
--- /dev/null
+++ b/Source/OpenTK/Input/IJoystickDriver.cs
@@ -0,0 +1,44 @@
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2008 the Open Toolkit library, except where noted.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenTK.Input
+{
+ ///
+ /// Defines the interface for JoystickDevice drivers.
+ ///
+ public interface IJoystickDriver
+ {
+ ///
+ /// Gets the list of available JoystickDevices.
+ ///
+ IList Joysticks { get; }
+ }
+}
diff --git a/Source/OpenTK/Input/IKeyboardDriver.cs b/Source/OpenTK/Input/IKeyboardDriver.cs
index 368edd28..e14493f9 100644
--- a/Source/OpenTK/Input/IKeyboardDriver.cs
+++ b/Source/OpenTK/Input/IKeyboardDriver.cs
@@ -10,8 +10,14 @@ using System.Text;
namespace OpenTK.Input
{
+ ///
+ /// Defines the interface for KeyboardDevice drivers.
+ ///
public interface IKeyboardDriver
{
+ ///
+ /// Gets the list of available KeyboardDevices.
+ ///
IList Keyboard { get; }
}
}
diff --git a/Source/OpenTK/Input/IMouseDriver.cs b/Source/OpenTK/Input/IMouseDriver.cs
index 7a47c25f..52abe7af 100644
--- a/Source/OpenTK/Input/IMouseDriver.cs
+++ b/Source/OpenTK/Input/IMouseDriver.cs
@@ -10,10 +10,13 @@ using System.Text;
namespace OpenTK.Input
{
+ ///
+ /// Defines the interface for MouseDevice drivers.
+ ///
public interface IMouseDriver
{
///
- /// Gets the list of available mouse devices.
+ /// Gets the list of available MouseDevices.
///
IList Mouse { get; }
}
diff --git a/Source/OpenTK/Input/InputDriver.cs b/Source/OpenTK/Input/InputDriver.cs
index 060b75d8..a1087842 100644
--- a/Source/OpenTK/Input/InputDriver.cs
+++ b/Source/OpenTK/Input/InputDriver.cs
@@ -59,26 +59,38 @@ namespace OpenTK
#region --- IInputDriver Members ---
+ public void Poll()
+ {
+ inputDriver.Poll();
+ }
+
+ #endregion
+
+ #region --- IKeyboardDriver Members ---
+
public IList Keyboard
{
get { return inputDriver.Keyboard; }
}
+ #endregion
+
+ #region --- IMouseDriver Members ---
+
public IList Mouse
{
get { return inputDriver.Mouse; }
}
- public void Poll()
+ #endregion
+
+ #region --- IJoystickDriver Members ---
+
+ public IList Joysticks
{
- inputDriver.Poll();
+ get { return inputDriver.Joysticks; }
}
- /*
- int IMouseDriver.RegisterDevices()
- {
- return inputDriver.RegisterDevices();
- }
- */
+
#endregion
#region --- IDisposable Members ---
diff --git a/Source/OpenTK/Input/JoystickDevice.cs b/Source/OpenTK/Input/JoystickDevice.cs
index 105e5290..9287a926 100644
--- a/Source/OpenTK/Input/JoystickDevice.cs
+++ b/Source/OpenTK/Input/JoystickDevice.cs
@@ -1,49 +1,121 @@
-using System;
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2008 the Open Toolkit library, except where noted.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+#endregion
+
+using System;
using System.Collections.Generic;
-using System.Text;
-using OpenTK.Math;
namespace OpenTK.Input
{
-#if false
- ///
- /// Represents a joystick device and provides methods to query its state.
- ///
- public class JoystickDevice : IInputDevice
+ public abstract class JoystickDevice : IInputDevice
{
+ #region Fields
+
+ int id;
string description;
- Vector2[] axis_position;
+ List axis = new List();
+ List button = new List();
+ IList axis_readonly;
+ IList button_readonly;
- #region --- IInputDevice Members ---
+ #endregion
- ///
- /// Gets a string describing this JoystickDevice.
- ///
+ #region Constructors
+
+ internal JoystickDevice(int id, int axes, int buttons)
+ {
+ if (axes <= 0)
+ throw new ArgumentOutOfRangeException("axes");
+
+ if (buttons <= 0)
+ throw new ArgumentOutOfRangeException("buttons");
+
+ Id = id;
+ axis.AddRange(new float[axes]);
+ button.AddRange(new bool[buttons]);
+
+ axis_readonly = axis.AsReadOnly();
+ button_readonly = button.AsReadOnly();
+ }
+
+ #endregion
+
+ #region Public Members
+
+ public IList Axis { get { return axis_readonly; } }
+
+ public IList Button { get { return button_readonly; } }
+
+ #endregion
+
+ #region IInputDevice Members
+
public string Description
{
get { return description; }
internal set { description = value; }
}
- ///
- /// Gets a value indicating the InputDeviceType of this InputDevice.
- ///
public InputDeviceType DeviceType
{
- get { return InputDeviceType.HID; }
+ get { return InputDeviceType.Hid; }
}
#endregion
- #region --- Public Methods ---
+ #region Internal Members
- //public Vector2 Axis1
- //{
- // get { return axis_position.Clone(); }
- // internal set {
- //}
+ internal int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ internal void SetAxis(int num, float @value)
+ {
+ axis[num] = @value;
+ }
+
+ internal void SetButton(int num, bool @value)
+ {
+ button[num] = @value;
+ }
#endregion
}
-#endif
+
+ // Provides platform-specific information about the relevant JoystickDevice.
+ internal sealed class JoystickDevice : JoystickDevice
+ {
+ TDetail details;
+
+ internal JoystickDevice(int id, int axes, int buttons)
+ : base(id, axes, buttons)
+ { }
+
+ internal TDetail Details { get { return details; } set { details = value; } }
+ }
}
diff --git a/Source/OpenTK/Platform/MacOS/CarbonInput.cs b/Source/OpenTK/Platform/MacOS/CarbonInput.cs
index f8cad89a..b8d08b51 100644
--- a/Source/OpenTK/Platform/MacOS/CarbonInput.cs
+++ b/Source/OpenTK/Platform/MacOS/CarbonInput.cs
@@ -11,13 +11,15 @@ namespace OpenTK.Platform.MacOS
{
List dummy_keyboard_list = new List(1);
List dummy_mice_list = new List(1);
+ List dummy_joystick_list = new List(1);
internal CarbonInput()
{
dummy_mice_list.Add(new MouseDevice());
dummy_keyboard_list.Add(new KeyboardDevice());
-
+ dummy_joystick_list.Add(new JoystickDevice