From 008fab88bb754642708bc3b7da977e472f24931f Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 7 Mar 2023 23:03:06 -0800 Subject: [PATCH] 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. --- src/input.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/input.c b/src/input.c index 36128e10..195369b8 100644 --- a/src/input.c +++ b/src/input.c @@ -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;