From 0f5c7f2b319e935899994cd59a6d71122579087c Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 1 Apr 2013 21:16:23 +0300 Subject: [PATCH] fix XInput issue introduced in d82b09b087 --- Windows/DinputDevice.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Windows/DinputDevice.cpp b/Windows/DinputDevice.cpp index 383740f9f..aeea0a0bf 100644 --- a/Windows/DinputDevice.cpp +++ b/Windows/DinputDevice.cpp @@ -19,6 +19,7 @@ #include "DinputDevice.h" #include "input/input_state.h" #include "Core/Reporting.h" +#include "Xinput.h" #pragma comment(lib,"dxguid.lib") #pragma comment(lib,"dinput8.lib") @@ -33,6 +34,26 @@ static const unsigned int dinput_ctrl_map[] = { 3, PAD_BUTTON_Y, }; +struct XINPUT_DEVICE_NODE +{ + DWORD dwVidPid; + XINPUT_DEVICE_NODE* pNext; +}; +XINPUT_DEVICE_NODE* g_pXInputDeviceList = NULL; + +bool IsXInputDevice( const GUID* pGuidProductFromDirectInput ) +{ + XINPUT_DEVICE_NODE* pNode = g_pXInputDeviceList; + while( pNode ) + { + if( pNode->dwVidPid == pGuidProductFromDirectInput->Data1 ) + return true; + pNode = pNode->pNext; + } + + return false; +} + DinputDevice::DinputDevice() { pJoystick = NULL; @@ -55,6 +76,17 @@ DinputDevice::DinputDevice() return; } + // ignore if device suppert XInput + DIDEVICEINSTANCE dinfo = {0}; + pJoystick->GetDeviceInfo(&dinfo); + if (IsXInputDevice(&dinfo.guidProduct)) + { + pDI->Release(); + pDI = NULL; + pJoystick->Release(); + pJoystick = NULL; + } + DIPROPRANGE diprg; diprg.diph.dwSize = sizeof(DIPROPRANGE); diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);