From 1b96bef8e1ee40fdaff7636b9b17b3e71c683dc7 Mon Sep 17 00:00:00 2001 From: luisr142004 Date: Tue, 6 Apr 2010 22:43:12 +0000 Subject: [PATCH] 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 --- .../DirectInput/DirectInputJoystick.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/Plugins/Plugin_GCPadNew/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp b/Source/Plugins/Plugin_GCPadNew/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp index f83c5b3f3a..3e129132ba 100644 --- a/Source/Plugins/Plugin_GCPadNew/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp +++ b/Source/Plugins/Plugin_GCPadNew/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp @@ -217,7 +217,7 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI js_caps.dwButtons = std::min((DWORD)32, js_caps.dwButtons); 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 for ( unsigned int i = 0; i < js_caps.dwButtons; ++i ) @@ -377,13 +377,20 @@ std::string Joystick::GetSource() const // update IO + bool Joystick::UpdateInput() { if ( m_must_poll ) - if ( DI_OK != m_device->Poll() ) - return false; + m_device->Poll(); + //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()