From ea994d952a36295f7cbda36da11f05a816aabfea Mon Sep 17 00:00:00 2001 From: praydog Date: Thu, 2 Nov 2023 17:16:46 -0700 Subject: [PATCH] UI: Limit sidebar navigation speed for gamepads --- src/Framework.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Framework.hpp b/src/Framework.hpp index 44255305..155e9bdd 100644 --- a/src/Framework.hpp +++ b/src/Framework.hpp @@ -185,11 +185,25 @@ class Framework { } void increment_sidebar_page() { + const auto now = std::chrono::steady_clock::now(); + const auto delta = now - m_last_page_inc_time; + if (delta < std::chrono::milliseconds(100)) { + return; + } ++m_sidebar_state.selected_entry; + + m_last_page_inc_time = now; } void decrement_sidebar_page() { + const auto now = std::chrono::steady_clock::now(); + const auto delta = now - m_last_page_dec_time; + if (delta < std::chrono::milliseconds(100)) { + return; + } --m_sidebar_state.selected_entry; + + m_last_page_dec_time = now; } private: @@ -284,6 +298,8 @@ class Framework { std::chrono::steady_clock::time_point m_last_message_time{}; std::chrono::steady_clock::time_point m_last_sendmessage_time{}; std::chrono::steady_clock::time_point m_last_chance_time{}; + std::chrono::steady_clock::time_point m_last_page_dec_time{}; + std::chrono::steady_clock::time_point m_last_page_inc_time{}; uint32_t m_frames_since_init{0}; bool m_has_last_chance{true}; bool m_first_initialize{true};