Make joystick platform code init on demand

This makes joystick support initialize the first time a joystick
function is called, including those gamepad functions that are layered
on top of joystick functions.

Related to #1284.
Related to #1646.
This commit is contained in:
Camilla Löwy
2020-07-12 18:31:29 +02:00
parent f760b124ca
commit 782e6b6cef
19 changed files with 101 additions and 49 deletions
+4 -2
View File
@@ -493,7 +493,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
// Initialize joystick interface
//
void _glfwInitJoysticksWin32(void)
GLFWbool _glfwPlatformInitJoysticks(void)
{
if (_glfw.win32.dinput8.instance)
{
@@ -505,15 +505,17 @@ void _glfwInitJoysticksWin32(void)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to create interface");
return GLFW_FALSE;
}
}
_glfwDetectJoystickConnectionWin32();
return GLFW_TRUE;
}
// Close all opened joystick handles
//
void _glfwTerminateJoysticksWin32(void)
void _glfwPlatformTerminateJoysticks(void)
{
int jid;