From 118f37dcb0758dd908cbf8562863d0960311a6a1 Mon Sep 17 00:00:00 2001 From: Peter Bech Date: Mon, 3 Jan 2022 19:06:19 +0100 Subject: [PATCH] =?UTF-8?q?=C2=83register=20gamepads=20before=20first=20en?= =?UTF-8?q?d=20drawing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rcore.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rcore.c b/src/rcore.c index 7752a7cc8..7d8470541 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -4507,6 +4507,16 @@ static bool InitGraphicsDevice(int width, int height) rlLoadExtensions(eglGetProcAddress); #endif +#if defined(PLATFORM_DESKTOP) + // Check if gamepads are ready + // NOTE: We register gamepads here to make sure that ready state of the gamepads represents the glfw state before the first call to EndDrawing() + for (int i = 0; i < MAX_GAMEPADS; i++) + { + if (glfwJoystickPresent(i)) CORE.Input.Gamepad.ready[i] = true; + else CORE.Input.Gamepad.ready[i] = false; + } +#endif + // Initialize OpenGL context (states and resources) // NOTE: CORE.Window.currentFbo.width and CORE.Window.currentFbo.height not used, just stored as globals in rlgl rlglInit(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height);