Fixed non-functional XInput support when built with modern Windows SDKs

https://mantis.zdoom.org/view.php?id=568
This commit is contained in:
alexey.lysiuk 2017-04-18 10:42:05 +03:00
parent 03b77c0505
commit b6774e723b
1 changed files with 5 additions and 3 deletions

View File

@ -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<IJoystickConfig *> &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)
{