diff --git a/README.md b/README.md index f43bf6c0..e71125c9 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Bitness test in `FindVulkan.cmake` was VS specific (#928) - [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading - [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X +- [Linux] Bugfix: Event processing did not detect joystick disconnection (#932) - [Cocoa] Added support for Vulkan window surface creation via [MoltenVK](https://moltengl.com/moltenvk/) (#870) - [Cocoa] Bugfix: Disabling window aspect ratio would assert (#852) diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 7a7b4561..cfc15a49 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -146,7 +146,7 @@ GLFWbool _glfwInitJoysticksLinux(void) _glfw.linjs.watch = inotify_add_watch(_glfw.linjs.inotify, dirname, - IN_CREATE | IN_ATTRIB); + IN_CREATE | IN_ATTRIB | IN_DELETE); if (_glfw.linjs.watch == -1) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -240,7 +240,22 @@ void _glfwDetectJoystickConnectionLinux(void) { char path[20]; snprintf(path, sizeof(path), "/dev/input/%s", e->name); - openJoystickDevice(path); + + if (e->mask & (IN_CREATE | IN_ATTRIB)) + openJoystickDevice(path); + else if (e->mask & IN_DELETE) + { + int jid; + + for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) + { + if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0) + { + closeJoystick(_glfw.joysticks + jid); + break; + } + } + } } offset += sizeof(struct inotify_event) + e->len;