diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0b659e83..6b89662a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -209,6 +209,7 @@ video tutorials. - Richard A. Wilkes - Tatsuya Yatagawa - Ryogo Yoshimura + - Rácz Zalán - Lukas Zanner - Andrey Zholos - Aihui Zhu diff --git a/README.md b/README.md index 635ffff2..19f91673 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ information on what to include when reporting a bug. ## Changelog + - Bugfix: Joysticks connected before init did not get gamepad mappings (#1996) - [Cocoa] Bugfix: A dependency on an external constant caused crashes on macOS 11 and earlier (#1985,#1994) diff --git a/src/input.c b/src/input.c index 67919334..96930240 100644 --- a/src/input.c +++ b/src/input.c @@ -401,6 +401,7 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value) // void _glfwInitGamepadMappings(void) { + int jid; size_t i; const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*); _glfw.mappings = calloc(count, sizeof(_GLFWmapping)); @@ -410,6 +411,13 @@ void _glfwInitGamepadMappings(void) if (parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i])) _glfw.mappingCount++; } + + for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) + { + _GLFWjoystick* js = _glfw.joysticks + jid; + if (js->present) + js->mapping = findValidMapping(js); + } } // Returns an available joystick object with arrays and name allocated