Moving functions to their respective sections.  Related to delayed
joystick Initialization.
This commit is contained in:
Camilla Löwy
2020-07-21 17:46:48 +02:00
parent 782e6b6cef
commit f771d41292
3 changed files with 75 additions and 91 deletions
+31 -35
View File
@@ -491,41 +491,6 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Initialize joystick interface
//
GLFWbool _glfwPlatformInitJoysticks(void)
{
if (_glfw.win32.dinput8.instance)
{
if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
&IID_IDirectInput8W,
(void**) &_glfw.win32.dinput8.api,
NULL)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to create interface");
return GLFW_FALSE;
}
}
_glfwDetectJoystickConnectionWin32();
return GLFW_TRUE;
}
// Close all opened joystick handles
//
void _glfwPlatformTerminateJoysticks(void)
{
int jid;
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
closeJoystick(_glfw.joysticks + jid);
if (_glfw.win32.dinput8.api)
IDirectInput8_Release(_glfw.win32.dinput8.api);
}
// Checks for new joysticks after DBT_DEVICEARRIVAL
//
void _glfwDetectJoystickConnectionWin32(void)
@@ -605,6 +570,37 @@ void _glfwDetectJoystickDisconnectionWin32(void)
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwPlatformInitJoysticks(void)
{
if (_glfw.win32.dinput8.instance)
{
if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
&IID_IDirectInput8W,
(void**) &_glfw.win32.dinput8.api,
NULL)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to create interface");
return GLFW_FALSE;
}
}
_glfwDetectJoystickConnectionWin32();
return GLFW_TRUE;
}
void _glfwPlatformTerminateJoysticks(void)
{
int jid;
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
closeJoystick(_glfw.joysticks + jid);
if (_glfw.win32.dinput8.api)
IDirectInput8_Release(_glfw.win32.dinput8.api);
}
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
{
if (js->win32.device)