diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 3342e0fe..e3e03cf1 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -45,9 +45,9 @@ // Attempt to open the specified joystick device // +#if defined(__linux__) static GLFWbool openJoystickDevice(const char* path) { -#if defined(__linux__) char axisCount, buttonCount; char name[256]; int joy, fd, version; @@ -102,9 +102,9 @@ static GLFWbool openJoystickDevice(const char* path) js->buttons = calloc(buttonCount, 1); _glfwInputJoystickChange(joy, GLFW_CONNECTED); -#endif // __linux__ return GLFW_TRUE; } +#endif // __linux__ // Polls for and processes events the specified joystick // @@ -155,12 +155,14 @@ static GLFWbool pollJoystickEvents(_GLFWjoystickLinux* js) // Lexically compare joysticks, used by quicksort // +#if defined(__linux__) static int compareJoysticks(const void* fp, const void* sp) { const _GLFWjoystickLinux* fj = fp; const _GLFWjoystickLinux* sj = sp; return strcmp(fj->path, sj->path); } +#endif // __linux__ ////////////////////////////////////////////////////////////////////////// @@ -274,6 +276,7 @@ void _glfwTerminateJoysticksLinux(void) void _glfwPollJoystickEvents(void) { +#if defined(__linux__) ssize_t offset = 0; char buffer[16384]; @@ -293,6 +296,7 @@ void _glfwPollJoystickEvents(void) offset += sizeof(struct inotify_event) + e->len; } +#endif } diff --git a/src/x11_window.c b/src/x11_window.c index fbe36f1d..7cf26ce3 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -57,16 +57,16 @@ void selectDisplayConnection(struct timeval* timeout) int result, count; const int fd = ConnectionNumber(_glfw.x11.display); + count = fd + 1; + FD_ZERO(&fds); FD_SET(fd, &fds); #if defined(__linux__) FD_SET(_glfw.linux_js.inotify, &fds); -#endif - if (fd > _glfw.linux_js.inotify) - count = fd + 1; - else + if (fd < _glfw.linux_js.inotify) count = _glfw.linux_js.inotify + 1; +#endif // NOTE: We use select instead of an X function like XNextEvent, as the // wait inside those are guarded by the mutex protecting the display