Permalink
Browse files

enable fast scrolling

  • Loading branch information...
BernardoGiordano committed May 14, 2018
1 parent bcf0fd8 commit 281f1a7b1b4f8b122a06a3f1ffc32f6622bab4ce
Showing with 39 additions and 13 deletions.
  1. +16 −4 switch/source/hbkbd.cpp
  2. +23 −9 switch/source/hid.cpp
@@ -47,7 +47,10 @@ void hbkbd::hid(size_t& currentEntry)
{
static const size_t columns = 11;
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_LEFT)
u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO);
bool sleep = false;
if (kHeld & KEY_LEFT)
{
switch (currentEntry)
{
@@ -72,8 +75,9 @@ void hbkbd::hid(size_t& currentEntry)
default:
currentEntry--;
}
sleep = true;
}
else if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_RIGHT)
else if (kHeld & KEY_RIGHT)
{
switch (currentEntry)
{
@@ -98,8 +102,9 @@ void hbkbd::hid(size_t& currentEntry)
default:
currentEntry++;
}
sleep = true;
}
else if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_UP)
else if (kHeld & KEY_UP)
{
switch (currentEntry)
{
@@ -121,8 +126,9 @@ void hbkbd::hid(size_t& currentEntry)
default:
currentEntry -= 11;
}
sleep = true;
}
else if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_DOWN)
else if (kHeld & KEY_DOWN)
{
switch (currentEntry)
{
@@ -145,6 +151,12 @@ void hbkbd::hid(size_t& currentEntry)
default:
currentEntry += 11;
}
sleep = true;
}
if (sleep)
{
svcSleepThread(1e8);
}
}
@@ -69,16 +69,20 @@ void hid::entryType(entryType_t v)
void hid::index(size_t& currentEntry, int& page, size_t maxpages, size_t maxentries, const size_t entries, const size_t columns) {
maxentries--;
u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO);
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
bool sleep = false;
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_ZL)
if (kDown & KEY_ZL)
{
page_back(page, maxpages);
if (currentEntry > refreshMaxEntries(page, entries))
{
currentEntry = refreshMaxEntries(page, entries);
}
}
else if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_ZR)
else if (kDown & KEY_ZR)
{
page_forward(page, maxpages);
if (currentEntry > refreshMaxEntries(page, entries))
@@ -88,7 +92,7 @@ void hid::index(size_t& currentEntry, int& page, size_t maxpages, size_t maxentr
}
else if (columns > 1)
{
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_LEFT)
if (kHeld & KEY_LEFT)
{
if (currentEntry > 0)
{
@@ -99,8 +103,9 @@ void hid::index(size_t& currentEntry, int& page, size_t maxpages, size_t maxentr
page_back(page, maxpages);
currentEntry = refreshMaxEntries(page, entries);
}
sleep = true;
}
else if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_RIGHT)
else if (kHeld & KEY_RIGHT)
{
if (currentEntry < maxentries)
{
@@ -111,8 +116,9 @@ void hid::index(size_t& currentEntry, int& page, size_t maxpages, size_t maxentr
page_forward(page, maxpages);
currentEntry = 0;
}
sleep = true;
}
else if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_UP)
else if (kHeld & KEY_UP)
{
if (currentEntry <= columns - 1)
{
@@ -126,8 +132,9 @@ void hid::index(size_t& currentEntry, int& page, size_t maxpages, size_t maxentr
{
currentEntry -= columns;
}
sleep = true;
}
else if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_DOWN)
else if (kHeld & KEY_DOWN)
{
if ((int)(maxentries - columns) >= 0)
{
@@ -143,12 +150,13 @@ void hid::index(size_t& currentEntry, int& page, size_t maxpages, size_t maxentr
currentEntry = refreshMaxEntries(page, entries);
}
}
sleep = true;
}
}
}
else
{
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_UP)
if (kHeld & KEY_UP)
{
if (currentEntry > 0)
{
@@ -159,9 +167,9 @@ void hid::index(size_t& currentEntry, int& page, size_t maxpages, size_t maxentr
page_back(page, maxpages);
currentEntry = refreshMaxEntries(page, entries);
}
sleep = true;
}
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_DOWN)
else if (kHeld & KEY_DOWN)
{
if (currentEntry < maxentries)
{
@@ -172,6 +180,12 @@ void hid::index(size_t& currentEntry, int& page, size_t maxpages, size_t maxentr
page_forward(page, maxpages);
currentEntry = 0;
}
sleep = true;
}
}
if (sleep)
{
svcSleepThread(1e8);
}
}

0 comments on commit 281f1a7

Please sign in to comment.