Merge pull request #481 from leezer3/NegativeAxis
Fix: Joysticks with an axis range below zero were inverted
This commit is contained in:
commit
519d13ccde
1 changed files with 20 additions and 7 deletions
|
@ -404,6 +404,8 @@ namespace OpenTK.Platform.Windows
|
|||
stick.SetHat(collection, page, usage, GetHatPosition(value, stick.AxisCaps[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stick.AxisCaps[i].LogicalMin > 0)
|
||||
{
|
||||
short scaled_value = (short) HidHelper.ScaleValue(
|
||||
(int) ((long) value + stick.AxisCaps[i].LogicalMin),
|
||||
|
@ -411,6 +413,17 @@ namespace OpenTK.Platform.Windows
|
|||
Int16.MinValue, Int16.MaxValue);
|
||||
stick.SetAxis(collection, page, usage, scaled_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
//If our stick returns a minimum value below zero, we should not add this to our value
|
||||
//before attempting to scale it, as this then inverts the value
|
||||
short scaled_value = (short)HidHelper.ScaleValue(
|
||||
(int)(long)value,
|
||||
stick.AxisCaps[i].LogicalMin, stick.AxisCaps[i].LogicalMax,
|
||||
Int16.MinValue, Int16.MaxValue);
|
||||
stick.SetAxis(collection, page, usage, scaled_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue