mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
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
This commit is contained in:
parent
dd8a678a66
commit
0a19ea0a3e
@ -385,6 +385,7 @@ void _glfwTerminateJoysticksLinux(void)
|
|||||||
GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
||||||
{
|
{
|
||||||
// Read all queued events (non-blocking)
|
// Read all queued events (non-blocking)
|
||||||
|
GLFWbool event_valid = GLFW_FALSE;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
struct input_event e;
|
struct input_event e;
|
||||||
@ -395,6 +396,8 @@ GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
|||||||
// Reset the joystick slot if the device was disconnected
|
// Reset the joystick slot if the device was disconnected
|
||||||
if (errno == ENODEV)
|
if (errno == ENODEV)
|
||||||
closeJoystick(js);
|
closeJoystick(js);
|
||||||
|
else if ((errno == EAGAIN) && (mode != _GLFW_POLL_PRESENCE))
|
||||||
|
return event_valid;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -406,6 +409,7 @@ GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
|||||||
else if (e.code == SYN_REPORT)
|
else if (e.code == SYN_REPORT)
|
||||||
{
|
{
|
||||||
_glfw.linjs.dropped = GLFW_FALSE;
|
_glfw.linjs.dropped = GLFW_FALSE;
|
||||||
|
event_valid = GLFW_TRUE;
|
||||||
pollAbsState(js);
|
pollAbsState(js);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user