From 11f2837893b5a79f8f5dff615b395ca02bb81496 Mon Sep 17 00:00:00 2001 From: BernardoGiordano Date: Fri, 5 Jul 2019 21:59:00 +0200 Subject: [PATCH] Fix #193 --- common/ihid.cpp | 16 ++++++++++++++++ common/ihid.hpp | 2 ++ switch/source/MainScreen.cpp | 12 ++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/common/ihid.cpp b/common/ihid.cpp index 401d326..12a07c6 100644 --- a/common/ihid.cpp +++ b/common/ihid.cpp @@ -85,4 +85,20 @@ void IHid::page_forward(void) else if (mPage == (int)mMaxPages - 1) { mPage = 0; } +} + +void IHid::pageBack(size_t count) +{ + page_back(); + if (mIndex > maxEntries(count)) { + mIndex = maxEntries(count); + } +} + +void IHid::pageForward(size_t count) +{ + page_forward(); + if (mIndex > maxEntries(count)) { + mIndex = maxEntries(count); + } } \ No newline at end of file diff --git a/common/ihid.hpp b/common/ihid.hpp index 2315c4e..0968995 100644 --- a/common/ihid.hpp +++ b/common/ihid.hpp @@ -54,6 +54,8 @@ public: int page(void) const; void page(int v); void reset(void); + void pageBack(size_t count); + void pageForward(size_t count); protected: void page_back(void); diff --git a/switch/source/MainScreen.cpp b/switch/source/MainScreen.cpp index 96d9977..f162e9b 100644 --- a/switch/source/MainScreen.cpp +++ b/switch/source/MainScreen.cpp @@ -201,14 +201,22 @@ void MainScreen::update(touchPosition* touch) void MainScreen::updateSelector(touchPosition* touch) { if (!g_backupScrollEnabled) { + size_t count = getTitleCount(g_currentUId); size_t oldindex = hid.index(); - hid.update(getTitleCount(g_currentUId)); + hid.update(count); + // change page + if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_L) { + hid.pageBack(count); + } + else if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_R) { + hid.pageForward(count); + } // loop through every rendered title for (u8 row = 0; row < rowlen; row++) { for (u8 col = 0; col < collen; col++) { u8 index = row * collen + col; - if (index > hid.maxEntries(getTitleCount(g_currentUId))) + if (index > hid.maxEntries(count)) break; u32 x = selectorX(index);