Skip to content

Commit

Permalink
Only check if the input devices have changed once per second, instead…
Browse files Browse the repository at this point in the history
… of every single frame.
  • Loading branch information
xwidghet committed Jun 23, 2017
1 parent d51c33f commit 01b930f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/GameLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,21 @@ void GameLoop::RunGameLoop()
* acting on song beat from last frame */
HandleInputEvents( fDeltaTime );

if( INPUTMAN->DevicesChanged() )
static float deviceCheckWait = 0.f;
deviceCheckWait += fDeltaTime;

if( deviceCheckWait >= 1.0f )
{
INPUTFILTER->Reset(); // fix "buttons stuck" if button held while unplugged
INPUTMAN->LoadDrivers();
RString sMessage;
if( INPUTMAPPER->CheckForChangedInputDevicesAndRemap(sMessage) )
SCREENMAN->SystemMessage( sMessage );
deviceCheckWait = 0.f;

if ( INPUTMAN->DevicesChanged() )
{
INPUTFILTER->Reset(); // fix "buttons stuck" if button held while unplugged
INPUTMAN->LoadDrivers();
RString sMessage;
if (INPUTMAPPER->CheckForChangedInputDevicesAndRemap(sMessage))
SCREENMAN->SystemMessage(sMessage);
}
}

// Render
Expand Down

0 comments on commit 01b930f

Please sign in to comment.