mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 03:05:30 +00:00
Added IJoystickDevice2 interface
This commit is contained in:
parent
78078d0742
commit
5215891a4f
|
@ -34,11 +34,6 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
public struct GamePadCapabilities : IEquatable<GamePadCapabilities>
|
public struct GamePadCapabilities : IEquatable<GamePadCapabilities>
|
||||||
{
|
{
|
||||||
byte axis_count;
|
|
||||||
byte button_count;
|
|
||||||
byte dpad_count;
|
|
||||||
byte trackball_count;
|
|
||||||
|
|
||||||
Buttons buttons;
|
Buttons buttons;
|
||||||
byte gamepad_type;
|
byte gamepad_type;
|
||||||
bool is_connected;
|
bool is_connected;
|
||||||
|
@ -221,34 +216,6 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Internal Members
|
|
||||||
|
|
||||||
internal int AxisCount
|
|
||||||
{
|
|
||||||
get { return axis_count; }
|
|
||||||
set { axis_count = (byte)value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal int ButtonCount
|
|
||||||
{
|
|
||||||
get { return button_count; }
|
|
||||||
set { button_count = (byte)value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal int DPadCount
|
|
||||||
{
|
|
||||||
get { return dpad_count; }
|
|
||||||
set { dpad_count = (byte)value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal int TrackballCount
|
|
||||||
{
|
|
||||||
get { return trackball_count; }
|
|
||||||
set { trackball_count = (byte)value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IEquatable<GamePadCapabilities> Members
|
#region IEquatable<GamePadCapabilities> Members
|
||||||
|
|
||||||
public bool Equals(GamePadCapabilities other)
|
public bool Equals(GamePadCapabilities other)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// #region License
|
#region License
|
||||||
//
|
//
|
||||||
// GamePadType.cs
|
// GamePadType.cs
|
||||||
//
|
//
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
//
|
//
|
||||||
// #endregion
|
#endregion
|
||||||
|
|
||||||
namespace OpenTK.Input
|
namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,5 +37,6 @@ namespace OpenTK.Input
|
||||||
IMouseDriver2 MouseDriver { get; }
|
IMouseDriver2 MouseDriver { get; }
|
||||||
IKeyboardDriver2 KeyboardDriver { get; }
|
IKeyboardDriver2 KeyboardDriver { get; }
|
||||||
IGamePadDriver GamePadDriver { get; }
|
IGamePadDriver GamePadDriver { get; }
|
||||||
|
IJoystickDriver2 JoystickDriver { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
41
Source/OpenTK/Input/IJoystickDriver2.cs
Normal file
41
Source/OpenTK/Input/IJoystickDriver2.cs
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#region License
|
||||||
|
//
|
||||||
|
// IJoystickDriver2.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Stefanos A. <stapostol@gmail.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2006-2013 Stefanos Apostolopoulos
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
interface IJoystickDriver2
|
||||||
|
{
|
||||||
|
JoystickState GetState(int index);
|
||||||
|
JoystickCapabilities GetCapabilities(int index);
|
||||||
|
}
|
||||||
|
}
|
51
Source/OpenTK/Input/Joystick.cs
Normal file
51
Source/OpenTK/Input/Joystick.cs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#region License
|
||||||
|
//
|
||||||
|
// Joystick.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Stefanos A. <stapostol@gmail.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2006-2013 Stefanos Apostolopoulos
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
public class Joystick
|
||||||
|
{
|
||||||
|
static readonly IJoystickDriver2 implementation =
|
||||||
|
Platform.Factory.Default.CreateJoystickDriver();
|
||||||
|
|
||||||
|
public static JoystickCapabilities GetCapabilities(int index)
|
||||||
|
{
|
||||||
|
return implementation.GetCapabilities(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JoystickState GetState(int index)
|
||||||
|
{
|
||||||
|
return implementation.GetState(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
62
Source/OpenTK/Input/JoystickAxis.cs
Normal file
62
Source/OpenTK/Input/JoystickAxis.cs
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
#region License
|
||||||
|
//
|
||||||
|
// JoystickAxis.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Stefanos A. <stapostol@gmail.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2006-2013 Stefanos Apostolopoulos
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines available JoystickDevice axes.
|
||||||
|
/// </summary>
|
||||||
|
public enum JoystickAxis
|
||||||
|
{
|
||||||
|
/// <summary>The first axis of the JoystickDevice.</summary>
|
||||||
|
Axis0 = 0,
|
||||||
|
/// <summary>The second axis of the JoystickDevice.</summary>
|
||||||
|
Axis1,
|
||||||
|
/// <summary>The third axis of the JoystickDevice.</summary>
|
||||||
|
Axis2,
|
||||||
|
/// <summary>The fourth axis of the JoystickDevice.</summary>
|
||||||
|
Axis3,
|
||||||
|
/// <summary>The fifth axis of the JoystickDevice.</summary>
|
||||||
|
Axis4,
|
||||||
|
/// <summary>The sixth axis of the JoystickDevice.</summary>
|
||||||
|
Axis5,
|
||||||
|
/// <summary>The seventh axis of the JoystickDevice.</summary>
|
||||||
|
Axis6,
|
||||||
|
/// <summary>The eighth axis of the JoystickDevice.</summary>
|
||||||
|
Axis7,
|
||||||
|
/// <summary>The ninth axis of the JoystickDevice.</summary>
|
||||||
|
Axis8,
|
||||||
|
/// <summary>The tenth axis of the JoystickDevice.</summary>
|
||||||
|
Axis9,
|
||||||
|
}
|
||||||
|
}
|
78
Source/OpenTK/Input/JoystickButton.cs
Normal file
78
Source/OpenTK/Input/JoystickButton.cs
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
#region License
|
||||||
|
//
|
||||||
|
// JoystickButton.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Stefanos A. <stapostol@gmail.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2006-2013 Stefanos Apostolopoulos
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
#region JoystickButton
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines available JoystickDevice buttons.
|
||||||
|
/// </summary>
|
||||||
|
public enum JoystickButton
|
||||||
|
{
|
||||||
|
/// <summary>The first button of the JoystickDevice.</summary>
|
||||||
|
Button0 = 0,
|
||||||
|
/// <summary>The second button of the JoystickDevice.</summary>
|
||||||
|
Button1,
|
||||||
|
/// <summary>The third button of the JoystickDevice.</summary>
|
||||||
|
Button2,
|
||||||
|
/// <summary>The fourth button of the JoystickDevice.</summary>
|
||||||
|
Button3,
|
||||||
|
/// <summary>The fifth button of the JoystickDevice.</summary>
|
||||||
|
Button4,
|
||||||
|
/// <summary>The sixth button of the JoystickDevice.</summary>
|
||||||
|
Button5,
|
||||||
|
/// <summary>The seventh button of the JoystickDevice.</summary>
|
||||||
|
Button6,
|
||||||
|
/// <summary>The eighth button of the JoystickDevice.</summary>
|
||||||
|
Button7,
|
||||||
|
/// <summary>The ninth button of the JoystickDevice.</summary>
|
||||||
|
Button8,
|
||||||
|
/// <summary>The tenth button of the JoystickDevice.</summary>
|
||||||
|
Button9,
|
||||||
|
/// <summary>The eleventh button of the JoystickDevice.</summary>
|
||||||
|
Button10,
|
||||||
|
/// <summary>The twelfth button of the JoystickDevice.</summary>
|
||||||
|
Button11,
|
||||||
|
/// <summary>The thirteenth button of the JoystickDevice.</summary>
|
||||||
|
Button12,
|
||||||
|
/// <summary>The fourteenth button of the JoystickDevice.</summary>
|
||||||
|
Button13,
|
||||||
|
/// <summary>The fifteenth button of the JoystickDevice.</summary>
|
||||||
|
Button14,
|
||||||
|
/// <summary>The sixteenth button of the JoystickDevice.</summary>
|
||||||
|
Button15,
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
75
Source/OpenTK/Input/JoystickCapabilities.cs
Normal file
75
Source/OpenTK/Input/JoystickCapabilities.cs
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
#region License
|
||||||
|
//
|
||||||
|
// JoystickCapabilities.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Stefanos A. <stapostol@gmail.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2006-2013 Stefanos Apostolopoulos
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
public struct JoystickCapabilities
|
||||||
|
{
|
||||||
|
byte axis_count;
|
||||||
|
byte button_count;
|
||||||
|
byte dpad_count;
|
||||||
|
byte trackball_count;
|
||||||
|
|
||||||
|
#region Public Members
|
||||||
|
|
||||||
|
public int AxisCount
|
||||||
|
{
|
||||||
|
get { return axis_count; }
|
||||||
|
set { axis_count = (byte)value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ButtonCount
|
||||||
|
{
|
||||||
|
get { return button_count; }
|
||||||
|
set { button_count = (byte)value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Members
|
||||||
|
|
||||||
|
int DPadCount
|
||||||
|
{
|
||||||
|
get { return dpad_count; }
|
||||||
|
set { dpad_count = (byte)value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
int TrackballCount
|
||||||
|
{
|
||||||
|
get { return trackball_count; }
|
||||||
|
set { trackball_count = (byte)value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -271,49 +271,6 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region JoystickButton
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Defines available JoystickDevice buttons.
|
|
||||||
/// </summary>
|
|
||||||
public enum JoystickButton
|
|
||||||
{
|
|
||||||
/// <summary>The first button of the JoystickDevice.</summary>
|
|
||||||
Button0 = 0,
|
|
||||||
/// <summary>The second button of the JoystickDevice.</summary>
|
|
||||||
Button1,
|
|
||||||
/// <summary>The third button of the JoystickDevice.</summary>
|
|
||||||
Button2,
|
|
||||||
/// <summary>The fourth button of the JoystickDevice.</summary>
|
|
||||||
Button3,
|
|
||||||
/// <summary>The fifth button of the JoystickDevice.</summary>
|
|
||||||
Button4,
|
|
||||||
/// <summary>The sixth button of the JoystickDevice.</summary>
|
|
||||||
Button5,
|
|
||||||
/// <summary>The seventh button of the JoystickDevice.</summary>
|
|
||||||
Button6,
|
|
||||||
/// <summary>The eighth button of the JoystickDevice.</summary>
|
|
||||||
Button7,
|
|
||||||
/// <summary>The ninth button of the JoystickDevice.</summary>
|
|
||||||
Button8,
|
|
||||||
/// <summary>The tenth button of the JoystickDevice.</summary>
|
|
||||||
Button9,
|
|
||||||
/// <summary>The eleventh button of the JoystickDevice.</summary>
|
|
||||||
Button10,
|
|
||||||
/// <summary>The twelfth button of the JoystickDevice.</summary>
|
|
||||||
Button11,
|
|
||||||
/// <summary>The thirteenth button of the JoystickDevice.</summary>
|
|
||||||
Button12,
|
|
||||||
/// <summary>The fourteenth button of the JoystickDevice.</summary>
|
|
||||||
Button13,
|
|
||||||
/// <summary>The fifteenth button of the JoystickDevice.</summary>
|
|
||||||
Button14,
|
|
||||||
/// <summary>The sixteenth button of the JoystickDevice.</summary>
|
|
||||||
Button15,
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region JoystickButtonCollection
|
#region JoystickButtonCollection
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -376,37 +333,6 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region JoystickAxis
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Defines available JoystickDevice axes.
|
|
||||||
/// </summary>
|
|
||||||
public enum JoystickAxis
|
|
||||||
{
|
|
||||||
/// <summary>The first axis of the JoystickDevice.</summary>
|
|
||||||
Axis0 = 0,
|
|
||||||
/// <summary>The second axis of the JoystickDevice.</summary>
|
|
||||||
Axis1,
|
|
||||||
/// <summary>The third axis of the JoystickDevice.</summary>
|
|
||||||
Axis2,
|
|
||||||
/// <summary>The fourth axis of the JoystickDevice.</summary>
|
|
||||||
Axis3,
|
|
||||||
/// <summary>The fifth axis of the JoystickDevice.</summary>
|
|
||||||
Axis4,
|
|
||||||
/// <summary>The sixth axis of the JoystickDevice.</summary>
|
|
||||||
Axis5,
|
|
||||||
/// <summary>The seventh axis of the JoystickDevice.</summary>
|
|
||||||
Axis6,
|
|
||||||
/// <summary>The eighth axis of the JoystickDevice.</summary>
|
|
||||||
Axis7,
|
|
||||||
/// <summary>The ninth axis of the JoystickDevice.</summary>
|
|
||||||
Axis8,
|
|
||||||
/// <summary>The tenth axis of the JoystickDevice.</summary>
|
|
||||||
Axis9,
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region JoystickAxisCollection
|
#region JoystickAxisCollection
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
79
Source/OpenTK/Input/JoystickState.cs
Normal file
79
Source/OpenTK/Input/JoystickState.cs
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
#region License
|
||||||
|
//
|
||||||
|
// JoystickState.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Stefanos A. <stapostol@gmail.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2006-2013 Stefanos Apostolopoulos
|
||||||
|
//
|
||||||
|
// 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.Text;
|
||||||
|
|
||||||
|
namespace OpenTK.Input
|
||||||
|
{
|
||||||
|
public struct JoystickState
|
||||||
|
{
|
||||||
|
const int MaxAxes = 10; // JoystickAxis defines 10 axes
|
||||||
|
const float ConversionFactor = 1.0f / short.MaxValue;
|
||||||
|
unsafe fixed short axes[MaxAxes];
|
||||||
|
JoystickButton buttons;
|
||||||
|
|
||||||
|
public float GetAxis(JoystickAxis axis)
|
||||||
|
{
|
||||||
|
return GetAxis((int)axis);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetAxis(int axis)
|
||||||
|
{
|
||||||
|
float value = 0.0f;
|
||||||
|
if (axis >= 0 && axis < MaxAxes)
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
fixed (short* paxis = axes)
|
||||||
|
{
|
||||||
|
value = *(paxis + axis) * ConversionFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Print("[Joystick] Invalid axis {0}", axis);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsButtonDown(JoystickButton button)
|
||||||
|
{
|
||||||
|
return (buttons & button) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsButtonUp(JoystickButton button)
|
||||||
|
{
|
||||||
|
return (buttons & button) == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -138,8 +138,14 @@
|
||||||
<Compile Include="Input\GamePadType.cs" />
|
<Compile Include="Input\GamePadType.cs" />
|
||||||
<Compile Include="Input\IGamePadDriver.cs" />
|
<Compile Include="Input\IGamePadDriver.cs" />
|
||||||
<Compile Include="Input\IInputDriver2.cs" />
|
<Compile Include="Input\IInputDriver2.cs" />
|
||||||
|
<Compile Include="Input\IJoystickDriver2.cs" />
|
||||||
<Compile Include="Input\IKeyboardDriver2.cs" />
|
<Compile Include="Input\IKeyboardDriver2.cs" />
|
||||||
<Compile Include="Input\IMouseDriver2.cs" />
|
<Compile Include="Input\IMouseDriver2.cs" />
|
||||||
|
<Compile Include="Input\Joystick.cs" />
|
||||||
|
<Compile Include="Input\JoystickAxis.cs" />
|
||||||
|
<Compile Include="Input\JoystickButton.cs" />
|
||||||
|
<Compile Include="Input\JoystickCapabilities.cs" />
|
||||||
|
<Compile Include="Input\JoystickState.cs" />
|
||||||
<Compile Include="InteropHelper.cs" />
|
<Compile Include="InteropHelper.cs" />
|
||||||
<Compile Include="Math\Matrix2.cs" />
|
<Compile Include="Math\Matrix2.cs" />
|
||||||
<Compile Include="Math\Matrix2d.cs" />
|
<Compile Include="Math\Matrix2d.cs" />
|
||||||
|
|
|
@ -149,6 +149,11 @@ namespace OpenTK.Platform
|
||||||
return default_implementation.CreateGamePadDriver();
|
return default_implementation.CreateGamePadDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Input.IJoystickDriver2 CreateJoystickDriver()
|
||||||
|
{
|
||||||
|
return default_implementation.CreateJoystickDriver();
|
||||||
|
}
|
||||||
|
|
||||||
class UnsupportedPlatform : IPlatformFactory
|
class UnsupportedPlatform : IPlatformFactory
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
@ -210,6 +215,11 @@ namespace OpenTK.Platform
|
||||||
throw new PlatformNotSupportedException(error_string);
|
throw new PlatformNotSupportedException(error_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Input.IJoystickDriver2 CreateJoystickDriver()
|
||||||
|
{
|
||||||
|
throw new PlatformNotSupportedException(error_string);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
|
@ -52,5 +52,7 @@ namespace OpenTK.Platform
|
||||||
OpenTK.Input.IMouseDriver2 CreateMouseDriver();
|
OpenTK.Input.IMouseDriver2 CreateMouseDriver();
|
||||||
|
|
||||||
OpenTK.Input.IGamePadDriver CreateGamePadDriver();
|
OpenTK.Input.IGamePadDriver CreateGamePadDriver();
|
||||||
|
|
||||||
|
Input.IJoystickDriver2 CreateJoystickDriver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,5 +113,10 @@ namespace OpenTK.Platform.MacOS
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IJoystickDriver2 JoystickDriver
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
// Requires Mac OS X 10.5 or higher.
|
// Requires Mac OS X 10.5 or higher.
|
||||||
// Todo: create a driver for older installations. Maybe use CGGetLastMouseDelta for that?
|
// Todo: create a driver for older installations. Maybe use CGGetLastMouseDelta for that?
|
||||||
class HIDInput : IInputDriver2, IMouseDriver2, IKeyboardDriver2, IGamePadDriver
|
class HIDInput : IInputDriver2, IMouseDriver2, IKeyboardDriver2, IGamePadDriver, IJoystickDriver2
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private Members
|
#region Private Members
|
||||||
|
|
||||||
IOHIDManagerRef CreateHIDManager()
|
IOHIDManagerRef CreateHIDManager()
|
||||||
{
|
{
|
||||||
|
@ -292,6 +292,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
public IMouseDriver2 MouseDriver { get { return this; } }
|
public IMouseDriver2 MouseDriver { get { return this; } }
|
||||||
public IKeyboardDriver2 KeyboardDriver { get { return this; } }
|
public IKeyboardDriver2 KeyboardDriver { get { return this; } }
|
||||||
public IGamePadDriver GamePadDriver { get { return this; } }
|
public IGamePadDriver GamePadDriver { get { return this; } }
|
||||||
|
public IJoystickDriver2 JoystickDriver { get { return this; } }
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -385,6 +387,20 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IJoystickDriver2 Members
|
||||||
|
|
||||||
|
JoystickState IJoystickDriver2.GetState(int index)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
JoystickCapabilities IJoystickDriver2.GetCapabilities(int index)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region NativeMethods
|
#region NativeMethods
|
||||||
|
|
||||||
class NativeMethods
|
class NativeMethods
|
||||||
|
|
|
@ -93,6 +93,11 @@ namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
return InputDriver.GamePadDriver;
|
return InputDriver.GamePadDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IJoystickDriver2 CreateJoystickDriver()
|
||||||
|
{
|
||||||
|
return InputDriver.JoystickDriver;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,11 @@ namespace OpenTK.Platform.SDL2
|
||||||
return InputDriver.GamePadDriver;
|
return InputDriver.GamePadDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IJoystickDriver2 CreateJoystickDriver()
|
||||||
|
{
|
||||||
|
return InputDriver.JoystickDriver;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
|
@ -220,6 +220,14 @@ namespace OpenTK.Platform.SDL2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IJoystickDriver2 JoystickDriver
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return joystick_driver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
|
@ -32,7 +32,7 @@ using OpenTK.Input;
|
||||||
|
|
||||||
namespace OpenTK.Platform.SDL2
|
namespace OpenTK.Platform.SDL2
|
||||||
{
|
{
|
||||||
class Sdl2JoystickDriver : IJoystickDriver, IGamePadDriver, IDisposable
|
class Sdl2JoystickDriver : IJoystickDriver, IJoystickDriver2, IGamePadDriver, IDisposable
|
||||||
{
|
{
|
||||||
const float RangeMultiplier = 1.0f / 32768.0f;
|
const float RangeMultiplier = 1.0f / 32768.0f;
|
||||||
|
|
||||||
|
@ -322,6 +322,20 @@ namespace OpenTK.Platform.SDL2
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IJoystickDriver2 Members
|
||||||
|
|
||||||
|
JoystickState IJoystickDriver2.GetState(int index)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
JoystickCapabilities IJoystickDriver2.GetCapabilities(int index)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
||||||
void Dispose(bool manual)
|
void Dispose(bool manual)
|
||||||
|
|
|
@ -130,7 +130,12 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
return InputDriver.GamePadDriver;
|
return InputDriver.GamePadDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IJoystickDriver2 CreateJoystickDriver()
|
||||||
|
{
|
||||||
|
return InputDriver.JoystickDriver;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
IInputDriver2 InputDriver
|
IInputDriver2 InputDriver
|
||||||
|
|
|
@ -164,6 +164,8 @@ namespace OpenTK.Platform.Windows
|
||||||
public abstract IKeyboardDriver2 KeyboardDriver { get; }
|
public abstract IKeyboardDriver2 KeyboardDriver { get; }
|
||||||
public abstract IGamePadDriver GamePadDriver { get; }
|
public abstract IGamePadDriver GamePadDriver { get; }
|
||||||
|
|
||||||
|
public abstract IJoystickDriver2 JoystickDriver { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
|
@ -445,10 +445,10 @@ namespace OpenTK.Platform.Windows
|
||||||
JoystickError result = UnsafeNativeMethods.joyGetDevCaps(index, out caps, JoyCaps.SizeInBytes);
|
JoystickError result = UnsafeNativeMethods.joyGetDevCaps(index, out caps, JoyCaps.SizeInBytes);
|
||||||
if (result == JoystickError.NoError)
|
if (result == JoystickError.NoError)
|
||||||
{
|
{
|
||||||
gpcaps.AxisCount = caps.NumAxes;
|
//gpcaps.AxisCount = caps.NumAxes;
|
||||||
gpcaps.ButtonCount = caps.NumButtons;
|
//gpcaps.ButtonCount = caps.NumButtons;
|
||||||
if ((caps.Capabilities & JoystCapsFlags.HasPov) != 0)
|
//if ((caps.Capabilities & JoystCapsFlags.HasPov) != 0)
|
||||||
gpcaps.DPadCount++;
|
// gpcaps.DPadCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -190,6 +190,11 @@ namespace OpenTK.Platform.Windows
|
||||||
get { return joystick_driver; }
|
get { return joystick_driver; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IJoystickDriver2 JoystickDriver
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// #region License
|
#region License
|
||||||
//
|
//
|
||||||
// XInputJoystick.cs
|
// XInputJoystick.cs
|
||||||
//
|
//
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
//
|
//
|
||||||
// #endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
|
@ -98,6 +98,12 @@ namespace OpenTK.Platform.X11
|
||||||
return new X11Joystick();
|
return new X11Joystick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual OpenTK.Input.IJoystickDriver2 CreateJoystickDriver()
|
||||||
|
{
|
||||||
|
return new X11Joystick();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
struct X11JoyDetails { }
|
struct X11JoyDetails { }
|
||||||
|
|
||||||
sealed class X11Joystick : IJoystickDriver, IGamePadDriver
|
sealed class X11Joystick : IJoystickDriver, IJoystickDriver2, IGamePadDriver
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
|
@ -277,5 +277,19 @@ namespace OpenTK.Platform.X11
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IJoystickDriver2 Members
|
||||||
|
|
||||||
|
JoystickState IJoystickDriver2.GetState(int index)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
JoystickCapabilities IJoystickDriver2.GetCapabilities(int index)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue