mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Fix X11 build on non-Linux systems
This commit is contained in:
parent
12a695696d
commit
9d50a346f0
|
@ -45,9 +45,9 @@
|
||||||
|
|
||||||
// Attempt to open the specified joystick device
|
// Attempt to open the specified joystick device
|
||||||
//
|
//
|
||||||
|
#if defined(__linux__)
|
||||||
static GLFWbool openJoystickDevice(const char* path)
|
static GLFWbool openJoystickDevice(const char* path)
|
||||||
{
|
{
|
||||||
#if defined(__linux__)
|
|
||||||
char axisCount, buttonCount;
|
char axisCount, buttonCount;
|
||||||
char name[256];
|
char name[256];
|
||||||
int joy, fd, version;
|
int joy, fd, version;
|
||||||
|
@ -102,9 +102,9 @@ static GLFWbool openJoystickDevice(const char* path)
|
||||||
js->buttons = calloc(buttonCount, 1);
|
js->buttons = calloc(buttonCount, 1);
|
||||||
|
|
||||||
_glfwInputJoystickChange(joy, GLFW_CONNECTED);
|
_glfwInputJoystickChange(joy, GLFW_CONNECTED);
|
||||||
#endif // __linux__
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
#endif // __linux__
|
||||||
|
|
||||||
// Polls for and processes events the specified joystick
|
// Polls for and processes events the specified joystick
|
||||||
//
|
//
|
||||||
|
@ -155,12 +155,14 @@ static GLFWbool pollJoystickEvents(_GLFWjoystickLinux* js)
|
||||||
|
|
||||||
// Lexically compare joysticks, used by quicksort
|
// Lexically compare joysticks, used by quicksort
|
||||||
//
|
//
|
||||||
|
#if defined(__linux__)
|
||||||
static int compareJoysticks(const void* fp, const void* sp)
|
static int compareJoysticks(const void* fp, const void* sp)
|
||||||
{
|
{
|
||||||
const _GLFWjoystickLinux* fj = fp;
|
const _GLFWjoystickLinux* fj = fp;
|
||||||
const _GLFWjoystickLinux* sj = sp;
|
const _GLFWjoystickLinux* sj = sp;
|
||||||
return strcmp(fj->path, sj->path);
|
return strcmp(fj->path, sj->path);
|
||||||
}
|
}
|
||||||
|
#endif // __linux__
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -274,6 +276,7 @@ void _glfwTerminateJoysticksLinux(void)
|
||||||
|
|
||||||
void _glfwPollJoystickEvents(void)
|
void _glfwPollJoystickEvents(void)
|
||||||
{
|
{
|
||||||
|
#if defined(__linux__)
|
||||||
ssize_t offset = 0;
|
ssize_t offset = 0;
|
||||||
char buffer[16384];
|
char buffer[16384];
|
||||||
|
|
||||||
|
@ -293,6 +296,7 @@ void _glfwPollJoystickEvents(void)
|
||||||
|
|
||||||
offset += sizeof(struct inotify_event) + e->len;
|
offset += sizeof(struct inotify_event) + e->len;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,16 +57,16 @@ void selectDisplayConnection(struct timeval* timeout)
|
||||||
int result, count;
|
int result, count;
|
||||||
const int fd = ConnectionNumber(_glfw.x11.display);
|
const int fd = ConnectionNumber(_glfw.x11.display);
|
||||||
|
|
||||||
|
count = fd + 1;
|
||||||
|
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(fd, &fds);
|
FD_SET(fd, &fds);
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
FD_SET(_glfw.linux_js.inotify, &fds);
|
FD_SET(_glfw.linux_js.inotify, &fds);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fd > _glfw.linux_js.inotify)
|
if (fd < _glfw.linux_js.inotify)
|
||||||
count = fd + 1;
|
|
||||||
else
|
|
||||||
count = _glfw.linux_js.inotify + 1;
|
count = _glfw.linux_js.inotify + 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
// NOTE: We use select instead of an X function like XNextEvent, as the
|
// NOTE: We use select instead of an X function like XNextEvent, as the
|
||||||
// wait inside those are guarded by the mutex protecting the display
|
// wait inside those are guarded by the mutex protecting the display
|
||||||
|
|
Loading…
Reference in New Issue
Block a user