From b698eb5f0c8f292796848f57bec1f31ccea1720c Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Fri, 6 Sep 2024 03:13:42 -0700 Subject: [PATCH] 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. --- src/GameLoop.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp index 6be83e243e..f4d3fd590b 100644 --- a/src/GameLoop.cpp +++ b/src/GameLoop.cpp @@ -306,8 +306,6 @@ void GameLoop::UpdateAllButDraw(bool bRunningFromVBLANK) void GameLoop::RunGameLoop() { - static int CheckInputDevicesCounter = 0; - /* People may want to do something else while songs are loading, so do * this after loading songs. */ if( ChangeAppPri() ) @@ -328,13 +326,12 @@ void GameLoop::RunGameLoop() UpdateAllButDraw(false); - // This loop runs every frame, so the input devices will be checked every 500 frames. - if (CheckInputDevicesCounter % (500) == 0) + // Check input devices every 255 frames (uint8_t can hold 0-255). + static uint8_t i_CheckInputDevices = 0; + if (++i_CheckInputDevices == 0) { CheckInputDevices(); - CheckInputDevicesCounter = 0; } - CheckInputDevicesCounter++; SCREENMAN->Draw(); }