mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
parent
ab2247f8f3
commit
a397195d3f
@ -199,6 +199,7 @@ information on what to include when reporting a bug.
|
|||||||
- [Linux] Moved to evdev for joystick input (#906,#1005)
|
- [Linux] Moved to evdev for joystick input (#906,#1005)
|
||||||
- [Linux] Bugfix: Event processing did not detect joystick disconnection (#932)
|
- [Linux] Bugfix: Event processing did not detect joystick disconnection (#932)
|
||||||
- [Linux] Bugfix: The joystick device path could be truncated (#1025)
|
- [Linux] Bugfix: The joystick device path could be truncated (#1025)
|
||||||
|
- [Linux] Bugfix: `glfwInit` would fail if inotify creation failed (#833)
|
||||||
- [Cocoa] Added support for Vulkan window surface creation via
|
- [Cocoa] Added support for Vulkan window surface creation via
|
||||||
[MoltenVK](https://moltengl.com/moltenvk/) (#870)
|
[MoltenVK](https://moltengl.com/moltenvk/) (#870)
|
||||||
- [Cocoa] Added support for loading a `MainMenu.nib` when available
|
- [Cocoa] Added support for loading a `MainMenu.nib` when available
|
||||||
|
@ -266,28 +266,17 @@ GLFWbool _glfwInitJoysticksLinux(void)
|
|||||||
const char* dirname = "/dev/input";
|
const char* dirname = "/dev/input";
|
||||||
|
|
||||||
_glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
_glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
||||||
if (_glfw.linjs.inotify == -1)
|
if (_glfw.linjs.inotify > 0)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
// HACK: Register for IN_ATTRIB to get notified when udev is done
|
||||||
"Linux: Failed to initialize inotify: %s",
|
// This works well in practice but the true way is libudev
|
||||||
strerror(errno));
|
|
||||||
return GLFW_FALSE;
|
_glfw.linjs.watch = inotify_add_watch(_glfw.linjs.inotify,
|
||||||
|
dirname,
|
||||||
|
IN_CREATE | IN_ATTRIB | IN_DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: Register for IN_ATTRIB as well to get notified when udev is done
|
// Continue without device connection notifications if inotify fails
|
||||||
// This works well in practice but the true way is libudev
|
|
||||||
|
|
||||||
_glfw.linjs.watch = inotify_add_watch(_glfw.linjs.inotify,
|
|
||||||
dirname,
|
|
||||||
IN_CREATE | IN_ATTRIB | IN_DELETE);
|
|
||||||
if (_glfw.linjs.watch == -1)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"Linux: Failed to watch for joystick connections in %s: %s",
|
|
||||||
dirname,
|
|
||||||
strerror(errno));
|
|
||||||
// Continue without device connection notifications
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
|
if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
|
||||||
{
|
{
|
||||||
@ -318,13 +307,8 @@ GLFWbool _glfwInitJoysticksLinux(void)
|
|||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
// Continue with no joysticks if enumeration fails
|
||||||
"Linux: Failed to open joystick device directory %s: %s",
|
|
||||||
dirname,
|
|
||||||
strerror(errno));
|
|
||||||
// Continue with no joysticks detected
|
|
||||||
}
|
|
||||||
|
|
||||||
qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks);
|
qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks);
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -359,6 +343,9 @@ void _glfwDetectJoystickConnectionLinux(void)
|
|||||||
ssize_t offset = 0;
|
ssize_t offset = 0;
|
||||||
char buffer[16384];
|
char buffer[16384];
|
||||||
|
|
||||||
|
if (_glfw.linjs.inotify <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
|
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
|
||||||
|
|
||||||
while (size > offset)
|
while (size > offset)
|
||||||
|
Loading…
Reference in New Issue
Block a user