Simplify the input device check
Reduce the input device check from every 500 frames to every 255 frames by way of replacing the modulo 500 with a wrapping uint8_t. A bit faster reaction during device plug-in is nice, and using a simple pre-increment instead of doing a modulo is a little more efficient.
This commit is contained in:
+3
-6
@@ -306,8 +306,6 @@ 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() )
|
||||||
@@ -328,13 +326,12 @@ void GameLoop::RunGameLoop()
|
|||||||
|
|
||||||
UpdateAllButDraw(false);
|
UpdateAllButDraw(false);
|
||||||
|
|
||||||
// This loop runs every frame, so the input devices will be checked every 500 frames.
|
// Check input devices every 255 frames (uint8_t can hold 0-255).
|
||||||
if (CheckInputDevicesCounter % (500) == 0)
|
static uint8_t i_CheckInputDevices = 0;
|
||||||
|
if (++i_CheckInputDevices == 0)
|
||||||
{
|
{
|
||||||
CheckInputDevices();
|
CheckInputDevices();
|
||||||
CheckInputDevicesCounter = 0;
|
|
||||||
}
|
}
|
||||||
CheckInputDevicesCounter++;
|
|
||||||
|
|
||||||
SCREENMAN->Draw();
|
SCREENMAN->Draw();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user