diff --git a/src/core/achievements.cpp b/src/core/achievements.cpp index 1ccadad2d..b8d75c51f 100644 --- a/src/core/achievements.cpp +++ b/src/core/achievements.cpp @@ -1969,6 +1969,15 @@ std::string Achievements::GetLoggedInUserBadgePath() return badge_path; } +u32 Achievements::GetPauseThrottleFrames() +{ + if (!IsActive() || !IsHardcoreModeActive() || IsUsingRAIntegration()) + return 0; + + u32 frames_remaining = 0; + return rc_client_can_pause(s_client, &frames_remaining) ? 0 : frames_remaining; +} + void Achievements::Logout() { if (IsActive()) diff --git a/src/core/achievements.h b/src/core/achievements.h index a572f5e60..7a2b5dc89 100644 --- a/src/core/achievements.h +++ b/src/core/achievements.h @@ -129,6 +129,9 @@ const char* GetLoggedInUserName(); /// Should be called with the lock held. std::string GetLoggedInUserBadgePath(); +/// Returns 0 if pausing is allowed, otherwise the number of frames until pausing is allowed. +u32 GetPauseThrottleFrames(); + /// Clears all cached state used to render the UI. void ClearUIState(); diff --git a/src/core/hotkeys.cpp b/src/core/hotkeys.cpp index 6fc333f4d..15b3bbaef 100644 --- a/src/core/hotkeys.cpp +++ b/src/core/hotkeys.cpp @@ -139,27 +139,16 @@ static void HotkeyToggleOSD() static bool CanPause() { - static constexpr const float PAUSE_INTERVAL = 3.0f; - static Common::Timer::Value s_last_pause_time = 0; - - if (!Achievements::IsHardcoreModeActive() || System::IsPaused()) + const u32 frames_until_pause_allowed = Achievements::GetPauseThrottleFrames(); + if (frames_until_pause_allowed == 0) return true; - const Common::Timer::Value time = Common::Timer::GetCurrentValue(); - const float delta = static_cast(Common::Timer::ConvertValueToSeconds(time - s_last_pause_time)); - if (delta < PAUSE_INTERVAL) - { - Host::AddIconOSDMessage("PauseCooldown", ICON_FA_CLOCK, - TRANSLATE_PLURAL_STR("Hotkeys", "You cannot pause until another %n second(s) have passed.", - "", static_cast(std::ceil(PAUSE_INTERVAL - delta))), - Host::OSD_QUICK_DURATION); - return false; - } - - Host::RemoveKeyedOSDMessage("PauseCooldown"); - s_last_pause_time = time; - - return true; + const float seconds = static_cast(frames_until_pause_allowed) / System::GetVideoFrameRate(); + Host::AddIconOSDMessage("PauseCooldown", ICON_FA_CLOCK, + TRANSLATE_PLURAL_STR("Hotkeys", "You cannot pause until another %n second(s) have passed.", + "", static_cast(std::ceil(seconds))), + std::max(seconds, Host::OSD_QUICK_DURATION)); + return false; } #endif