Compare commits

...

2 Commits

Author SHA1 Message Date
Yang sheng
e83207d54a
Merge 0a19ea0a3e into 0d2d85d19c 2025-08-18 12:01:52 +00:00
iysheng
0a19ea0a3e Linux: Modify _glfwPollJoystickLinux return true only when new valid event
To keep consistent with the event reporting mechanism, and returns true only
when a new valid event occurs
2022-09-22 17:34:57 +08:00

View File

@ -386,6 +386,7 @@ void _glfwTerminateJoysticksLinux(void)
GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
{
// Read all queued events (non-blocking)
GLFWbool event_valid = GLFW_FALSE;
for (;;)
{
struct input_event e;
@ -396,6 +397,8 @@ GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
// Reset the joystick slot if the device was disconnected
if (errno == ENODEV)
closeJoystick(js);
else if ((errno == EAGAIN) && (mode != _GLFW_POLL_PRESENCE))
return event_valid;
break;
}
@ -407,6 +410,7 @@ GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
else if (e.code == SYN_REPORT)
{
_glfw.linjs.dropped = GLFW_FALSE;
event_valid = GLFW_TRUE;
pollAbsState(js);
}
}