Browse Source

Fix controller not available right after win init (#5358)

- Fix IsGamepadAvailable() returns false for an available controller immediately after window initialization
pull/5362/head
Serhii Zasenko 2 weeks ago
committed by GitHub
parent
commit
be9a24e68c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      src/platforms/rcore_desktop_glfw.c

+ 6
- 1
src/platforms/rcore_desktop_glfw.c View File

@ -1749,7 +1749,12 @@ int InitPlatform(void)
{
// WARNING: If glfwGetJoystickName() is longer than MAX_GAMEPAD_NAME_LENGTH,
// we can get a not-NULL terminated string, so, we only copy up to (MAX_GAMEPAD_NAME_LENGTH - 1)
if (glfwJoystickPresent(i)) strncpy(CORE.Input.Gamepad.name[i], glfwGetJoystickName(i), MAX_GAMEPAD_NAME_LENGTH - 1);
if (glfwJoystickPresent(i))
{
CORE.Input.Gamepad.ready[i] = true;
CORE.Input.Gamepad.axisCount[i] = GLFW_GAMEPAD_AXIS_LAST + 1;
strncpy(CORE.Input.Gamepad.name[i], glfwGetJoystickName(i), MAX_GAMEPAD_NAME_LENGTH - 1);
}
}
//----------------------------------------------------------------------------

Loading…
Cancel
Save