* X11/X11Joystick.cs: Flip vertical axes so that +1 points up.
* Windows/WinMMJoystick.cs: Move Z-axis before R-axis.
This commit is contained in:
parent
51e2d93e38
commit
67f9358bd3
2 changed files with 9 additions and 7 deletions
|
@ -89,18 +89,16 @@ namespace OpenTK.Platform.Windows
|
||||||
stick.Details = new WinMMJoyDetails(num_axes);
|
stick.Details = new WinMMJoyDetails(num_axes);
|
||||||
|
|
||||||
// Make sure to reverse the vertical axes, so that +1 points up and -1 points down.
|
// Make sure to reverse the vertical axes, so that +1 points up and -1 points down.
|
||||||
// I don't know if this an artifact of my joypad, but RAxis is the second horizontal and
|
|
||||||
// ZAxis is the second vertical axis here (Saitek P880).
|
|
||||||
int axis = 0;
|
int axis = 0;
|
||||||
if (axis < caps.NumAxes)
|
if (axis < caps.NumAxes)
|
||||||
{ stick.Details.Min[axis] = caps.XMin; stick.Details.Max[axis] = caps.XMax; axis++; }
|
{ stick.Details.Min[axis] = caps.XMin; stick.Details.Max[axis] = caps.XMax; axis++; }
|
||||||
if (axis < caps.NumAxes)
|
if (axis < caps.NumAxes)
|
||||||
{ stick.Details.Min[axis] = caps.YMax; stick.Details.Max[axis] = caps.YMin; axis++; }
|
{ stick.Details.Min[axis] = caps.YMax; stick.Details.Max[axis] = caps.YMin; axis++; }
|
||||||
if (axis < caps.NumAxes)
|
if (axis < caps.NumAxes)
|
||||||
{ stick.Details.Min[axis] = caps.RMin; stick.Details.Max[axis] = caps.RMax; axis++; }
|
|
||||||
if (axis < caps.NumAxes)
|
|
||||||
{ stick.Details.Min[axis] = caps.ZMax; stick.Details.Max[axis] = caps.ZMin; axis++; }
|
{ stick.Details.Min[axis] = caps.ZMax; stick.Details.Max[axis] = caps.ZMin; axis++; }
|
||||||
if (axis < caps.NumAxes)
|
if (axis < caps.NumAxes)
|
||||||
|
{ stick.Details.Min[axis] = caps.RMin; stick.Details.Max[axis] = caps.RMax; axis++; }
|
||||||
|
if (axis < caps.NumAxes)
|
||||||
{ stick.Details.Min[axis] = caps.UMin; stick.Details.Max[axis] = caps.UMax; axis++; }
|
{ stick.Details.Min[axis] = caps.UMin; stick.Details.Max[axis] = caps.UMax; axis++; }
|
||||||
if (axis < caps.NumAxes)
|
if (axis < caps.NumAxes)
|
||||||
{ stick.Details.Min[axis] = caps.VMax; stick.Details.Max[axis] = caps.VMin; axis++; }
|
{ stick.Details.Min[axis] = caps.VMax; stick.Details.Max[axis] = caps.VMin; axis++; }
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace OpenTK.Platform.X11
|
||||||
JoystickDevice stick = OpenJoystick(JoystickPath, number++);
|
JoystickDevice stick = OpenJoystick(JoystickPath, number++);
|
||||||
if (stick != null)
|
if (stick != null)
|
||||||
{
|
{
|
||||||
stick.Description = String.Format("USB Joystick {0} ({1} axes, {2} buttons, {3})",
|
stick.Description = String.Format("USB Joystick {0} ({1} axes, {2} buttons, {3}{0})",
|
||||||
number, stick.Axis.Count, stick.Button.Count, JoystickPath);
|
number, stick.Axis.Count, stick.Button.Count, JoystickPath);
|
||||||
sticks.Add(stick);
|
sticks.Add(stick);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ namespace OpenTK.Platform.X11
|
||||||
JoystickDevice stick = OpenJoystick(JoystickPathLegacy, number++);
|
JoystickDevice stick = OpenJoystick(JoystickPathLegacy, number++);
|
||||||
if (stick != null)
|
if (stick != null)
|
||||||
{
|
{
|
||||||
stick.Description = String.Format("USB Joystick {0} ({1} axes, {2} buttons, {3})",
|
stick.Description = String.Format("USB Joystick {0} ({1} axes, {2} buttons, {3}{0})",
|
||||||
number, stick.Axis.Count, stick.Button.Count, JoystickPathLegacy);
|
number, stick.Axis.Count, stick.Button.Count, JoystickPathLegacy);
|
||||||
sticks.Add(stick);
|
sticks.Add(stick);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,11 @@ namespace OpenTK.Platform.X11
|
||||||
switch (e.Type)
|
switch (e.Type)
|
||||||
{
|
{
|
||||||
case JoystickEventType.Axis:
|
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);
|
js.SetAxis((JoystickAxis)e.Number, e.Value / 32767.0f);
|
||||||
|
else
|
||||||
|
js.SetAxis((JoystickAxis)e.Number, -e.Value / 32767.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JoystickEventType.Button:
|
case JoystickEventType.Button:
|
||||||
|
|
Loading…
Reference in a new issue