From b6774e723bd570ef8be2d2f820e5b05bc0dec01a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 18 Apr 2017 10:42:05 +0300 Subject: [PATCH] Fixed non-functional XInput support when built with modern Windows SDKs https://mantis.zdoom.org/view.php?id=568 --- src/win32/i_xinput.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/win32/i_xinput.cpp b/src/win32/i_xinput.cpp index c6cd535a71..8b967746fb 100644 --- a/src/win32/i_xinput.cpp +++ b/src/win32/i_xinput.cpp @@ -671,8 +671,10 @@ FXInputManager::FXInputManager() InputSetState = (XInputSetStateType)GetProcAddress(XInputDLL, "XInputSetState"); InputGetCapabilities = (XInputGetCapabilitiesType)GetProcAddress(XInputDLL, "XInputGetCapabilities"); InputEnable = (XInputEnableType)GetProcAddress(XInputDLL, "XInputEnable"); - if (InputGetState == NULL || InputSetState == NULL || InputGetCapabilities == NULL || - InputEnable == NULL) + // Treat XInputEnable() function as optional + // It is not available in xinput9_1_0.dll which is XINPUT_DLL in modern SDKs + // See https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx + if (InputGetState == NULL || InputSetState == NULL || InputGetCapabilities == NULL) { FreeLibrary(XInputDLL); XInputDLL = NULL; @@ -781,7 +783,7 @@ void FXInputManager::GetDevices(TArray &sticks) bool FXInputManager::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result) { - if (message == WM_ACTIVATE) + if (nullptr != InputEnable && message == WM_ACTIVATE) { if (LOWORD(wParam) == WA_INACTIVE) {