Encapsulate input device check to run it less often
This commit is contained in:
+19
-6
@@ -87,6 +87,18 @@ static void CheckFocus()
|
|||||||
INPUTFILTER->Reset();
|
INPUTFILTER->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CheckInputDevices()
|
||||||
|
{
|
||||||
|
if (INPUTMAN->DevicesChanged())
|
||||||
|
{
|
||||||
|
INPUTFILTER->Reset(); // fix "buttons stuck" if button held while unplugged
|
||||||
|
INPUTMAN->LoadDrivers();
|
||||||
|
RString sMessage;
|
||||||
|
if (INPUTMAPPER->CheckForChangedInputDevicesAndRemap(sMessage))
|
||||||
|
SCREENMAN->SystemMessage(sMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// On the next update, change themes, and load sNewScreen.
|
// On the next update, change themes, and load sNewScreen.
|
||||||
static RString g_NewTheme;
|
static RString g_NewTheme;
|
||||||
static RString g_NewGame;
|
static RString g_NewGame;
|
||||||
@@ -281,6 +293,8 @@ void GameLoop::UpdateAllButDraw(bool bRunningFromVBLANK)
|
|||||||
|
|
||||||
void GameLoop::RunGameLoop()
|
void GameLoop::RunGameLoop()
|
||||||
{
|
{
|
||||||
|
static int CheckInputDevicesCounter = 0;
|
||||||
|
|
||||||
/* People may want to do something else while songs are loading, so do
|
/* People may want to do something else while songs are loading, so do
|
||||||
* this after loading songs. */
|
* this after loading songs. */
|
||||||
if( ChangeAppPri() )
|
if( ChangeAppPri() )
|
||||||
@@ -301,14 +315,13 @@ void GameLoop::RunGameLoop()
|
|||||||
|
|
||||||
UpdateAllButDraw(false);
|
UpdateAllButDraw(false);
|
||||||
|
|
||||||
if( INPUTMAN->DevicesChanged() )
|
// This loop runs every frame, so the input devices will be checked every 500 frames.
|
||||||
|
if (CheckInputDevicesCounter % (500) == 0)
|
||||||
{
|
{
|
||||||
INPUTFILTER->Reset(); // fix "buttons stuck" once per frame if button held while unplugged
|
CheckInputDevices();
|
||||||
INPUTMAN->LoadDrivers();
|
CheckInputDevicesCounter = 0;
|
||||||
RString sMessage;
|
|
||||||
if( INPUTMAPPER->CheckForChangedInputDevicesAndRemap(sMessage) )
|
|
||||||
SCREENMAN->SystemMessage( sMessage );
|
|
||||||
}
|
}
|
||||||
|
CheckInputDevicesCounter++;
|
||||||
|
|
||||||
SCREENMAN->Draw();
|
SCREENMAN->Draw();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user