Merge pull request #1152 from CrazyMax/win-input

fix XInput issue introduced in d82b09b087
This commit is contained in:
Henrik Rydgård 2013-04-01 11:23:25 -07:00
commit f25735aa93

View File

@ -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);