From ebda16beae2ca1c0d90e8cf5a16a93412285ec61 Mon Sep 17 00:00:00 2001 From: bicarus <202771338+bicarus-dev@users.noreply.github.com> Date: Sun, 10 May 2026 19:47:33 -0700 Subject: [PATCH] rb: update reflec beat to use new timer (#692) ## Link to GitHub Issue or related Pull Request, if one exists Continuation of #682 ## Description of change RB uses SleepEx, so it was missed during the search while working on #682. ## Testing Plays about the same on a 200Hz touch monitor. --- src/spice2x/games/rb/rb.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/spice2x/games/rb/rb.cpp b/src/spice2x/games/rb/rb.cpp index 1b2c7f9..35fdee1 100644 --- a/src/spice2x/games/rb/rb.cpp +++ b/src/spice2x/games/rb/rb.cpp @@ -4,6 +4,8 @@ #include "hooks/devicehook.h" #include "hooks/audio/backends/dsound/dsound_backend.h" #include "util/detour.h" +#include "util/precise_timer.h" +#include "util/logging.h" #include "touch.h" @@ -11,20 +13,18 @@ static decltype(SleepEx) *SleepEx_orig; static DWORD WINAPI SleepEx_hook(DWORD dwMilliseconds, BOOL bAltertable) { - /* - * Increase touch poll from ~110 FPS to ~500 FPS - */ + // increase touch poll from ~110 FPS to ~500 FPS (Sleep) or ~1000 FPS (Win10 high-res timer) if (dwMilliseconds == 8) { - static bool initialized = false; - if (!initialized) { - initialized = true; - - // if we only sleep for 1ms we also don't need the high priority RB sets - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); - } dwMilliseconds = 1; } + // most calls from rb are actually non-alertable + if (!bAltertable) { + static thread_local timeutils::PreciseSleepTimer timer; + timer.sleep(dwMilliseconds); + return 0; + } + // call original return SleepEx_orig(dwMilliseconds, bAltertable); }