From c812b9d87cb4afaae44ca7e9e6f40ddd35cce44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 9 Nov 2021 19:44:00 +0100 Subject: [PATCH] Add conditional compilation for platform units This is a step towards being able to compile GLFW manually without needing to duplicate a lot of platform- or OS-specific logic. --- CONTRIBUTORS.md | 1 + src/cocoa_init.m | 5 +++++ src/cocoa_joystick.h | 2 -- src/cocoa_joystick.m | 4 ++++ src/cocoa_monitor.m | 4 ++++ src/cocoa_time.c | 4 ++++ src/cocoa_window.m | 4 ++++ src/glx_context.c | 4 ++++ src/linux_joystick.c | 4 ++++ src/linux_joystick.h | 2 -- src/mappings.h | 12 ++++++------ src/mappings.h.in | 12 ++++++------ src/nsgl_context.m | 4 ++++ src/platform.h | 46 +++++++++++++++++++++++++++++++++++++++++--- src/posix_module.c | 4 ++++ src/posix_poll.c | 4 ++++ src/posix_thread.c | 4 ++++ src/posix_time.c | 4 ++++ src/wgl_context.c | 4 ++++ src/win32_init.c | 4 ++++ src/win32_joystick.c | 4 ++++ src/win32_joystick.h | 2 -- src/win32_module.c | 4 ++++ src/win32_monitor.c | 4 ++++ src/win32_thread.c | 4 ++++ src/win32_time.c | 3 +++ src/win32_window.c | 4 ++++ src/wl_init.c | 6 +++++- src/wl_monitor.c | 4 ++++ src/wl_window.c | 4 ++++ src/x11_init.c | 6 +++++- src/x11_monitor.c | 4 ++++ src/x11_window.c | 8 ++++++-- src/xkb_unicode.c | 3 +++ 34 files changed, 167 insertions(+), 25 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d938afae..e0bb9368 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -243,6 +243,7 @@ video tutorials. - Torsten Walluhn - Patrick Walton - Xo Wang + - Andre Weissflog - Jay Weisskopf - Frank Wille - Andy Williams diff --git a/src/cocoa_init.m b/src/cocoa_init.m index aa369f9c..b3831df1 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -27,6 +27,9 @@ //======================================================================== #include "internal.h" + +#if defined(_GLFW_COCOA) + #include // For MAXPATHLEN // Needed for _NSGetProgname @@ -690,3 +693,5 @@ void _glfwTerminateCocoa(void) } // autoreleasepool } +#endif // _GLFW_COCOA + diff --git a/src/cocoa_joystick.h b/src/cocoa_joystick.h index fc7ba7a2..2f46dfcb 100644 --- a/src/cocoa_joystick.h +++ b/src/cocoa_joystick.h @@ -31,8 +31,6 @@ #define GLFW_COCOA_JOYSTICK_STATE _GLFWjoystickNS ns; #define GLFW_COCOA_LIBRARY_JOYSTICK_STATE -#define GLFW_BUILD_COCOA_MAPPINGS - // Cocoa-specific per-joystick data // typedef struct _GLFWjoystickNS diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index ebcf5fdb..865adac7 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_COCOA) + #include #include #include @@ -476,3 +478,5 @@ void _glfwUpdateGamepadGUIDCocoa(char* guid) } } +#endif // _GLFW_COCOA + diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 64d9eb2c..6c7315bd 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_COCOA) + #include #include #include @@ -625,3 +627,5 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) return monitor->ns.displayID; } +#endif // _GLFW_COCOA + diff --git a/src/cocoa_time.c b/src/cocoa_time.c index c2bf8eda..8da367aa 100644 --- a/src/cocoa_time.c +++ b/src/cocoa_time.c @@ -28,6 +28,8 @@ #include "internal.h" +#if defined(GLFW_BUILD_COCOA_TIMER) + #include @@ -53,3 +55,5 @@ uint64_t _glfwPlatformGetTimerFrequency(void) return _glfw.timer.ns.frequency; } +#endif // GLFW_BUILD_COCOA_TIMER + diff --git a/src/cocoa_window.m b/src/cocoa_window.m index daac39b3..6f8aa978 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -28,6 +28,8 @@ #include "internal.h" +#if defined(_GLFW_COCOA) + #include #include @@ -2047,3 +2049,5 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) return window->ns.object; } +#endif // _GLFW_COCOA + diff --git a/src/glx_context.c b/src/glx_context.c index 3c38807f..4406dfd3 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_X11) + #include #include #include @@ -714,3 +716,5 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) return window->context.glx.window; } +#endif // _GLFW_X11 + diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 366bda2d..26db853e 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(GLFW_BUILD_LINUX_JOYSTICK) + #include #include #include @@ -429,3 +431,5 @@ void _glfwUpdateGamepadGUIDLinux(char* guid) { } +#endif // GLFW_BUILD_LINUX_JOYSTICK + diff --git a/src/linux_joystick.h b/src/linux_joystick.h index f898b2b9..df605e72 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -31,8 +31,6 @@ #define GLFW_LINUX_JOYSTICK_STATE _GLFWjoystickLinux linjs; #define GLFW_LINUX_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs; -#define GLFW_BUILD_LINUX_MAPPINGS - // Linux-specific joystick data // typedef struct _GLFWjoystickLinux diff --git a/src/mappings.h b/src/mappings.h index 553fe2a2..270fa4cd 100644 --- a/src/mappings.h +++ b/src/mappings.h @@ -60,7 +60,7 @@ const char* _glfwDefaultMappings[] = { -#if defined(GLFW_BUILD_WIN32_MAPPINGS) +#if defined(_GLFW_WIN32) "03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows,", "03000000c82d00002038000000000000,8bitdo,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,", "03000000c82d00000951000000000000,8BitDo Dogbone Modkit,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b11,platform:Windows,", @@ -426,9 +426,9 @@ const char* _glfwDefaultMappings[] = "78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", -#endif // GLFW_BUILD_WIN32_MAPPINGS +#endif // _GLFW_WIN32 -#if defined(GLFW_BUILD_COCOA_MAPPINGS) +#if defined(_GLFW_COCOA) "030000008f0e00000300000009010000,2In1 USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,", "03000000c82d00000090000001000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,", "03000000c82d00001038000000010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,", @@ -598,9 +598,9 @@ const char* _glfwDefaultMappings[] = "03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Mac OS X,", "03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,", "03000000120c0000101e000000010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,", -#endif // GLFW_BUILD_COCOA_MAPPINGS +#endif // _GLFW_COCOA -#if defined(GLFW_BUILD_LINUX_MAPPINGS) +#if defined(GLFW_BUILD_LINUX_JOYSTICK) "03000000c82d00000090000011010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,", "05000000c82d00001038000000010000,8Bitdo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,", "05000000c82d00005106000000010000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Linux,", @@ -996,6 +996,6 @@ const char* _glfwDefaultMappings[] = "03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux,", "03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,", "03000000120c0000101e000011010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,", -#endif // GLFW_BUILD_LINUX_MAPPINGS +#endif // GLFW_BUILD_LINUX_JOYSTICK }; diff --git a/src/mappings.h.in b/src/mappings.h.in index f2604390..ed623680 100644 --- a/src/mappings.h.in +++ b/src/mappings.h.in @@ -60,7 +60,7 @@ const char* _glfwDefaultMappings[] = { -#if defined(GLFW_BUILD_WIN32_MAPPINGS) +#if defined(_GLFW_WIN32) @GLFW_WIN32_MAPPINGS@ "78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", @@ -69,14 +69,14 @@ const char* _glfwDefaultMappings[] = "78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", -#endif // GLFW_BUILD_WIN32_MAPPINGS +#endif // _GLFW_WIN32 -#if defined(GLFW_BUILD_COCOA_MAPPINGS) +#if defined(_GLFW_COCOA) @GLFW_COCOA_MAPPINGS@ -#endif // GLFW_BUILD_COCOA_MAPPINGS +#endif // _GLFW_COCOA -#if defined(GLFW_BUILD_LINUX_MAPPINGS) +#if defined(GLFW_BUILD_LINUX_JOYSTICK) @GLFW_LINUX_MAPPINGS@ -#endif // GLFW_BUILD_LINUX_MAPPINGS +#endif // GLFW_BUILD_LINUX_JOYSTICK }; diff --git a/src/nsgl_context.m b/src/nsgl_context.m index fc1f7521..878f32ed 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -28,6 +28,8 @@ #include "internal.h" +#if defined(_GLFW_COCOA) + #include #include @@ -374,3 +376,5 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) return window->context.nsgl.object; } +#endif // _GLFW_COCOA + diff --git a/src/platform.h b/src/platform.h index 0c593676..4e924a69 100644 --- a/src/platform.h +++ b/src/platform.h @@ -25,6 +25,18 @@ // //======================================================================== +#if defined(GLFW_BUILD_WIN32_TIMER) || \ + defined(GLFW_BUILD_WIN32_MODULE) || \ + defined(GLFW_BUILD_WIN32_THREAD) || \ + defined(GLFW_BUILD_COCOA_TIMER) || \ + defined(GLFW_BUILD_POSIX_TIMER) || \ + defined(GLFW_BUILD_POSIX_MODULE) || \ + defined(GLFW_BUILD_POSIX_THREAD) || \ + defined(GLFW_BUILD_POSIX_POLL) || \ + defined(GLFW_BUILD_LINUX_JOYSTICK) + #error "You must not define these; define zero or more _GLFW_ macros instead" +#endif + #include "null_platform.h" #if defined(_GLFW_WIN32) @@ -86,6 +98,10 @@ #endif #if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__) + #define GLFW_BUILD_LINUX_JOYSTICK +#endif + +#if defined(GLFW_BUILD_LINUX_JOYSTICK) #include "linux_joystick.h" #else #define GLFW_LINUX_JOYSTICK_STATE @@ -141,23 +157,47 @@ GLFW_GLX_LIBRARY_CONTEXT_STATE #if defined(_WIN32) + #define GLFW_BUILD_WIN32_THREAD +#else + #define GLFW_BUILD_POSIX_THREAD +#endif + +#if defined(GLFW_BUILD_WIN32_THREAD) #include "win32_thread.h" #define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE #define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE -#else +#elif defined(GLFW_BUILD_POSIX_THREAD) #include "posix_thread.h" #define GLFW_PLATFORM_TLS_STATE GLFW_POSIX_TLS_STATE #define GLFW_PLATFORM_MUTEX_STATE GLFW_POSIX_MUTEX_STATE #endif #if defined(_WIN32) + #define GLFW_BUILD_WIN32_TIMER +#elif defined(__APPLE__) + #define GLFW_BUILD_COCOA_TIMER +#else + #define GLFW_BUILD_POSIX_TIMER +#endif + +#if defined(GLFW_BUILD_WIN32_TIMER) #include "win32_time.h" #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE -#elif defined(__APPLE__) +#elif defined(GLFW_BUILD_COCOA_TIMER) #include "cocoa_time.h" #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE -#else +#elif defined(GLFW_BUILD_POSIX_TIMER) #include "posix_time.h" #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE #endif +#if defined(_WIN32) + #define GLFW_BUILD_WIN32_MODULE +#else + #define GLFW_BUILD_POSIX_MODULE +#endif + +#if defined(_GLFW_WAYLAND) || defined(_GLFW_X11) + #define GLFW_BUILD_POSIX_POLL +#endif + diff --git a/src/posix_module.c b/src/posix_module.c index 7079e5b4..ba5024a3 100644 --- a/src/posix_module.c +++ b/src/posix_module.c @@ -28,6 +28,8 @@ #include "internal.h" +#if defined(GLFW_BUILD_POSIX_MODULE) + #include ////////////////////////////////////////////////////////////////////////// @@ -49,3 +51,5 @@ GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) return dlsym(module, name); } +#endif // GLFW_BUILD_POSIX_MODULE + diff --git a/src/posix_poll.c b/src/posix_poll.c index 676a8a51..a5016a13 100644 --- a/src/posix_poll.c +++ b/src/posix_poll.c @@ -30,6 +30,8 @@ #include "internal.h" +#if defined(GLFW_BUILD_POSIX_POLL) + #include #include #include @@ -79,3 +81,5 @@ GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout) } } +#endif // GLFW_BUILD_POSIX_POLL + diff --git a/src/posix_thread.c b/src/posix_thread.c index 02361457..4ce55526 100644 --- a/src/posix_thread.c +++ b/src/posix_thread.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(GLFW_BUILD_POSIX_THREAD) + #include #include @@ -103,3 +105,5 @@ void _glfwPlatformUnlockMutex(_GLFWmutex* mutex) pthread_mutex_unlock(&mutex->posix.handle); } +#endif // GLFW_BUILD_POSIX_THREAD + diff --git a/src/posix_time.c b/src/posix_time.c index f134be47..caed678e 100644 --- a/src/posix_time.c +++ b/src/posix_time.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(GLFW_BUILD_POSIX_TIMER) + #include #include @@ -61,3 +63,5 @@ uint64_t _glfwPlatformGetTimerFrequency(void) return _glfw.timer.posix.frequency; } +#endif // GLFW_BUILD_POSIX_TIMER + diff --git a/src/wgl_context.c b/src/wgl_context.c index 4a5e77a8..cfe24b27 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_WIN32) + #include #include @@ -776,3 +778,5 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) return window->context.wgl.handle; } +#endif // _GLFW_WIN32 + diff --git a/src/win32_init.c b/src/win32_init.c index 8704150c..64393e77 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_WIN32) + #include static const GUID _glfw_GUID_DEVINTERFACE_HID = @@ -725,3 +727,5 @@ void _glfwTerminateWin32(void) freeLibraries(); } +#endif // _GLFW_WIN32 + diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 3a28943b..4e83577a 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_WIN32) + #include #include @@ -756,3 +758,5 @@ void _glfwUpdateGamepadGUIDWin32(char* guid) } } +#endif // _GLFW_WIN32 + diff --git a/src/win32_joystick.h b/src/win32_joystick.h index d7c2bb6f..9ab6438b 100644 --- a/src/win32_joystick.h +++ b/src/win32_joystick.h @@ -27,8 +27,6 @@ #define GLFW_WIN32_JOYSTICK_STATE _GLFWjoystickWin32 win32; #define GLFW_WIN32_LIBRARY_JOYSTICK_STATE -#define GLFW_BUILD_WIN32_MAPPINGS - // Joystick element (axis, button or slider) // typedef struct _GLFWjoyobjectWin32 diff --git a/src/win32_module.c b/src/win32_module.c index 35bdd71d..9c2b6d24 100644 --- a/src/win32_module.c +++ b/src/win32_module.c @@ -28,6 +28,8 @@ #include "internal.h" +#if defined(GLFW_BUILD_WIN32_MODULE) + ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// @@ -47,3 +49,5 @@ GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) return (GLFWproc) GetProcAddress((HMODULE) module, name); } +#endif // GLFW_BUILD_WIN32_MODULE + diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 57b44af3..2935ac28 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_WIN32) + #include #include #include @@ -545,3 +547,5 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle) return monitor->win32.publicDisplayName; } +#endif // _GLFW_WIN32 + diff --git a/src/win32_thread.c b/src/win32_thread.c index 35b8f99e..db997915 100644 --- a/src/win32_thread.c +++ b/src/win32_thread.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(GLFW_BUILD_WIN32_THREAD) + #include @@ -96,3 +98,5 @@ void _glfwPlatformUnlockMutex(_GLFWmutex* mutex) LeaveCriticalSection(&mutex->win32.section); } +#endif // GLFW_BUILD_WIN32_THREAD + diff --git a/src/win32_time.c b/src/win32_time.c index a1c64141..fcfe2005 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -29,6 +29,7 @@ #include "internal.h" +#if defined(GLFW_BUILD_WIN32_TIMER) ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// @@ -51,3 +52,5 @@ uint64_t _glfwPlatformGetTimerFrequency(void) return _glfw.timer.win32.frequency; } +#endif // GLFW_BUILD_WIN32_TIMER + diff --git a/src/win32_window.c b/src/win32_window.c index 69fb6422..e9be2b86 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_WIN32) + #include #include #include @@ -2510,3 +2512,5 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle) return window->win32.handle; } +#endif // _GLFW_WIN32 + diff --git a/src/wl_init.c b/src/wl_init.c index 8cbcc6e8..4e6b4294 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -28,6 +28,8 @@ #include "internal.h" +#if defined(_GLFW_WAYLAND) + #include #include #include @@ -392,7 +394,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform) _glfwGetKeyScancodeWayland, _glfwSetClipboardStringWayland, _glfwGetClipboardStringWayland, -#if defined(__linux__) +#if defined(_GLFW_LINUX_JOYSTICK) _glfwInitJoysticksLinux, _glfwTerminateJoysticksLinux, _glfwPollJoystickLinux, @@ -791,3 +793,5 @@ void _glfwTerminateWayland(void) _glfw_free(_glfw.wl.clipboardString); } +#endif // _GLFW_WAYLAND + diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 336681fd..3d4fcbb8 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -28,6 +28,8 @@ #include "internal.h" +#if defined(_GLFW_WAYLAND) + #include #include #include @@ -270,3 +272,5 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) return monitor->wl.output; } +#endif // _GLFW_WAYLAND + diff --git a/src/wl_window.c b/src/wl_window.c index 76d5f15b..c4d097b7 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -30,6 +30,8 @@ #include "internal.h" +#if defined(_GLFW_WAYLAND) + #include #include #include @@ -2887,3 +2889,5 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle) return window->wl.surface; } +#endif // _GLFW_WAYLAND + diff --git a/src/x11_init.c b/src/x11_init.c index 11aeb9e5..1c69c0f6 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_X11) + #include #include #include @@ -1182,7 +1184,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform) _glfwGetKeyScancodeX11, _glfwSetClipboardStringX11, _glfwGetClipboardStringX11, -#if defined(__linux__) +#if defined(_GLFW_LINUX_JOYSTICK) _glfwInitJoysticksLinux, _glfwTerminateJoysticksLinux, _glfwPollJoystickLinux, @@ -1652,3 +1654,5 @@ void _glfwTerminateX11(void) } } +#endif // _GLFW_X11 + diff --git a/src/x11_monitor.c b/src/x11_monitor.c index b031c83c..3183630b 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_X11) + #include #include #include @@ -614,3 +616,5 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle) return monitor->x11.output; } +#endif // _GLFW_X11 + diff --git a/src/x11_window.c b/src/x11_window.c index 8a689ed1..2c46bfff 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -29,6 +29,8 @@ #include "internal.h" +#if defined(_GLFW_X11) + #include #include @@ -86,7 +88,7 @@ static GLFWbool waitForAnyEvent(double* timeout) { _glfw.x11.emptyEventPipe[0], POLLIN } }; -#if defined(__linux__) +#if defined(_GLFW_LINUX_JOYSTICK) if (_glfw.joysticksInitialized) fds[count++] = (struct pollfd) { _glfw.linjs.inotify, POLLIN }; #endif @@ -2781,7 +2783,7 @@ void _glfwPollEventsX11(void) { drainEmptyEvents(); -#if defined(__linux__) +#if defined(_GLFW_LINUX_JOYSTICK) if (_glfw.joysticksInitialized) _glfwDetectJoystickConnectionLinux(); #endif @@ -3349,3 +3351,5 @@ GLFWAPI const char* glfwGetX11SelectionString(void) return getSelectionString(_glfw.x11.PRIMARY); } +#endif // _GLFW_X11 + diff --git a/src/xkb_unicode.c b/src/xkb_unicode.c index 1b2482cd..a516af00 100644 --- a/src/xkb_unicode.c +++ b/src/xkb_unicode.c @@ -29,6 +29,7 @@ #include "internal.h" +#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND) /* * Marcus: This code was originally written by Markus G. Kuhn. @@ -940,3 +941,5 @@ uint32_t _glfwKeySym2Unicode(unsigned int keysym) return GLFW_INVALID_CODEPOINT; } +#endif // _GLFW_WAYLAND or _GLFW_X11 +