This commit is contained in:
divVerent 2021-09-20 00:24:39 -04:00 committed by GitHub
commit 3a4b6c03ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 7 deletions

View File

@ -88,6 +88,10 @@ in the documentation for more information.
GLFW itself needs only CMake 3.1 or later and the headers and libraries for your
OS and window system.
As an exception, on FreeBSD, the `devel/evdev-proto` and `devel/libinotify`
ports need to be installed; furthermore, to actually use gamepads/joysticks,
`multimedia/webcamd` needs to be installed and configured.
The examples and test programs depend on a number of tiny libraries. These are
located in the `deps/` directory.

View File

@ -49,6 +49,12 @@ endif()
if (_GLFW_X11 OR _GLFW_WAYLAND)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
pkg_check_modules(LIBINOTIFY REQUIRED libinotify)
target_link_libraries(glfw PRIVATE ${LIBINOTIFY_LINK_LIBRARIES})
target_include_directories(glfw PRIVATE ${LIBINOTIFY_INCLUDE_DIRS})
target_compile_options(glfw PRIVATE ${LIBINOTIFY_CFLAGS_OTHER})
else()
target_sources(glfw PRIVATE null_joystick.h null_joystick.c)
endif()

View File

@ -324,7 +324,7 @@ GLFWbool _glfwPlatformInitJoysticks(void)
// Continue without device connection notifications if inotify fails
if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
if (regcomp(&_glfw.linjs.regex, "^event[0-9][0-9]*$", 0) != 0)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
return GLFW_FALSE;

View File

@ -25,7 +25,11 @@
//========================================================================
#include <linux/input.h>
#ifdef __linux__
#include <linux/limits.h>
#else
#include <limits.h>
#endif
#include <regex.h>
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs

View File

@ -47,7 +47,7 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
#include "posix_thread.h"
#include "posix_time.h"
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include "linux_joystick.h"
#else
#include "null_joystick.h"

View File

@ -1487,7 +1487,7 @@ const char* _glfwPlatformGetVersionString(void)
#if defined(_POSIX_MONOTONIC_CLOCK)
" monotonic"
#endif
#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
" evdev"
#endif
#if defined(_GLFW_BUILD_DLL)

View File

@ -378,7 +378,7 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk
#include "posix_time.h"
#include "xkb_unicode.h"
#include "glx_context.h"
#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
#include "linux_joystick.h"
#else
#include "null_joystick.h"

View File

@ -67,7 +67,7 @@ static GLFWbool waitForEvent(double* timeout)
const int fd = ConnectionNumber(_glfw.x11.display);
int count = fd + 1;
#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
if (_glfw.linjs.inotify > fd)
count = _glfw.linjs.inotify + 1;
#endif
@ -75,7 +75,7 @@ static GLFWbool waitForEvent(double* timeout)
{
FD_ZERO(&fds);
FD_SET(fd, &fds);
#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
if (_glfw.linjs.inotify > 0)
FD_SET(_glfw.linjs.inotify, &fds);
#endif
@ -2779,7 +2779,7 @@ void _glfwPlatformPollEvents(void)
{
_GLFWwindow* window;
#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
if (_glfw.joysticksInitialized)
_glfwDetectJoystickConnectionLinux();
#endif