Skip to content

Commit

Permalink
UI: Limit sidebar navigation speed for gamepads
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Nov 3, 2023
1 parent 7972fdf commit ea994d9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Framework.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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};
Expand Down

0 comments on commit ea994d9

Please sign in to comment.