diff --git a/OpenTK/GameWindow.cs b/OpenTK/GameWindow.cs
index f0ce00fb3..a8b67872a 100644
--- a/OpenTK/GameWindow.cs
+++ b/OpenTK/GameWindow.cs
@@ -455,18 +455,6 @@ namespace OpenTK
#endregion
- #region Joysticks
-
- ///
- /// Gets a readonly IList containing all available OpenTK.Input.JoystickDevices.
- ///
- public IList Joysticks
- {
- get { return InputDriver.Joysticks; }
- }
-
- #endregion
-
#region Keyboard
///
diff --git a/OpenTK/Input/Interfaces.cs b/OpenTK/Input/Interfaces.cs
index 8729d3fcf..6b2945d65 100644
--- a/OpenTK/Input/Interfaces.cs
+++ b/OpenTK/Input/Interfaces.cs
@@ -5,7 +5,6 @@
#endregion
using System;
-using System.Collections.Generic;
using System.Drawing;
namespace OpenTK.Input {
@@ -23,30 +22,17 @@ namespace OpenTK.Input {
Keyboard,
/// Device is a mouse.
Mouse,
- /// Device is a Human Interface Device. Joysticks, joypads, pens
- /// and some specific usb keyboards/mice fall into this category.
- Hid
}
/// Defines the interface for an input driver.
- public interface IInputDriver : IJoystickDriver, IDisposable {
+ public interface IInputDriver : IDisposable {
- /// Gets the list of available KeyboardDevices.
+ /// Gets the available KeyboardDevice.
KeyboardDevice Keyboard { get; }
- /// Gets the list of available MouseDevices.
+ /// Gets the available MouseDevice.
MouseDevice Mouse { get; }
- /// Updates the state of the driver.
- void Poll();
-
Point DesktopCursorPos { get; set; }
}
-
- /// Defines the interface for JoystickDevice drivers.
- public interface IJoystickDriver {
-
- /// Gets the list of available JoystickDevices.
- IList Joysticks { get; }
- }
}
diff --git a/OpenTK/Input/JoystickDevice.cs b/OpenTK/Input/JoystickDevice.cs
deleted file mode 100644
index 1c7c7b9bc..000000000
--- a/OpenTK/Input/JoystickDevice.cs
+++ /dev/null
@@ -1,471 +0,0 @@
-#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;
-
-namespace OpenTK.Input
-{
- ///
- /// Represents a joystick device and provides methods to query its status.
- ///
- public abstract class JoystickDevice : IInputDevice
- {
- #region Fields
-
- int id;
- string description;
- JoystickAxisCollection axis_collection;
- JoystickButtonCollection button_collection;
- JoystickMoveEventArgs move_args = new JoystickMoveEventArgs(0, 0, 0);
- JoystickButtonEventArgs button_args = new JoystickButtonEventArgs(0, false);
-
- #endregion
-
- #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_collection = new JoystickAxisCollection(axes);
- button_collection = new JoystickButtonCollection(buttons);
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets a JoystickAxisCollection containing the state of each axis on this instance. Values are normalized in the [-1, 1] range.
- ///
- public JoystickAxisCollection Axis { get { return axis_collection; } }
-
- ///
- /// Gets JoystickButtonCollection containing the state of each button on this instance. True indicates that the button is pressed.
- ///
- public JoystickButtonCollection Button { get { return button_collection; } }
-
- #endregion
-
- #region IInputDevice Members
-
- ///
- /// Gets a System.String containing a unique description for this instance.
- ///
- 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; }
- }
-
- #endregion
-
- #region Events
-
- ///
- /// Occurs when an axis of this JoystickDevice instance is moved.
- ///
- public EventHandler Move =
- delegate(object sender, JoystickMoveEventArgs e) { };
-
- ///
- /// Occurs when a button of this JoystickDevice instance is pressed.
- ///
- public EventHandler ButtonDown =
- delegate(object sender, JoystickButtonEventArgs e) { };
-
- ///
- /// Occurs when a button of this JoystickDevice is released.
- ///
- public EventHandler ButtonUp =
- delegate(object sender, JoystickButtonEventArgs e) { };
-
- #endregion
-
- #region Internal Members
-
- internal int Id
- {
- get { return id; }
- set { id = value; }
- }
-
- internal void SetAxis(JoystickAxis axis, float @value)
- {
- move_args.Axis = axis;
- move_args.Delta = move_args.Value - @value;
- axis_collection[axis] = move_args.Value = @value;
- Move(this, move_args);
- }
-
- internal void SetButton(JoystickButton button, bool @value)
- {
- if (button_collection[button] != @value)
- {
- button_args.Button = button;
- button_collection[button] = button_args.Pressed = @value;
- if (@value)
- ButtonDown(this, button_args);
- else
- ButtonUp(this, button_args);
- }
- }
-
- #endregion
- }
-
- #region JoystickDevice : JoystickDevice
-
- // Provides platform-specific information about the relevant JoystickDevice.
- internal sealed class JoystickDevice : JoystickDevice
- {
- internal JoystickDevice(int id, int axes, int buttons)
- : base(id, axes, buttons)
- { }
-
- internal TDetail Details;
- }
-
- #endregion
-
- #region Event Arguments
-
- ///
- /// The base class for JoystickDevice event arguments.
- ///
- public class JoystickEventArgs : EventArgs
- {
- }
-
- ///
- /// Provides data for the and events.
- /// This class is cached for performance reasons - avoid storing references outside the scope of the event.
- ///
- public class JoystickButtonEventArgs : EventArgs
- {
- #region Fields
-
- JoystickButton button;
- bool pressed;
-
- #endregion
-
- #region Constructors
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The index of the joystick button for the event.
- /// The current state of the button.
- internal JoystickButtonEventArgs(JoystickButton button, bool pressed)
- {
- this.button = button;
- this.pressed = pressed;
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// The index of the joystick button for the event.
- ///
- public JoystickButton Button { get { return this.button; } internal set { this.button = value; } }
-
- ///
- /// Gets a System.Boolean representing the state of the button for the event.
- ///
- public bool Pressed { get { return pressed; } internal set { this.pressed = value; } }
-
- #endregion
- }
-
- ///
- /// Provides data for the event.
- /// This class is cached for performance reasons - avoid storing references outside the scope of the event.
- ///
- public class JoystickMoveEventArgs : JoystickEventArgs
- {
- #region Fields
-
- JoystickAxis axis;
- float value;
- float delta;
-
- #endregion
-
- #region Constructors
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The index of the joystick axis that was moved.
- /// The absolute value of the joystick axis.
- /// The relative change in value of the joystick axis.
- public JoystickMoveEventArgs(JoystickAxis axis, float value, float delta)
- {
- this.axis = axis;
- this.value = value;
- this.delta = delta;
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets a System.Int32 representing the index of the axis that was moved.
- ///
- public JoystickAxis Axis { get { return axis; } internal set { this.axis = value; } }
-
- ///
- /// Gets a System.Single representing the absolute position of the axis.
- ///
- public float Value { get { return value; } internal set { this.value = value; } }
-
- ///
- /// Gets a System.Single representing the relative change in the position of the axis.
- ///
- public float Delta { get { return delta; } internal set { this.delta = value; } }
-
- #endregion
- }
-
- #endregion
-
- #region JoystickButton
-
- ///
- /// Defines available JoystickDevice buttons.
- ///
- public enum JoystickButton
- {
- /// The first button of the JoystickDevice.
- Button0 = 0,
- /// The second button of the JoystickDevice.
- Button1,
- /// The third button of the JoystickDevice.
- Button2,
- /// The fourth button of the JoystickDevice.
- Button3,
- /// The fifth button of the JoystickDevice.
- Button4,
- /// The sixth button of the JoystickDevice.
- Button5,
- /// The seventh button of the JoystickDevice.
- Button6,
- /// The eighth button of the JoystickDevice.
- Button7,
- /// The ninth button of the JoystickDevice.
- Button8,
- /// The tenth button of the JoystickDevice.
- Button9,
- /// The eleventh button of the JoystickDevice.
- Button10,
- /// The twelfth button of the JoystickDevice.
- Button11,
- /// The thirteenth button of the JoystickDevice.
- Button12,
- /// The fourteenth button of the JoystickDevice.
- Button13,
- /// The fifteenth button of the JoystickDevice.
- Button14,
- /// The sixteenth button of the JoystickDevice.
- Button15,
- }
-
- #endregion
-
- #region JoystickButtonCollection
-
- ///
- /// Defines a collection of JoystickButtons.
- ///
- public sealed class JoystickButtonCollection
- {
- #region Fields
-
- bool[] button_state;
-
- #endregion
-
- #region Constructors
-
- internal JoystickButtonCollection(int numButtons)
- {
- if (numButtons < 0)
- throw new ArgumentOutOfRangeException("numButtons");
-
- button_state = new bool[numButtons];
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets a System.Boolean indicating whether the JoystickButton with the specified index is pressed.
- ///
- /// The index of the JoystickButton to check.
- /// True if the JoystickButton is pressed; false otherwise.
- public bool this[int index]
- {
- get { return button_state[index]; }
- internal set { button_state[index] = value; }
- }
-
- ///
- /// Gets a System.Boolean indicating whether the specified JoystickButton is pressed.
- ///
- /// The JoystickButton to check.
- /// True if the JoystickButton is pressed; false otherwise.
- public bool this[JoystickButton button]
- {
- get { return button_state[(int)button]; }
- internal set { button_state[(int)button] = value; }
- }
-
- ///
- /// Gets a System.Int32 indicating the available amount of JoystickButtons.
- ///
- public int Count
- {
- get { return button_state.Length; }
- }
-
- #endregion
- }
-
- #endregion
-
- #region JoystickAxis
-
- ///
- /// Defines available JoystickDevice axes.
- ///
- public enum JoystickAxis
- {
- /// The first axis of the JoystickDevice.
- Axis0 = 0,
- /// The second axis of the JoystickDevice.
- Axis1,
- /// The third axis of the JoystickDevice.
- Axis2,
- /// The fourth axis of the JoystickDevice.
- Axis3,
- /// The fifth axis of the JoystickDevice.
- Axis4,
- /// The sixth axis of the JoystickDevice.
- Axis5,
- /// The seventh axis of the JoystickDevice.
- Axis6,
- /// The eighth axis of the JoystickDevice.
- Axis7,
- /// The ninth axis of the JoystickDevice.
- Axis8,
- /// The tenth axis of the JoystickDevice.
- Axis9,
- }
-
- #endregion
-
- #region JoystickAxisCollection
-
- ///
- /// Defines a collection of JoystickAxes.
- ///
- public sealed class JoystickAxisCollection
- {
- #region Fields
-
- float[] axis_state;
-
- #endregion
-
- #region Constructors
-
- internal JoystickAxisCollection(int numAxes)
- {
- if (numAxes < 0)
- throw new ArgumentOutOfRangeException("numAxes");
-
- axis_state = new float[numAxes];
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets a System.Single indicating the absolute position of the JoystickAxis with the specified index.
- ///
- /// The index of the JoystickAxis to check.
- /// A System.Single in the range [-1, 1].
- public float this[int index]
- {
- get { return axis_state[index]; }
- internal set { axis_state[index] = value; }
- }
-
- ///
- /// Gets a System.Single indicating the absolute position of the JoystickAxis.
- ///
- /// The JoystickAxis to check.
- /// A System.Single in the range [-1, 1].
- public float this[JoystickAxis axis]
- {
- get { return axis_state[(int)axis]; }
- internal set { axis_state[(int)axis] = value; }
- }
-
- ///
- /// Gets a System.Int32 indicating the available amount of JoystickAxes.
- ///
- public int Count
- {
- get { return axis_state.Length; }
- }
-
- #endregion
- }
-
- #endregion
-}
diff --git a/OpenTK/OpenTK.csproj b/OpenTK/OpenTK.csproj
index f918e9d85..cac240524 100644
--- a/OpenTK/OpenTK.csproj
+++ b/OpenTK/OpenTK.csproj
@@ -73,7 +73,6 @@
-
@@ -105,7 +104,6 @@
-
@@ -116,7 +114,6 @@
-
diff --git a/OpenTK/Platform/MacOS/CarbonGLNative.cs b/OpenTK/Platform/MacOS/CarbonGLNative.cs
index 296f1d281..7a590c122 100644
--- a/OpenTK/Platform/MacOS/CarbonGLNative.cs
+++ b/OpenTK/Platform/MacOS/CarbonGLNative.cs
@@ -106,7 +106,6 @@ namespace OpenTK.Platform.MacOS
new Rect((short)x, (short)y, (short)width, (short)height));
mDisplayDevice = device;
- dummy_joystick_list.Add(new JoystickDevice
internal sealed class X11Input : IInputDriver
{
- X11Joystick joystick_driver = new X11Joystick();
KeyboardDevice keyboard = new KeyboardDevice();
MouseDevice mouse = new MouseDevice();
@@ -151,15 +150,6 @@ namespace OpenTK.Platform.X11
set { System.Windows.Forms.Cursor.Position = value; }
}
- public IList Joysticks {
- get { return joystick_driver.Joysticks; }
- }
-
- /// Polls and updates state of all keyboard, mouse and joystick devices.
- public void Poll() {
- joystick_driver.Poll();
- }
-
#endregion
public void Dispose() {
diff --git a/OpenTK/Platform/X11/X11Joystick.cs b/OpenTK/Platform/X11/X11Joystick.cs
deleted file mode 100644
index c073ef19e..000000000
--- a/OpenTK/Platform/X11/X11Joystick.cs
+++ /dev/null
@@ -1,252 +0,0 @@
-#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.Diagnostics;
-using System.Runtime.InteropServices;
-using OpenTK.Input;
-
-namespace OpenTK.Platform.X11
-{
- struct X11JoyDetails { }
-
- sealed class X11Joystick : IJoystickDriver
- {
- #region Fields
-
- List sticks = new List();
- IList sticks_readonly;
-
- bool disposed;
-
- #endregion
-
- #region Constructors
-
- public X11Joystick()
- {
- sticks_readonly = sticks.AsReadOnly();
-
- int number = 0, max_sticks = 25;
- while (number < max_sticks)
- {
- JoystickDevice stick = OpenJoystick(JoystickPath, number++);
- if (stick != null)
- {
- stick.Description = String.Format("USB Joystick {0} ({1} axes, {2} buttons, {3}{0})",
- number, stick.Axis.Count, stick.Button.Count, JoystickPath);
- sticks.Add(stick);
- }
- }
-
- number = 0;
- while (number < max_sticks)
- {
- JoystickDevice stick = OpenJoystick(JoystickPathLegacy, number++);
- if (stick != null)
- {
- stick.Description = String.Format("USB Joystick {0} ({1} axes, {2} buttons, {3}{0})",
- number, stick.Axis.Count, stick.Button.Count, JoystickPathLegacy);
- sticks.Add(stick);
- }
- }
- }
-
- #endregion
-
- #region IJoystickDriver
-
- public int DeviceCount
- {
- get { return sticks.Count; }
- }
-
- public IList Joysticks
- {
- get { return sticks_readonly; }
- }
-
- public void Poll()
- {
- JoystickEvent e;
-
- foreach (JoystickDevice js in sticks)
- {
- unsafe
- {
- while ((long)UnsafeNativeMethods.read(js.Id, (void*)&e, (UIntPtr)sizeof(JoystickEvent)) > 0)
- {
- e.Type &= ~JoystickEventType.Init;
-
- switch (e.Type)
- {
- case JoystickEventType.Axis:
- // Flip vertical axes so that +1 point up.
- if (e.Number % 2 == 0)
- js.SetAxis((JoystickAxis)e.Number, e.Value / 32767.0f);
- else
- js.SetAxis((JoystickAxis)e.Number, -e.Value / 32767.0f);
- break;
-
- case JoystickEventType.Button:
- js.SetButton((JoystickButton)e.Number, e.Value != 0);
- break;
- }
- }
- }
- }
- }
-
- #endregion
-
- #region Private Members
-
- JoystickDevice OpenJoystick(string base_path, int number)
- {
- string path = base_path + number.ToString();
- JoystickDevice stick = null;
-
- int fd = -1;
- try
- {
- fd = UnsafeNativeMethods.open(path, OpenFlags.NonBlock);
- if (fd == -1)
- return null;
-
- // Check joystick driver version (must be 1.0+)
- int driver_version = 0x00000800;
- UnsafeNativeMethods.ioctl(fd, JoystickIoctlCode.Version, ref driver_version);
- if (driver_version < 0x00010000)
- return null;
-
- // Get number of joystick axes
- int axes = 0;
- UnsafeNativeMethods.ioctl(fd, JoystickIoctlCode.Axes, ref axes);
-
- // Get number of joystick buttons
- int buttons = 0;
- UnsafeNativeMethods.ioctl(fd, JoystickIoctlCode.Buttons, ref buttons);
-
- stick = new JoystickDevice(fd, axes, buttons);
- Debug.Print("Found joystick on path {0}", path);
- }
- finally
- {
- if (stick == null && fd != -1)
- UnsafeNativeMethods.close(fd);
- }
-
- return stick;
- }
-
- #region UnsafeNativeMethods
-
- struct JoystickEvent
- {
- public uint Time; // (u32) event timestamp in milliseconds
- public short Value; // (s16) value
- public JoystickEventType Type; // (u8) event type
- public byte Number; // (u8) axis/button number
- }
-
- [Flags]
- enum JoystickEventType : byte
- {
- Button = 0x01, // button pressed/released
- Axis = 0x02, // joystick moved
- Init = 0x80 // initial state of device
- }
-
- enum JoystickIoctlCode : uint
- {
- Version = 0x80046a01,
- Axes = 0x80016a11,
- Buttons = 0x80016a12
- }
-
- static readonly string JoystickPath = "/dev/input/js";
- static readonly string JoystickPathLegacy = "/dev/js";
-
- [Flags]
- enum OpenFlags
- {
- NonBlock = 0x00000800
- }
-
- static class UnsafeNativeMethods
- {
- [DllImport("libc", SetLastError = true)]
- public static extern int ioctl(int d, JoystickIoctlCode request, ref int data);
-
- [DllImport("libc", SetLastError = true)]
- public static extern int open([MarshalAs(UnmanagedType.LPStr)]string pathname, OpenFlags flags);
-
- [DllImport("libc", SetLastError = true)]
- public static extern int close(int fd);
-
- [DllImport("libc", SetLastError = true)]
- unsafe public static extern IntPtr read(int fd, void* buffer, UIntPtr count);
- }
-
- #endregion
-
- #endregion
-
- #region IDisposable Members
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- void Dispose(bool manual)
- {
- if (!disposed)
- {
- if (manual)
- {
- }
-
- foreach (JoystickDevice js in sticks)
- {
- UnsafeNativeMethods.close(js.Id);
- }
-
- disposed = true;
- }
- }
-
- ~X11Joystick()
- {
- Dispose(false);
- }
-
- #endregion
- }
-}