mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Possible control flow clarification.
This commit is contained in:
parent
382133b384
commit
899117e785
|
@ -93,7 +93,6 @@ static void pollJoystickEvents(void)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
int i;
|
int i;
|
||||||
ssize_t result;
|
|
||||||
struct js_event e;
|
struct js_event e;
|
||||||
|
|
||||||
for (i = 0; i <= GLFW_JOYSTICK_LAST; i++)
|
for (i = 0; i <= GLFW_JOYSTICK_LAST; i++)
|
||||||
|
@ -105,10 +104,12 @@ static void pollJoystickEvents(void)
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
result = read(_glfw.linux_js[i].fd, &e, sizeof(e));
|
if (read(_glfw.linux_js[i].fd, &e, sizeof(e)) < 0)
|
||||||
|
{
|
||||||
if (errno == ENODEV)
|
if (errno == ENODEV)
|
||||||
{
|
{
|
||||||
|
// The joystick was disconnected
|
||||||
|
|
||||||
free(_glfw.linux_js[i].axes);
|
free(_glfw.linux_js[i].axes);
|
||||||
free(_glfw.linux_js[i].buttons);
|
free(_glfw.linux_js[i].buttons);
|
||||||
free(_glfw.linux_js[i].name);
|
free(_glfw.linux_js[i].name);
|
||||||
|
@ -116,8 +117,8 @@ static void pollJoystickEvents(void)
|
||||||
memset(&_glfw.linux_js[i], 0, sizeof(_glfw.linux_js[i]));
|
memset(&_glfw.linux_js[i], 0, sizeof(_glfw.linux_js[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == -1)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// We don't care if it's an init event or not
|
// We don't care if it's an init event or not
|
||||||
e.type &= ~JS_EVENT_INIT;
|
e.type &= ~JS_EVENT_INIT;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user