diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3e94336 --- /dev/null +++ b/go.mod @@ -0,0 +1 @@ +module github.com/go-gl/glfw diff --git a/v3.2/glfw/build.go b/v3.2/glfw/build.go index 0f62dc2..96bd79c 100644 --- a/v3.2/glfw/build.go +++ b/v3.2/glfw/build.go @@ -22,7 +22,7 @@ package glfw // Linux Build Tags // ---------------- // GLFW Options: -#cgo linux,!wayland CFLAGS: -D_GLFW_X11 +#cgo linux,!wayland CFLAGS: -D_GLFW_X11 -D_GNU_SOURCE #cgo linux,wayland CFLAGS: -D_GLFW_WAYLAND -D_GNU_SOURCE // Linker Options: diff --git a/v3.2/glfw/glfw/src/linux_joystick.c b/v3.2/glfw/glfw/src/linux_joystick.c index 561b1eb..ed89891 100644 --- a/v3.2/glfw/glfw/src/linux_joystick.c +++ b/v3.2/glfw/glfw/src/linux_joystick.c @@ -215,15 +215,23 @@ GLFWbool _glfwInitJoysticksLinux(void) while ((entry = readdir(dir))) { - char path[20]; regmatch_t match; + char* path = NULL; if (regexec(&_glfw.linux_js.regex, entry->d_name, 1, &match, 0) != 0) continue; + if (asprintf(&path, "%s/%s", dirname, entry->d_name) < 0) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Linux: Failed to construct device path: %s", + strerror(errno)); + continue; + } - snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name); if (openJoystickDevice(path)) count++; + + free(path); } closedir(dir);