Fix: Some joystick hats not returning centered correctly on Windows HID
This commit is contained in:
parent
9ea1f55139
commit
471dd5bf18
1 changed files with 22 additions and 4 deletions
|
@ -342,14 +342,32 @@ namespace OpenTK.Platform.Windows
|
||||||
HatPosition GetHatPosition(uint value, HidProtocolValueCaps caps)
|
HatPosition GetHatPosition(uint value, HidProtocolValueCaps caps)
|
||||||
{
|
{
|
||||||
if (caps.LogicalMax == 8)
|
if (caps.LogicalMax == 8)
|
||||||
return (HatPosition)value;
|
|
||||||
else if (caps.LogicalMax == 7)
|
|
||||||
{
|
{
|
||||||
|
//Hat states are represented as a plain number from 0-8
|
||||||
|
//with centered being zero
|
||||||
|
//Padding should have already been stripped out, so just cast
|
||||||
|
if (value > 8)
|
||||||
|
{
|
||||||
|
//Value out of bounds, so return centered
|
||||||
|
return HatPosition.Centered;
|
||||||
|
}
|
||||||
|
return (HatPosition)value;
|
||||||
|
}
|
||||||
|
if (caps.LogicalMax == 7)
|
||||||
|
{
|
||||||
|
//Hat states are represented as a plain number from 0-7
|
||||||
|
//with centered being 8
|
||||||
|
if (value > 8)
|
||||||
|
{
|
||||||
|
//Return zero if our value is out of bounds ==> e.g.
|
||||||
|
//Thrustmaster T-Flight Hotas X returns 15 for the centered position
|
||||||
|
return HatPosition.Centered;
|
||||||
|
}
|
||||||
value++;
|
value++;
|
||||||
value %= 9;
|
value %= 9;
|
||||||
return (HatPosition)value;
|
return (HatPosition)value;
|
||||||
}
|
}
|
||||||
else
|
//The HID report length is unsupported
|
||||||
return HatPosition.Centered;
|
return HatPosition.Centered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue