Don't poll and acquire the same device in both the input thread and Update.
This commit is contained in:
@@ -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 )
|
for( unsigned i = 0; i < Devices.size(); ++i )
|
||||||
{
|
{
|
||||||
|
if( Devices[i].buffered != bBuffered )
|
||||||
|
continue;
|
||||||
|
|
||||||
HRESULT hr = IDirectInputDevice2_Poll( Devices[i].Device );
|
HRESULT hr = IDirectInputDevice2_Poll( Devices[i].Device );
|
||||||
if ( hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED )
|
if ( hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED )
|
||||||
{
|
{
|
||||||
@@ -449,8 +452,11 @@ void InputHandler_DInput::Update()
|
|||||||
RageTimer zero;
|
RageTimer zero;
|
||||||
zero.SetZero();
|
zero.SetZero();
|
||||||
|
|
||||||
/* Handle polled devices. */
|
/* Handle polled devices. Handle buffered, too, if there's no input thread to do it. */
|
||||||
PollAndAcquireDevices();
|
PollAndAcquireDevices( false );
|
||||||
|
if( !m_Thread.IsCreated() )
|
||||||
|
PollAndAcquireDevices( true );
|
||||||
|
|
||||||
for( unsigned i = 0; i < Devices.size(); ++i )
|
for( unsigned i = 0; i < Devices.size(); ++i )
|
||||||
{
|
{
|
||||||
if( !Devices[i].buffered )
|
if( !Devices[i].buffered )
|
||||||
@@ -504,7 +510,7 @@ void InputHandler_DInput::InputThreadMain()
|
|||||||
if( BufferedDevices.size() )
|
if( BufferedDevices.size() )
|
||||||
{
|
{
|
||||||
/* Update buffered devices. */
|
/* Update buffered devices. */
|
||||||
PollAndAcquireDevices();
|
PollAndAcquireDevices( true );
|
||||||
|
|
||||||
int ret = WaitForSingleObjectEx( Handle, 50, true );
|
int ret = WaitForSingleObjectEx( Handle, 50, true );
|
||||||
if( ret == -1 )
|
if( ret == -1 )
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ private:
|
|||||||
|
|
||||||
void UpdatePolled( DIDevice &device, const RageTimer &tm );
|
void UpdatePolled( DIDevice &device, const RageTimer &tm );
|
||||||
void UpdateBuffered( 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; }
|
static int InputThread_Start( void *p ) { ((InputHandler_DInput *) p)->InputThreadMain(); return 0; }
|
||||||
void InputThreadMain();
|
void InputThreadMain();
|
||||||
|
|||||||
Reference in New Issue
Block a user