fixed gcpad new to work with certain devices that need reaquiring of the device when inputlost is returned, billiard gave me the code :P

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5287 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004 2010-04-06 22:43:12 +00:00
parent c26a34d4a5
commit 1b96bef8e1
1 changed files with 11 additions and 4 deletions

View File

@ -217,7 +217,7 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
js_caps.dwButtons = std::min((DWORD)32, js_caps.dwButtons); js_caps.dwButtons = std::min((DWORD)32, js_caps.dwButtons);
js_caps.dwPOVs = std::min((DWORD)4, js_caps.dwPOVs); js_caps.dwPOVs = std::min((DWORD)4, js_caps.dwPOVs);
m_must_poll = ( ( js_caps.dwFlags & DIDC_POLLEDDATAFORMAT ) > 0 ); m_must_poll = (bool)( js_caps.dwFlags & DIDC_POLLEDDATAFORMAT );
// buttons // buttons
for ( unsigned int i = 0; i < js_caps.dwButtons; ++i ) for ( unsigned int i = 0; i < js_caps.dwButtons; ++i )
@ -377,13 +377,20 @@ std::string Joystick::GetSource() const
// update IO // update IO
bool Joystick::UpdateInput() bool Joystick::UpdateInput()
{ {
if ( m_must_poll ) if ( m_must_poll )
if ( DI_OK != m_device->Poll() ) m_device->Poll();
return false; //return false;
return ( DI_OK == m_device->GetDeviceState( sizeof(m_state_in), &m_state_in ) ); HRESULT hr = m_device->GetDeviceState( sizeof(m_state_in), &m_state_in );
// try reacquire if input lost
while ( DIERR_INPUTLOST == hr )
hr = m_device->Acquire();
return ( DI_OK == hr );
} }
bool Joystick::UpdateOutput() bool Joystick::UpdateOutput()