summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGil Barbosa Reis <[email protected]>2021-02-07 16:49:37 -0300
committerGitHub <[email protected]>2021-02-07 20:49:37 +0100
commit9081defd46e2ca3da7629e2e4f15eedbf88c49df (patch)
tree05af656a7de623532a7af22b3ccf78de95b39bf4
parent090c790e50a0e3607197538882d35628329be297 (diff)
downloadraylib-9081defd46e2ca3da7629e2e4f15eedbf88c49df.tar.gz
raylib-9081defd46e2ca3da7629e2e4f15eedbf88c49df.zip
Fix initialize GLFW's Joystick subsystem before window is created on Desktop platforms (#1554) (#1572)
-rw-r--r--src/core.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core.c b/src/core.c
index 1696c41e..b21b27ca 100644
--- a/src/core.c
+++ b/src/core.c
@@ -3329,6 +3329,20 @@ static bool InitGraphicsDevice(int width, int height)
#endif
}
+#if defined(PLATFORM_DESKTOP)
+ // NOTE: GLFW 3.4+ defers initialization of the Joystick subsystem on the
+ // first call to any Joystick related functions. Forcing this
+ // initialization here avoids doing it on `PollInputEvents` called by
+ // `EndDrawing` after first frame has been just drawn. The initialization
+ // will still happen and possible delays still occur, but before the window
+ // is shown, which is a nicer experience.
+ // Ref: https://github.com/raysan5/raylib/issues/1554
+ if (MAX_GAMEPADS > 0)
+ {
+ glfwSetJoystickCallback(NULL);
+ }
+#endif // PLATFORM_DESKTOP
+
if (CORE.Window.fullscreen)
{
// remember center for switchinging from fullscreen to window