Joystick hat: treat invalid combinations as nothing pressed

Previously this condition asserted, but on win32 it's possible to get
opposing directions set simultaneously with some xinput controllers.
This commit is contained in:
Peter Johnson 2023-03-07 23:03:06 -08:00
parent 9a87635686
commit 008fab88bb
No known key found for this signature in database
GPG Key ID: FE8D173228CE7AB9

View File

@ -464,8 +464,10 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
// Valid hat values only use the least significant nibble and have at most two bits
// set, which can be considered adjacent plus an arbitrary rotation within the nibble
// Treat invalid combinations as nothing pressed
assert((value & 0xf0) == 0);
assert((value & ((value << 2) | (value >> 2))) == 0);
if ((value & ((value << 2) | (value >> 2))) != 0)
value = 0;
base = js->buttonCount + hat * 4;