* 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:
the_fiddler 2009-03-01 09:17:19 +00:00
parent 51e2d93e38
commit 67f9358bd3
2 changed files with 9 additions and 7 deletions

View file

@ -89,18 +89,16 @@ namespace OpenTK.Platform.Windows
stick.Details = new WinMMJoyDetails(num_axes);
// 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;
if (axis < caps.NumAxes)
{ stick.Details.Min[axis] = caps.XMin; stick.Details.Max[axis] = caps.XMax; axis++; }
if (axis < caps.NumAxes)
{ stick.Details.Min[axis] = caps.YMax; stick.Details.Max[axis] = caps.YMin; axis++; }
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++; }
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++; }
if (axis < caps.NumAxes)
{ stick.Details.Min[axis] = caps.VMax; stick.Details.Max[axis] = caps.VMin; axis++; }

View file

@ -58,7 +58,7 @@ namespace OpenTK.Platform.X11
JoystickDevice stick = OpenJoystick(JoystickPath, number++);
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);
sticks.Add(stick);
}
@ -70,7 +70,7 @@ namespace OpenTK.Platform.X11
JoystickDevice stick = OpenJoystick(JoystickPathLegacy, number++);
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);
sticks.Add(stick);
}
@ -106,7 +106,11 @@ namespace OpenTK.Platform.X11
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: