Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FreeBSD support to the glfw joystick code. #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion v3.3/glfw/c_glfw_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package glfw

/*
#cgo LDFLAGS: -linotify
#ifdef _GLFW_WAYLAND
#include "glfw/src/wl_init.c"
#include "glfw/src/wl_monitor.c"
Expand All @@ -20,7 +21,7 @@ package glfw
#include "glfw/src/x11_window.c"
#include "glfw/src/glx_context.c"
#endif
#include "glfw/src/null_joystick.c"
#include "glfw/src/linux_joystick.c"
#include "glfw/src/posix_time.c"
#include "glfw/src/posix_thread.c"
#include "glfw/src/xkb_unicode.c"
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/linux_joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ GLFWbool _glfwInitJoysticksLinux(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;
Expand Down
4 changes: 4 additions & 0 deletions v3.3/glfw/glfw/src/linux_joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions v3.3/glfw/glfw/src/wl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ int _glfwPlatformInit(void)
// Sync so we got all initial output events
wl_display_roundtrip(_glfw.wl.display);

#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
if (!_glfwInitJoysticksLinux())
return GLFW_FALSE;
#endif
Expand Down Expand Up @@ -1217,7 +1217,7 @@ int _glfwPlatformInit(void)

void _glfwPlatformTerminate(void)
{
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
_glfwTerminateJoysticksLinux();
#endif
_glfwTerminateEGL();
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/wl_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions v3.3/glfw/glfw/src/x11_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ int _glfwPlatformInit(void)
}
}

#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
if (!_glfwInitJoysticksLinux())
return GLFW_FALSE;
#endif
Expand Down Expand Up @@ -1187,7 +1187,7 @@ void _glfwPlatformTerminate(void)
_glfwTerminateEGL();
_glfwTerminateGLX();

#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
_glfwTerminateJoysticksLinux();
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/x11_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk
#include "glx_context.h"
#include "egl_context.h"
#include "osmesa_context.h"
#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
#include "linux_joystick.h"
#else
#include "null_joystick.h"
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/x11_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2771,7 +2771,7 @@ void _glfwPlatformPollEvents(void)
{
_GLFWwindow* window;

#if defined(__linux__)
#if defined(__linux__) || defined(__FreeBSD__)
_glfwDetectJoystickConnectionLinux();
#endif
XPending(_glfw.x11.display);
Expand Down