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

View file

@ -671,8 +671,10 @@ FXInputManager::FXInputManager()
InputSetState = (XInputSetStateType)GetProcAddress(XInputDLL, "XInputSetState"); InputSetState = (XInputSetStateType)GetProcAddress(XInputDLL, "XInputSetState");
InputGetCapabilities = (XInputGetCapabilitiesType)GetProcAddress(XInputDLL, "XInputGetCapabilities"); InputGetCapabilities = (XInputGetCapabilitiesType)GetProcAddress(XInputDLL, "XInputGetCapabilities");
InputEnable = (XInputEnableType)GetProcAddress(XInputDLL, "XInputEnable"); InputEnable = (XInputEnableType)GetProcAddress(XInputDLL, "XInputEnable");
if (InputGetState == NULL || InputSetState == NULL || InputGetCapabilities == NULL || // Treat XInputEnable() function as optional
InputEnable == NULL) // 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); FreeLibrary(XInputDLL);
XInputDLL = NULL; 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) 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) if (LOWORD(wParam) == WA_INACTIVE)
{ {