mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-25 19:26:45 +00:00
Change: Bump joystick axis limit to 64 & remove JoystickAxis enum
This commit is contained in:
parent
9ea1f55139
commit
d00a2f982d
|
@ -155,10 +155,10 @@ namespace OpenTK.Input
|
||||||
switch (item[0])
|
switch (item[0])
|
||||||
{
|
{
|
||||||
case 'a':
|
case 'a':
|
||||||
return new GamePadConfigurationSource(ParseAxis(item));
|
return new GamePadConfigurationSource(true, ParseAxis(item));
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
return new GamePadConfigurationSource(ParseButton(item));
|
return new GamePadConfigurationSource(false, ParseButton(item));
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
{
|
{
|
||||||
|
@ -172,10 +172,10 @@ namespace OpenTK.Input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static JoystickAxis ParseAxis(string item)
|
static int ParseAxis(string item)
|
||||||
{
|
{
|
||||||
// item is in the format "a#" where # a zero-based integer number
|
// item is in the format "a#" where # a zero-based integer number
|
||||||
JoystickAxis axis = JoystickAxis.Axis0;
|
int axis = 0;
|
||||||
int id = Int32.Parse(item.Substring(1));
|
int id = Int32.Parse(item.Substring(1));
|
||||||
return axis + id;
|
return axis + id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,22 +32,23 @@ namespace OpenTK.Input
|
||||||
struct GamePadConfigurationSource
|
struct GamePadConfigurationSource
|
||||||
{
|
{
|
||||||
int? map_button;
|
int? map_button;
|
||||||
JoystickAxis? map_axis;
|
int? map_axis;
|
||||||
JoystickHat? map_hat;
|
JoystickHat? map_hat;
|
||||||
HatPosition? map_hat_position;
|
HatPosition? map_hat_position;
|
||||||
|
|
||||||
public GamePadConfigurationSource(JoystickAxis axis)
|
public GamePadConfigurationSource(bool axis, int index)
|
||||||
: this()
|
: this()
|
||||||
|
{
|
||||||
|
if (axis)
|
||||||
{
|
{
|
||||||
Type = ConfigurationType.Axis;
|
Type = ConfigurationType.Axis;
|
||||||
Axis = axis;
|
Axis = index;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
public GamePadConfigurationSource(int button)
|
|
||||||
: this()
|
|
||||||
{
|
{
|
||||||
Type = ConfigurationType.Button;
|
Type = ConfigurationType.Button;
|
||||||
Button = button;
|
Button = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GamePadConfigurationSource(JoystickHat hat, HatPosition pos)
|
public GamePadConfigurationSource(JoystickHat hat, HatPosition pos)
|
||||||
|
@ -60,7 +61,7 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
public ConfigurationType Type { get; private set; }
|
public ConfigurationType Type { get; private set; }
|
||||||
|
|
||||||
public JoystickAxis Axis
|
public int Axis
|
||||||
{
|
{
|
||||||
get { return map_axis.Value; }
|
get { return map_axis.Value; }
|
||||||
private set { map_axis = value; }
|
private set { map_axis = value; }
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
//
|
|
||||||
// JoystickAxis.cs
|
|
||||||
//
|
|
||||||
// Author:
|
|
||||||
// Stefanos A. <stapostol@gmail.com>
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006-2014 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.
|
|
||||||
//
|
|
||||||
|
|
||||||
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,
|
|
||||||
/// <summary>The eleventh axis of the JoystickDevice.</summary>
|
|
||||||
Axis10,
|
|
||||||
/// <summary>The highest supported axis of the JoystickDevice.</summary>
|
|
||||||
Last = Axis10,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -92,7 +92,7 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
internal int Id { get; set; }
|
internal int Id { get; set; }
|
||||||
|
|
||||||
internal void SetAxis(JoystickAxis axis, float @value)
|
internal void SetAxis(int axis, float @value)
|
||||||
{
|
{
|
||||||
if ((int)axis < Axis.Count)
|
if ((int)axis < Axis.Count)
|
||||||
{
|
{
|
||||||
|
@ -178,7 +178,7 @@ namespace OpenTK.Input
|
||||||
/// <param name="axis">The index of the joystick axis that was moved.</param>
|
/// <param name="axis">The index of the joystick axis that was moved.</param>
|
||||||
/// <param name="value">The absolute value of the joystick axis.</param>
|
/// <param name="value">The absolute value of the joystick axis.</param>
|
||||||
/// <param name="delta">The relative change in value of the joystick axis.</param>
|
/// <param name="delta">The relative change in value of the joystick axis.</param>
|
||||||
public JoystickMoveEventArgs(JoystickAxis axis, float value, float delta)
|
public JoystickMoveEventArgs(int axis, float value, float delta)
|
||||||
{
|
{
|
||||||
this.Axis = axis;
|
this.Axis = axis;
|
||||||
this.Value = value;
|
this.Value = value;
|
||||||
|
@ -188,7 +188,7 @@ namespace OpenTK.Input
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a System.Int32 representing the index of the axis that was moved.
|
/// Gets a System.Int32 representing the index of the axis that was moved.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public JoystickAxis Axis { get; internal set; }
|
public int Axis { get; internal set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a System.Single representing the absolute position of the axis.
|
/// Gets a System.Single representing the absolute position of the axis.
|
||||||
|
@ -262,17 +262,6 @@ namespace OpenTK.Input
|
||||||
internal set { axis_state[index] = value; }
|
internal set { axis_state[index] = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a System.Single indicating the absolute position of the JoystickAxis.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="axis">The JoystickAxis to check.</param>
|
|
||||||
/// <returns>A System.Single in the range [-1, 1].</returns>
|
|
||||||
public float this[JoystickAxis axis]
|
|
||||||
{
|
|
||||||
get { return axis_state[(int)axis]; }
|
|
||||||
internal set { axis_state[(int)axis] = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a System.Int32 indicating the available amount of JoystickAxes.
|
/// Gets a System.Int32 indicating the available amount of JoystickAxes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
// If we ever add more values to JoystickAxis or JoystickButton
|
// If we ever add more values to JoystickAxis or JoystickButton
|
||||||
// then we'll need to increase these limits.
|
// then we'll need to increase these limits.
|
||||||
internal const int MaxAxes = (int)JoystickAxis.Last + 1;
|
internal const int MaxAxes = 64;
|
||||||
internal const int MaxButtons = 64;
|
internal const int MaxButtons = 64;
|
||||||
internal const int MaxHats = (int)JoystickHat.Last + 1;
|
internal const int MaxHats = (int)JoystickHat.Last + 1;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ namespace OpenTK.Input
|
||||||
/// to query the number of available axes.
|
/// to query the number of available axes.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <param name="axis">The <see cref="JoystickAxis"/> to query.</param>
|
/// <param name="axis">The <see cref="JoystickAxis"/> to query.</param>
|
||||||
public float GetAxis(JoystickAxis axis)
|
public float GetAxis(int axis)
|
||||||
{
|
{
|
||||||
return GetAxisRaw(axis) * ConversionFactor;
|
return GetAxisRaw(axis) * ConversionFactor;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ namespace OpenTK.Input
|
||||||
for (int i = 0; i < MaxAxes; i++)
|
for (int i = 0; i < MaxAxes; i++)
|
||||||
{
|
{
|
||||||
sb.Append(" ");
|
sb.Append(" ");
|
||||||
sb.Append(String.Format("{0:f4}", GetAxis(JoystickAxis.Axis0 + i)));
|
sb.Append(String.Format("{0:f4}", GetAxis(i)));
|
||||||
}
|
}
|
||||||
return String.Format(
|
return String.Format(
|
||||||
"{{Axes:{0}; Buttons: {1}; Hat: {2}; IsConnected: {3}}}",
|
"{{Axes:{0}; Buttons: {1}; Hat: {2}; IsConnected: {3}}}",
|
||||||
|
@ -186,11 +186,6 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
internal int PacketNumber { get; private set; }
|
internal int PacketNumber { get; private set; }
|
||||||
|
|
||||||
internal short GetAxisRaw(JoystickAxis axis)
|
|
||||||
{
|
|
||||||
return GetAxisRaw((int)axis);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal short GetAxisRaw(int axis)
|
internal short GetAxisRaw(int axis)
|
||||||
{
|
{
|
||||||
short value = 0;
|
short value = 0;
|
||||||
|
@ -205,9 +200,9 @@ namespace OpenTK.Input
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetAxis(JoystickAxis axis, short value)
|
internal void SetAxis(int axis, short value)
|
||||||
{
|
{
|
||||||
int index = (int)axis;
|
int index = axis;
|
||||||
if (index < 0 || index >= MaxAxes)
|
if (index < 0 || index >= MaxAxes)
|
||||||
throw new ArgumentOutOfRangeException("axis");
|
throw new ArgumentOutOfRangeException("axis");
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,6 @@
|
||||||
<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\Joystick.cs" />
|
||||||
<Compile Include="Input\JoystickAxis.cs" />
|
|
||||||
<Compile Include="Input\JoystickCapabilities.cs" />
|
<Compile Include="Input\JoystickCapabilities.cs" />
|
||||||
<Compile Include="Input\JoystickState.cs" />
|
<Compile Include="Input\JoystickState.cs" />
|
||||||
<Compile Include="InteropHelper.cs" />
|
<Compile Include="InteropHelper.cs" />
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace OpenTK.Platform.Common
|
||||||
return (int)(temp / (value_max - value_min) + result_min);
|
return (int)(temp / (value_max - value_min) + result_min);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JoystickAxis TranslateJoystickAxis(HIDPage page, int usage)
|
public static int TranslateJoystickAxis(HIDPage page, int usage)
|
||||||
{
|
{
|
||||||
switch (page)
|
switch (page)
|
||||||
{
|
{
|
||||||
|
@ -64,26 +64,23 @@ namespace OpenTK.Platform.Common
|
||||||
switch ((HIDUsageGD)usage)
|
switch ((HIDUsageGD)usage)
|
||||||
{
|
{
|
||||||
case HIDUsageGD.X:
|
case HIDUsageGD.X:
|
||||||
return JoystickAxis.Axis0;
|
return 0;
|
||||||
case HIDUsageGD.Y:
|
case HIDUsageGD.Y:
|
||||||
return JoystickAxis.Axis1;
|
return 1;
|
||||||
|
|
||||||
case HIDUsageGD.Z:
|
case HIDUsageGD.Z:
|
||||||
return JoystickAxis.Axis2;
|
return 2;
|
||||||
case HIDUsageGD.Rz:
|
case HIDUsageGD.Rz:
|
||||||
return JoystickAxis.Axis3;
|
return 3;
|
||||||
|
|
||||||
case HIDUsageGD.Rx:
|
case HIDUsageGD.Rx:
|
||||||
return JoystickAxis.Axis4;
|
return 4;
|
||||||
case HIDUsageGD.Ry:
|
case HIDUsageGD.Ry:
|
||||||
return JoystickAxis.Axis5;
|
return 5;
|
||||||
|
|
||||||
case HIDUsageGD.Slider:
|
case HIDUsageGD.Slider:
|
||||||
return JoystickAxis.Axis6;
|
return 6;
|
||||||
case HIDUsageGD.Dial:
|
case HIDUsageGD.Dial:
|
||||||
return JoystickAxis.Axis7;
|
return 7;
|
||||||
case HIDUsageGD.Wheel:
|
case HIDUsageGD.Wheel:
|
||||||
return JoystickAxis.Axis8;
|
return 8;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -91,9 +88,9 @@ namespace OpenTK.Platform.Common
|
||||||
switch ((HIDUsageSim)usage)
|
switch ((HIDUsageSim)usage)
|
||||||
{
|
{
|
||||||
case HIDUsageSim.Rudder:
|
case HIDUsageSim.Rudder:
|
||||||
return JoystickAxis.Axis9;
|
return 9;
|
||||||
case HIDUsageSim.Throttle:
|
case HIDUsageSim.Throttle:
|
||||||
return JoystickAxis.Axis10;
|
return 10;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace OpenTK.Platform.Linux
|
||||||
{
|
{
|
||||||
struct AxisInfo
|
struct AxisInfo
|
||||||
{
|
{
|
||||||
public JoystickAxis Axis;
|
public int Axis;
|
||||||
public InputAbsInfo Info;
|
public InputAbsInfo Info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ namespace OpenTK.Platform.Linux
|
||||||
// Analogue hat
|
// Analogue hat
|
||||||
stick.AxisMap.Add(axis, new AxisInfo
|
stick.AxisMap.Add(axis, new AxisInfo
|
||||||
{
|
{
|
||||||
Axis = (JoystickAxis)(JoystickHat)hats++,
|
Axis = (int)(JoystickHat)hats++,
|
||||||
Info = info
|
Info = info
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ namespace OpenTK.Platform.Linux
|
||||||
// Regular axis
|
// Regular axis
|
||||||
stick.AxisMap.Add(axis, new AxisInfo
|
stick.AxisMap.Add(axis, new AxisInfo
|
||||||
{
|
{
|
||||||
Axis = (JoystickAxis)axes++,
|
Axis = axes++,
|
||||||
Info = info
|
Info = info
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -850,8 +850,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
case HIDUsageGD.Dial:
|
case HIDUsageGD.Dial:
|
||||||
case HIDUsageGD.Wheel:
|
case HIDUsageGD.Wheel:
|
||||||
short offset = GetJoystickAxis(val, elem);
|
short offset = GetJoystickAxis(val, elem);
|
||||||
JoystickAxis axis = JoystickAxis.Axis0 + joy.Elements[cookie].Index;
|
int axis = joy.Elements[cookie].Index;
|
||||||
if (axis >= JoystickAxis.Axis0 && axis <= JoystickAxis.Last)
|
if (axis >= 0 && axis <= 64)
|
||||||
{
|
{
|
||||||
joy.State.SetAxis(axis, offset);
|
joy.State.SetAxis(axis, offset);
|
||||||
}
|
}
|
||||||
|
@ -874,8 +874,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
case HIDUsageSim.Rudder:
|
case HIDUsageSim.Rudder:
|
||||||
case HIDUsageSim.Throttle:
|
case HIDUsageSim.Throttle:
|
||||||
short offset = GetJoystickAxis(val, elem);
|
short offset = GetJoystickAxis(val, elem);
|
||||||
JoystickAxis axis = JoystickAxis.Axis0 + joy.Elements[cookie].Index;
|
int axis = 0 + joy.Elements[cookie].Index;
|
||||||
if (axis >= JoystickAxis.Axis0 && axis <= JoystickAxis.Last)
|
if (axis >= 0 && axis <= 64)
|
||||||
{
|
{
|
||||||
joy.State.SetAxis(axis, offset);
|
joy.State.SetAxis(axis, offset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace OpenTK.Platform
|
||||||
case ConfigurationType.Axis:
|
case ConfigurationType.Axis:
|
||||||
{
|
{
|
||||||
// JoystickAxis -> Buttons/GamePadAxes mapping
|
// JoystickAxis -> Buttons/GamePadAxes mapping
|
||||||
JoystickAxis source_axis = map.Source.Axis;
|
int source_axis = map.Source.Axis;
|
||||||
short value = joy.GetAxisRaw(source_axis);
|
short value = joy.GetAxisRaw(source_axis);
|
||||||
|
|
||||||
switch (map.Target.Type)
|
switch (map.Target.Type)
|
||||||
|
|
|
@ -359,7 +359,7 @@ namespace OpenTK.Platform.SDL2
|
||||||
int index = sdl_instanceid_to_joysticks[id];
|
int index = sdl_instanceid_to_joysticks[id];
|
||||||
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
||||||
float value = ev.Value * RangeMultiplier;
|
float value = ev.Value * RangeMultiplier;
|
||||||
joystick.SetAxis((JoystickAxis)ev.Axis, value);
|
joystick.SetAxis(ev.Axis, value);
|
||||||
joystick.Details.PacketNumber = Math.Max(0, unchecked(joystick.Details.PacketNumber + 1));
|
joystick.Details.PacketNumber = Math.Max(0, unchecked(joystick.Details.PacketNumber + 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -591,7 +591,7 @@ namespace OpenTK.Platform.SDL2
|
||||||
|
|
||||||
for (int i = 0; i < joystick.Axis.Count; i++)
|
for (int i = 0; i < joystick.Axis.Count; i++)
|
||||||
{
|
{
|
||||||
state.SetAxis(JoystickAxis.Axis0 + i, (short)(joystick.Axis[i] * short.MaxValue + 0.5f));
|
state.SetAxis(i, (short)(joystick.Axis[i] * short.MaxValue + 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < joystick.Button.Count; i++)
|
for (int i = 0; i < joystick.Button.Count; i++)
|
||||||
|
|
|
@ -51,8 +51,8 @@ namespace OpenTK.Platform.Windows
|
||||||
internal readonly bool IsXInput;
|
internal readonly bool IsXInput;
|
||||||
internal readonly int XInputIndex;
|
internal readonly int XInputIndex;
|
||||||
|
|
||||||
readonly Dictionary<int, JoystickAxis> axes =
|
readonly Dictionary<int, int> axes =
|
||||||
new Dictionary<int,JoystickAxis>();
|
new Dictionary<int,int>();
|
||||||
readonly Dictionary<int, int> buttons =
|
readonly Dictionary<int, int> buttons =
|
||||||
new Dictionary<int, int>();
|
new Dictionary<int, int>();
|
||||||
readonly Dictionary<int, JoystickHat> hats =
|
readonly Dictionary<int, JoystickHat> hats =
|
||||||
|
@ -79,7 +79,7 @@ namespace OpenTK.Platform.Windows
|
||||||
//return an invalid HID page of 1, so
|
//return an invalid HID page of 1, so
|
||||||
if ((int)usage != 1)
|
if ((int)usage != 1)
|
||||||
{
|
{
|
||||||
JoystickAxis axis = GetAxis(collection, page, usage);
|
int axis = GetAxis(collection, page, usage);
|
||||||
State.SetAxis(axis, value);
|
State.SetAxis(axis, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,12 +133,12 @@ namespace OpenTK.Platform.Windows
|
||||||
return (coll_byte << 24) | (page_byte << 16) | unchecked((ushort)usage);
|
return (coll_byte << 24) | (page_byte << 16) | unchecked((ushort)usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
JoystickAxis GetAxis(short collection, HIDPage page, short usage)
|
int GetAxis(short collection, HIDPage page, short usage)
|
||||||
{
|
{
|
||||||
int key = MakeKey(collection, page, usage);
|
int key = MakeKey(collection, page, usage);
|
||||||
if (!axes.ContainsKey(key))
|
if (!axes.ContainsKey(key))
|
||||||
{
|
{
|
||||||
JoystickAxis axis = HidHelper.TranslateJoystickAxis(page, usage);
|
int axis = HidHelper.TranslateJoystickAxis(page, usage);
|
||||||
axes.Add(key, axis);
|
axes.Add(key, axis);
|
||||||
}
|
}
|
||||||
return axes[key];
|
return axes[key];
|
||||||
|
@ -527,7 +527,7 @@ namespace OpenTK.Platform.Windows
|
||||||
case HIDUsageGD.Dial:
|
case HIDUsageGD.Dial:
|
||||||
case HIDUsageGD.Wheel:
|
case HIDUsageGD.Wheel:
|
||||||
Debug.Print("Found axis {0} ({1} / {2})",
|
Debug.Print("Found axis {0} ({1} / {2})",
|
||||||
JoystickAxis.Axis0 + stick.GetCapabilities().AxisCount,
|
stick.GetCapabilities().AxisCount,
|
||||||
page, (HIDUsageGD)stick.AxisCaps[i].NotRange.Usage);
|
page, (HIDUsageGD)stick.AxisCaps[i].NotRange.Usage);
|
||||||
stick.SetAxis(collection, page, stick.AxisCaps[i].NotRange.Usage, 0);
|
stick.SetAxis(collection, page, stick.AxisCaps[i].NotRange.Usage, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -552,7 +552,7 @@ namespace OpenTK.Platform.Windows
|
||||||
case HIDUsageSim.Rudder:
|
case HIDUsageSim.Rudder:
|
||||||
case HIDUsageSim.Throttle:
|
case HIDUsageSim.Throttle:
|
||||||
Debug.Print("Found simulation axis {0} ({1} / {2})",
|
Debug.Print("Found simulation axis {0} ({1} / {2})",
|
||||||
JoystickAxis.Axis0 + stick.GetCapabilities().AxisCount,
|
stick.GetCapabilities().AxisCount,
|
||||||
page, (HIDUsageSim)stick.AxisCaps[i].NotRange.Usage);
|
page, (HIDUsageSim)stick.AxisCaps[i].NotRange.Usage);
|
||||||
stick.SetAxis(collection, page, stick.AxisCaps[i].NotRange.Usage, 0);
|
stick.SetAxis(collection, page, stick.AxisCaps[i].NotRange.Usage, 0);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -54,12 +54,12 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
state.SetIsConnected(true);
|
state.SetIsConnected(true);
|
||||||
|
|
||||||
state.SetAxis(JoystickAxis.Axis0, (short)xstate.GamePad.ThumbLX);
|
state.SetAxis(0, (short)xstate.GamePad.ThumbLX);
|
||||||
state.SetAxis(JoystickAxis.Axis1, (short)Math.Min(short.MaxValue, -xstate.GamePad.ThumbLY));
|
state.SetAxis(1, (short)Math.Min(short.MaxValue, -xstate.GamePad.ThumbLY));
|
||||||
state.SetAxis(JoystickAxis.Axis2, (short)Common.HidHelper.ScaleValue(xstate.GamePad.LeftTrigger, 0, byte.MaxValue, short.MinValue, short.MaxValue));
|
state.SetAxis(2, (short)Common.HidHelper.ScaleValue(xstate.GamePad.LeftTrigger, 0, byte.MaxValue, short.MinValue, short.MaxValue));
|
||||||
state.SetAxis(JoystickAxis.Axis3, (short)xstate.GamePad.ThumbRX);
|
state.SetAxis(3, (short)xstate.GamePad.ThumbRX);
|
||||||
state.SetAxis(JoystickAxis.Axis4, (short)Math.Min(short.MaxValue, -xstate.GamePad.ThumbRY));
|
state.SetAxis(4, (short)Math.Min(short.MaxValue, -xstate.GamePad.ThumbRY));
|
||||||
state.SetAxis(JoystickAxis.Axis5, (short)Common.HidHelper.ScaleValue(xstate.GamePad.RightTrigger, 0, byte.MaxValue, short.MinValue, short.MaxValue));
|
state.SetAxis(5, (short)Common.HidHelper.ScaleValue(xstate.GamePad.RightTrigger, 0, byte.MaxValue, short.MinValue, short.MaxValue));
|
||||||
|
|
||||||
state.SetButton(0, (xstate.GamePad.Buttons & XInputButtons.A) != 0);
|
state.SetButton(0, (xstate.GamePad.Buttons & XInputButtons.A) != 0);
|
||||||
state.SetButton(1, (xstate.GamePad.Buttons & XInputButtons.B) != 0);
|
state.SetButton(1, (xstate.GamePad.Buttons & XInputButtons.B) != 0);
|
||||||
|
|
Loading…
Reference in a new issue