From 660034332d35b9600a71dac105e40f2c33b0929d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 19 Mar 2014 15:27:49 +0100 Subject: [PATCH] Separated joystick state from window system state. This is partially in preparation for pending support for additional joystick APIs like XInput, DirectInput and IOHID. --- src/CMakeLists.txt | 14 +++-- src/cocoa_platform.h | 30 +--------- src/internal.h | 2 + src/iokit_joystick.h | 69 ++++++++++++++++++++++ src/{cocoa_joystick.m => iokit_joystick.m} | 28 ++++----- src/linux_joystick.c | 62 +++++++++---------- src/linux_joystick.h | 36 +++++++---- src/unix_time.c | 1 + src/wayland_platform.h | 2 - src/win32_platform.h | 11 +--- src/{win32_joystick.c => winmm_joystick.c} | 14 ++--- src/winmm_joystick.h | 56 ++++++++++++++++++ src/x11_platform.h | 3 - 13 files changed, 214 insertions(+), 114 deletions(-) create mode 100644 src/iokit_joystick.h rename src/{cocoa_joystick.m => iokit_joystick.m} (95%) rename src/{win32_joystick.c => winmm_joystick.c} (93%) create mode 100644 src/winmm_joystick.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3336f3d6..44270173 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,15 +12,17 @@ set(common_SOURCES clipboard.c context.c gamma.c init.c input.c joystick.c monitor.c time.c window.c) if (_GLFW_COCOA) - set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h posix_tls.h) + set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h iokit_joystick.h + posix_tls.h) set(glfw_SOURCES ${common_SOURCES} cocoa_clipboard.m cocoa_gamma.c - cocoa_init.m cocoa_joystick.m cocoa_monitor.m cocoa_time.c - cocoa_window.m posix_tls.c) + cocoa_init.m cocoa_monitor.m cocoa_time.c cocoa_window.m + iokit_joystick.m posix_tls.c) elseif (_GLFW_WIN32) - set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_tls.h) + set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_tls.h + winmm_joystick.h) set(glfw_SOURCES ${common_SOURCES} win32_clipboard.c win32_gamma.c - win32_init.c win32_joystick.c win32_monitor.c win32_time.c - win32_tls.c win32_window.c) + win32_init.c win32_monitor.c win32_time.c win32_tls.c + win32_window.c winmm_joystick.c) elseif (_GLFW_X11) set(glfw_HEADERS ${common_HEADERS} x11_platform.h posix_tls.h) set(glfw_SOURCES ${common_SOURCES} x11_clipboard.c x11_gamma.c x11_init.c diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index ef44abbd..7a7f5bab 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -45,10 +45,7 @@ typedef void* id; #error "No supported context creation API selected" #endif -#include -#include -#include -#include +#include "iokit_joystick.h" #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns @@ -74,26 +71,6 @@ typedef struct _GLFWwindowNS } _GLFWwindowNS; -//------------------------------------------------------------------------ -// Joystick information & state -//------------------------------------------------------------------------ -typedef struct -{ - int present; - char name[256]; - - IOHIDDeviceInterface** interface; - - CFMutableArrayRef axisElements; - CFMutableArrayRef buttonElements; - CFMutableArrayRef hatElements; - - float* axes; - unsigned char* buttons; - -} _GLFWjoy; - - //------------------------------------------------------------------------ // Platform-specific library global data for Cocoa //------------------------------------------------------------------------ @@ -111,7 +88,6 @@ typedef struct _GLFWlibraryNS char* clipboardString; - _GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1]; } _GLFWlibraryNS; @@ -143,10 +119,6 @@ typedef struct _GLFWcursorNS // Time void _glfwInitTimer(void); -// Joystick input -void _glfwInitJoysticks(void); -void _glfwTerminateJoysticks(void); - // Fullscreen GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoMode(_GLFWmonitor* monitor); diff --git a/src/internal.h b/src/internal.h index 95e8fc3b..0c11e8ad 100644 --- a/src/internal.h +++ b/src/internal.h @@ -349,6 +349,8 @@ struct _GLFWlibrary _GLFW_PLATFORM_LIBRARY_WINDOW_STATE; // This is defined in the context API's platform.h _GLFW_PLATFORM_LIBRARY_OPENGL_STATE; + // This is defined in the platform's joystick.h + _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE; // This is defined in the platform's tls.h _GLFW_PLATFORM_TLS_STATE; }; diff --git a/src/iokit_joystick.h b/src/iokit_joystick.h new file mode 100644 index 00000000..f90ae1d4 --- /dev/null +++ b/src/iokit_joystick.h @@ -0,0 +1,69 @@ +//======================================================================== +// GLFW 3.1 IOKit - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2006-2014 Camilla Berglund +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#ifndef _iokit_joystick_h_ +#define _iokit_joystick_h_ + +#include +#include +#include +#include + +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \ + _GLFWjoystickIOKit joystick[GLFW_JOYSTICK_LAST + 1] + + +//======================================================================== +// GLFW platform specific types +//======================================================================== + +//------------------------------------------------------------------------ +// Platform-specific joystick structure +//------------------------------------------------------------------------ +typedef struct _GLFWjoystickIOKit +{ + int present; + char name[256]; + + IOHIDDeviceInterface** interface; + + CFMutableArrayRef axisElements; + CFMutableArrayRef buttonElements; + CFMutableArrayRef hatElements; + + float* axes; + unsigned char* buttons; +} _GLFWjoystickIOKit; + + +//======================================================================== +// Prototypes for platform specific internal functions +//======================================================================== + +void _glfwInitJoysticks(void); +void _glfwTerminateJoysticks(void); + +#endif // _iokit_joystick_h_ diff --git a/src/cocoa_joystick.m b/src/iokit_joystick.m similarity index 95% rename from src/cocoa_joystick.m rename to src/iokit_joystick.m index dc798b8b..40721504 100644 --- a/src/cocoa_joystick.m +++ b/src/iokit_joystick.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.1 OS X - www.glfw.org +// GLFW 3.1 IOKit - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2010 Camilla Berglund // Copyright (c) 2012 Torsten Walluhn @@ -58,7 +58,7 @@ static void getElementsCFArrayHandler(const void* value, void* parameter); // Adds an element to the specified joystick // -static void addJoystickElement(_GLFWjoy* joystick, CFTypeRef elementRef) +static void addJoystickElement(_GLFWjoystickIOKit* joystick, CFTypeRef elementRef) { long elementType, usagePage, usage; CFMutableArrayRef elementsArray = NULL; @@ -146,12 +146,12 @@ static void addJoystickElement(_GLFWjoy* joystick, CFTypeRef elementRef) static void getElementsCFArrayHandler(const void* value, void* parameter) { if (CFGetTypeID(value) == CFDictionaryGetTypeID()) - addJoystickElement((_GLFWjoy*) parameter, (CFTypeRef) value); + addJoystickElement((_GLFWjoystickIOKit*) parameter, (CFTypeRef) value); } // Returns the value of the specified element of the specified joystick // -static long getElementValue(_GLFWjoy* joystick, _GLFWjoyelement* element) +static long getElementValue(_GLFWjoystickIOKit* joystick, _GLFWjoyelement* element) { IOReturn result = kIOReturnSuccess; IOHIDEventStruct hidEvent; @@ -178,7 +178,7 @@ static long getElementValue(_GLFWjoy* joystick, _GLFWjoyelement* element) // Removes the specified joystick // -static void removeJoystick(_GLFWjoy* joystick) +static void removeJoystick(_GLFWjoystickIOKit* joystick) { int i; @@ -203,14 +203,14 @@ static void removeJoystick(_GLFWjoy* joystick) (*(joystick->interface))->close(joystick->interface); (*(joystick->interface))->Release(joystick->interface); - memset(joystick, 0, sizeof(_GLFWjoy)); + memset(joystick, 0, sizeof(_GLFWjoystickIOKit)); } // Callback for user-initiated joystick removal // static void removalCallback(void* target, IOReturn result, void* refcon, void* sender) { - removeJoystick((_GLFWjoy*) refcon); + removeJoystick((_GLFWjoystickIOKit*) refcon); } // Polls for joystick events and updates GLFW state @@ -223,7 +223,7 @@ static void pollJoystickEvents(void) { CFIndex i; int buttonIndex = 0; - _GLFWjoy* joystick = _glfw.ns.joysticks + joy; + _GLFWjoystickIOKit* joystick = _glfw.joystick + joy; if (!joystick->present) continue; @@ -368,7 +368,7 @@ void _glfwInitJoysticks(void) CFRelease(valueRef); } - _GLFWjoy* joystick = _glfw.ns.joysticks + joy; + _GLFWjoystickIOKit* joystick = _glfw.joystick + joy; joystick->present = GL_TRUE; result = IOCreatePlugInInterfaceForService(ioHIDDeviceObject, @@ -450,7 +450,7 @@ void _glfwTerminateJoysticks(void) for (i = 0; i < GLFW_JOYSTICK_LAST + 1; i++) { - _GLFWjoy* joystick = &_glfw.ns.joysticks[i]; + _GLFWjoystickIOKit* joystick = &_glfw.joystick[i]; removeJoystick(joystick); } } @@ -464,12 +464,12 @@ int _glfwPlatformJoystickPresent(int joy) { pollJoystickEvents(); - return _glfw.ns.joysticks[joy].present; + return _glfw.joystick[joy].present; } const float* _glfwPlatformGetJoystickAxes(int joy, int* count) { - _GLFWjoy* joystick = _glfw.ns.joysticks + joy; + _GLFWjoystickIOKit* joystick = _glfw.joystick + joy; pollJoystickEvents(); @@ -482,7 +482,7 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count) const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count) { - _GLFWjoy* joystick = _glfw.ns.joysticks + joy; + _GLFWjoystickIOKit* joystick = _glfw.joystick + joy; pollJoystickEvents(); @@ -498,6 +498,6 @@ const char* _glfwPlatformGetJoystickName(int joy) { pollJoystickEvents(); - return _glfw.ns.joysticks[joy].name; + return _glfw.joystick[joy].name; } diff --git a/src/linux_joystick.c b/src/linux_joystick.c index bb5efcda..81f10f26 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -56,7 +56,7 @@ static int openJoystickDevice(int joy, const char* path) if (fd == -1) return GL_FALSE; - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].fd = fd; + _glfw.joystick[joy].fd = fd; // Verify that the joystick driver version is at least 1.0 ioctl(fd, JSIOCGVERSION, &version); @@ -70,20 +70,18 @@ static int openJoystickDevice(int joy, const char* path) if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0) strncpy(name, "Unknown", sizeof(name)); - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].name = strdup(name); + _glfw.joystick[joy].name = strdup(name); ioctl(fd, JSIOCGAXES, &axisCount); - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].axisCount = (int) axisCount; + _glfw.joystick[joy].axisCount = (int) axisCount; ioctl(fd, JSIOCGBUTTONS, &buttonCount); - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].buttonCount = (int) buttonCount; + _glfw.joystick[joy].buttonCount = (int) buttonCount; - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].axes = - calloc(axisCount, sizeof(float)); - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].buttons = - calloc(buttonCount, 1); + _glfw.joystick[joy].axes = calloc(axisCount, sizeof(float)); + _glfw.joystick[joy].buttons = calloc(buttonCount, 1); - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].present = GL_TRUE; + _glfw.joystick[joy].present = GL_TRUE; #endif // __linux__ return GL_TRUE; @@ -100,23 +98,21 @@ static void pollJoystickEvents(void) for (i = 0; i <= GLFW_JOYSTICK_LAST; i++) { - if (!_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].present) + if (!_glfw.joystick[i].present) continue; // Read all queued events (non-blocking) for (;;) { errno = 0; - result = read(_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].fd, - &e, - sizeof(e)); + result = read(_glfw.joystick[i].fd, &e, sizeof(e)); if (errno == ENODEV) { - free(_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].axes); - free(_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].buttons); - free(_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].name); - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].present = GL_FALSE; + free(_glfw.joystick[i].axes); + free(_glfw.joystick[i].buttons); + free(_glfw.joystick[i].name); + _glfw.joystick[i].present = GL_FALSE; } if (result == -1) @@ -128,12 +124,12 @@ static void pollJoystickEvents(void) switch (e.type) { case JS_EVENT_AXIS: - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].axes[e.number] = + _glfw.joystick[i].axes[e.number] = (float) e.value / 32767.0f; break; case JS_EVENT_BUTTON: - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].buttons[e.number] = + _glfw.joystick[i].buttons[e.number] = e.value ? GLFW_PRESS : GLFW_RELEASE; break; @@ -208,14 +204,14 @@ void _glfwTerminateJoysticks(void) for (i = 0; i <= GLFW_JOYSTICK_LAST; i++) { - if (_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].present) + if (_glfw.joystick[i].present) { - close(_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].fd); - free(_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].axes); - free(_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].buttons); - free(_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].name); + close(_glfw.joystick[i].fd); + free(_glfw.joystick[i].axes); + free(_glfw.joystick[i].buttons); + free(_glfw.joystick[i].name); - _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[i].present = GL_FALSE; + _glfw.joystick[i].present = GL_FALSE; } } #endif // __linux__ @@ -230,35 +226,35 @@ int _glfwPlatformJoystickPresent(int joy) { pollJoystickEvents(); - return _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].present; + return _glfw.joystick[joy].present; } const float* _glfwPlatformGetJoystickAxes(int joy, int* count) { pollJoystickEvents(); - if (!_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].present) + if (!_glfw.joystick[joy].present) return NULL; - *count = _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].axisCount; - return _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].axes; + *count = _glfw.joystick[joy].axisCount; + return _glfw.joystick[joy].axes; } const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count) { pollJoystickEvents(); - if (!_GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].present) + if (!_glfw.joystick[joy].present) return NULL; - *count = _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].buttonCount; - return _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].buttons; + *count = _glfw.joystick[joy].buttonCount; + return _glfw.joystick[joy].buttons; } const char* _glfwPlatformGetJoystickName(int joy) { pollJoystickEvents(); - return _GLFW_LINUX_JOYSTICK_CONTEXT.joystick[joy].name; + return _glfw.joystick[joy].name; } diff --git a/src/linux_joystick.h b/src/linux_joystick.h index 8f49b784..5c03c286 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -27,19 +27,33 @@ #ifndef _linux_joystick_h_ #define _linux_joystick_h_ -typedef struct _GLFWjoystickLinux { - struct { - int present; - int fd; - float* axes; - int axisCount; - unsigned char* buttons; - int buttonCount; - char* name; - } joystick[GLFW_JOYSTICK_LAST + 1]; +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \ + _GLFWjoystickLinux joystick[GLFW_JOYSTICK_LAST + 1] + + +//======================================================================== +// GLFW platform specific types +//======================================================================== + +//------------------------------------------------------------------------ +// Platform-specific joystick structure +//------------------------------------------------------------------------ +typedef struct _GLFWjoystickLinux +{ + int present; + int fd; + float* axes; + int axisCount; + unsigned char* buttons; + int buttonCount; + char* name; } _GLFWjoystickLinux; -// Joystick input + +//======================================================================== +// Prototypes for platform specific internal functions +//======================================================================== + void _glfwInitJoysticks(void); void _glfwTerminateJoysticks(void); diff --git a/src/unix_time.c b/src/unix_time.c index 3a558080..775cb1c5 100644 --- a/src/unix_time.c +++ b/src/unix_time.c @@ -94,3 +94,4 @@ void _glfwPlatformSetTime(double time) _GLFW_UNIX_TIME_CONTEXT.base = getRawTime() - (uint64_t) (time / _GLFW_UNIX_TIME_CONTEXT.resolution); } + diff --git a/src/wayland_platform.h b/src/wayland_platform.h index 21c4c18f..7bf36f82 100644 --- a/src/wayland_platform.h +++ b/src/wayland_platform.h @@ -36,7 +36,6 @@ #error "The Wayland backend depends on EGL platform support" #endif -#define _GLFW_LINUX_JOYSTICK_CONTEXT _glfw.wayland.joystick #include "linux_joystick.h" #define _GLFW_UNIX_TIME_CONTEXT _glfw.wayland.timer @@ -76,7 +75,6 @@ typedef struct _GLFWlibraryWayland int monitorsSize; _GLFWtimeUNIX timer; - _GLFWjoystickLinux joystick; } _GLFWlibraryWayland; typedef struct _GLFWmonitorWayland diff --git a/src/win32_platform.h b/src/win32_platform.h index ee4ebcf5..154eb601 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -163,6 +163,8 @@ typedef HRESULT (WINAPI * DWMISCOMPOSITIONENABLED_T)(BOOL*); #error "No supported context creation API selected" #endif +#include "winmm_joystick.h" + #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32 #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32 @@ -232,11 +234,6 @@ typedef struct _GLFWlibraryWin32 DWMISCOMPOSITIONENABLED_T DwmIsCompositionEnabled; } dwmapi; - struct { - float axes[6]; - unsigned char buttons[36]; // 32 buttons plus one hat - char* name; - } joystick[GLFW_JOYSTICK_LAST + 1]; } _GLFWlibraryWin32; @@ -276,10 +273,6 @@ char* _glfwCreateUTF8FromWideString(const WCHAR* source); // Time void _glfwInitTimer(void); -// Joystick input -void _glfwInitJoysticks(void); -void _glfwTerminateJoysticks(void); - // Fullscreen support GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoMode(_GLFWmonitor* monitor); diff --git a/src/win32_joystick.c b/src/winmm_joystick.c similarity index 93% rename from src/win32_joystick.c rename to src/winmm_joystick.c index a68a9b4d..789b0c3a 100644 --- a/src/win32_joystick.c +++ b/src/winmm_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.1 Win32 - www.glfw.org +// GLFW 3.1 WinMM - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2010 Camilla Berglund @@ -63,7 +63,7 @@ void _glfwTerminateJoysticks(void) int i; for (i = 0; i < GLFW_JOYSTICK_LAST; i++) - free(_glfw.win32.joystick[i].name); + free(_glfw.joystick[i].name); } @@ -85,7 +85,7 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count) { JOYCAPS jc; JOYINFOEX ji; - float* axes = _glfw.win32.joystick[joy].axes; + float* axes = _glfw.joystick[joy].axes; if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR) return NULL; @@ -118,7 +118,7 @@ const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count) { JOYCAPS jc; JOYINFOEX ji; - unsigned char* buttons = _glfw.win32.joystick[joy].buttons; + unsigned char* buttons = _glfw.joystick[joy].buttons; if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR) return NULL; @@ -169,9 +169,9 @@ const char* _glfwPlatformGetJoystickName(int joy) if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR) return NULL; - free(_glfw.win32.joystick[joy].name); - _glfw.win32.joystick[joy].name = _glfwCreateUTF8FromWideString(jc.szPname); + free(_glfw.joystick[joy].name); + _glfw.joystick[joy].name = _glfwCreateUTF8FromWideString(jc.szPname); - return _glfw.win32.joystick[joy].name; + return _glfw.joystick[joy].name; } diff --git a/src/winmm_joystick.h b/src/winmm_joystick.h new file mode 100644 index 00000000..19d1bbb5 --- /dev/null +++ b/src/winmm_joystick.h @@ -0,0 +1,56 @@ +//======================================================================== +// GLFW 3.1 WinMM - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2006-2014 Camilla Berglund +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#ifndef _winmm_joystick_h_ +#define _winmm_joystick_h_ + +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \ + _GLFWjoystickWinMM joystick[GLFW_JOYSTICK_LAST + 1] + + +//======================================================================== +// GLFW platform specific types +//======================================================================== + +//------------------------------------------------------------------------ +// Platform-specific joystick structure +//------------------------------------------------------------------------ +typedef struct _GLFWjoystickWinMM +{ + float axes[6]; + unsigned char buttons[36]; // 32 buttons plus one hat + char* name; +} _GLFWjoystickWinMM; + + +//======================================================================== +// Prototypes for platform specific internal functions +//======================================================================== + +void _glfwInitJoysticks(void); +void _glfwTerminateJoysticks(void); + +#endif // _winmm_joystick_h_ diff --git a/src/x11_platform.h b/src/x11_platform.h index 802aaec4..6962b045 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -65,7 +65,6 @@ #define _GLFW_UNIX_TIME_CONTEXT _glfw.x11.timer #include "unix_time.h" -#define _GLFW_LINUX_JOYSTICK_CONTEXT _glfw.x11.joystick #include "linux_joystick.h" #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11 @@ -215,8 +214,6 @@ typedef struct _GLFWlibraryX11 Window source; } xdnd; - _GLFWjoystickLinux joystick; - } _GLFWlibraryX11;