Don't poll and acquire the same device in both the input thread and Update.

This commit is contained in:
Glenn Maynard
2005-12-28 19:02:50 +00:00
parent 906179d035
commit 445df4ea85
2 changed files with 11 additions and 5 deletions
@@ -426,10 +426,13 @@ void InputHandler_DInput::UpdateBuffered(DIDevice &device, const RageTimer &tm)
}
void InputHandler_DInput::PollAndAcquireDevices()
void InputHandler_DInput::PollAndAcquireDevices( bool bBuffered )
{
for( unsigned i = 0; i < Devices.size(); ++i )
{
if( Devices[i].buffered != bBuffered )
continue;
HRESULT hr = IDirectInputDevice2_Poll( Devices[i].Device );
if ( hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED )
{
@@ -449,8 +452,11 @@ void InputHandler_DInput::Update()
RageTimer zero;
zero.SetZero();
/* Handle polled devices. */
PollAndAcquireDevices();
/* Handle polled devices. Handle buffered, too, if there's no input thread to do it. */
PollAndAcquireDevices( false );
if( !m_Thread.IsCreated() )
PollAndAcquireDevices( true );
for( unsigned i = 0; i < Devices.size(); ++i )
{
if( !Devices[i].buffered )
@@ -504,7 +510,7 @@ void InputHandler_DInput::InputThreadMain()
if( BufferedDevices.size() )
{
/* Update buffered devices. */
PollAndAcquireDevices();
PollAndAcquireDevices( true );
int ret = WaitForSingleObjectEx( Handle, 50, true );
if( ret == -1 )
@@ -22,7 +22,7 @@ private:
void UpdatePolled( DIDevice &device, const RageTimer &tm );
void UpdateBuffered( DIDevice &device, const RageTimer &tm );
void PollAndAcquireDevices();
void PollAndAcquireDevices( bool bBuffered );
static int InputThread_Start( void *p ) { ((InputHandler_DInput *) p)->InputThreadMain(); return 0; }
void InputThreadMain();