From 3de8b6345796d527bc59d69df0fa4897f62e0dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 19 Dec 2014 22:37:31 -0800 Subject: [PATCH] Fixed crash when xinput is not present. --- examples/common/entry/entry_windows.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index c70127db3..66189681d 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -79,12 +79,21 @@ namespace entry { XInputGetState = (PFN_XINPUT_GET_STATE)bx::dlsym(m_xinputdll, "XInputGetState"); // XInputEnable = (PFN_XINPUT_ENABLE )bx::dlsym(m_xinputdll, "XInputEnable" ); + + if (NULL == XInputGetState) + { + shutdown(); + } } } void shutdown() { - bx::dlclose(m_xinputdll); + if (NULL != m_xinputdll) + { + bx::dlclose(m_xinputdll); + m_xinputdll = NULL; + } } bool filter(GamepadAxis::Enum _axis, int32_t _old, int32_t* _value) @@ -98,6 +107,11 @@ namespace entry void update(EventQueue& _eventQueue) { + if (NULL == m_xinputdll) + { + return; + } + WindowHandle defaultWindow = { 0 }; GamepadHandle handle = { 0 };