mirror of
https://github.com/BernardoGiordano/Checkpoint
synced 2024-11-28 03:20:17 +00:00
commit
4395619de0
18 changed files with 542 additions and 668 deletions
|
@ -58,7 +58,7 @@ protected:
|
|||
std::string nameFromCell(size_t index) const;
|
||||
|
||||
private:
|
||||
HidHorizontal hid;
|
||||
Hid<HidDirection::HORIZONTAL, HidDirection::VERTICAL> hid;
|
||||
std::unique_ptr<Clickable> buttonBackup, buttonRestore, buttonCheats, buttonPlayCoins;
|
||||
std::unique_ptr<Scrollable> directoryList;
|
||||
char ver[10];
|
||||
|
@ -75,4 +75,4 @@ private:
|
|||
int refreshTimer;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -51,8 +51,8 @@ private:
|
|||
C2D_TextBuf textBuf;
|
||||
C2D_Text text;
|
||||
std::unique_ptr<Clickable> buttonYes, buttonNo;
|
||||
HidHorizontal hid;
|
||||
Hid<HidDirection::HORIZONTAL, HidDirection::HORIZONTAL> hid;
|
||||
std::function<void()> yesFunc, noFunc;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -30,44 +30,28 @@
|
|||
#include "ihid.hpp"
|
||||
#include <3ds.h>
|
||||
|
||||
class HidHorizontal : public IHidHorizontal {
|
||||
#define DELAY_TICKS 50000000
|
||||
|
||||
template <HidDirection ListDirection, HidDirection PageDirection>
|
||||
class Hid : public IHid<ListDirection, PageDirection, DELAY_TICKS>
|
||||
{
|
||||
public:
|
||||
HidHorizontal(size_t entries, size_t columns) : IHidHorizontal(entries, columns) { mDelayTicks = 35000000; }
|
||||
Hid(size_t entries, size_t columns) : IHid<ListDirection, PageDirection, DELAY_TICKS>(entries, columns) {}
|
||||
|
||||
virtual ~HidHorizontal(void) {}
|
||||
|
||||
u64 down(void) override { return (u64)hidKeysDown(); }
|
||||
|
||||
u64 held(void) override { return (u64)hidKeysHeld(); }
|
||||
|
||||
u64 tick(void) override { return svcGetSystemTick(); }
|
||||
|
||||
u64 _KEY_ZL(void) override { return KEY_ZL; }
|
||||
u64 _KEY_ZR(void) override { return KEY_ZR; }
|
||||
u64 _KEY_LEFT(void) override { return KEY_LEFT; }
|
||||
u64 _KEY_RIGHT(void) override { return KEY_RIGHT; }
|
||||
u64 _KEY_UP(void) override { return KEY_UP; }
|
||||
u64 _KEY_DOWN(void) override { return KEY_DOWN; }
|
||||
private:
|
||||
bool downDown() const override { return hidKeysDown() & KEY_DOWN; }
|
||||
bool upDown() const override { return hidKeysDown() & KEY_UP; }
|
||||
bool leftDown() const override { return hidKeysDown() & KEY_LEFT; }
|
||||
bool rightDown() const override { return hidKeysDown() & KEY_RIGHT; }
|
||||
bool leftTriggerDown() const override { return hidKeysDown() & KEY_L || hidKeysDown() & KEY_ZL; }
|
||||
bool rightTriggerDown() const override { return hidKeysDown() & KEY_R || hidKeysDown() & KEY_ZR; }
|
||||
bool downHeld() const override { return hidKeysHeld() & KEY_DOWN; }
|
||||
bool upHeld() const override { return hidKeysHeld() & KEY_UP; }
|
||||
bool leftHeld() const override { return hidKeysHeld() & KEY_LEFT; }
|
||||
bool rightHeld() const override { return hidKeysHeld() & KEY_RIGHT; }
|
||||
bool leftTriggerHeld() const override { return hidKeysHeld() & KEY_L || hidKeysHeld() & KEY_ZL; }
|
||||
bool rightTriggerHeld() const override { return hidKeysHeld() & KEY_R || hidKeysHeld() & KEY_ZR; }
|
||||
u64 tick() const override { return svcGetSystemTick(); }
|
||||
};
|
||||
|
||||
class HidVertical : public IHidVertical {
|
||||
public:
|
||||
HidVertical(size_t entries, size_t columns) : IHidVertical(entries, columns) { mDelayTicks = 50000000; }
|
||||
|
||||
virtual ~HidVertical(void) {}
|
||||
|
||||
u64 down(void) override { return (u64)hidKeysDown(); }
|
||||
|
||||
u64 held(void) override { return (u64)hidKeysHeld(); }
|
||||
|
||||
u64 tick(void) override { return svcGetSystemTick(); }
|
||||
|
||||
u64 _KEY_ZL(void) override { return KEY_ZL; }
|
||||
u64 _KEY_ZR(void) override { return KEY_ZR; }
|
||||
u64 _KEY_LEFT(void) override { return KEY_LEFT; }
|
||||
u64 _KEY_RIGHT(void) override { return KEY_RIGHT; }
|
||||
u64 _KEY_UP(void) override { return KEY_UP; }
|
||||
u64 _KEY_DOWN(void) override { return KEY_DOWN; }
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -37,12 +37,9 @@
|
|||
|
||||
class Scrollable : public IScrollable<u32> {
|
||||
public:
|
||||
Scrollable(int x, int y, u32 w, u32 h, size_t visibleEntries) : IScrollable(x, y, w, h, visibleEntries)
|
||||
{
|
||||
mHid = new HidVertical(visibleEntries, 1);
|
||||
}
|
||||
Scrollable(int x, int y, u32 w, u32 h, size_t visibleEntries) : IScrollable(x, y, w, h, visibleEntries), mHid(visibleEntries, 1) {}
|
||||
|
||||
virtual ~Scrollable(void) { delete mHid; }
|
||||
virtual ~Scrollable(void) {}
|
||||
|
||||
void c2dText(size_t i, const std::string& v);
|
||||
void draw(bool condition = false) override;
|
||||
|
@ -52,7 +49,7 @@ public:
|
|||
void updateSelection(void) override;
|
||||
|
||||
protected:
|
||||
HidVertical* mHid;
|
||||
Hid<HidDirection::VERTICAL, HidDirection::HORIZONTAL> mHid;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -276,13 +276,6 @@ void MainScreen::updateSelector(void)
|
|||
if (getTitleCount() > 0) {
|
||||
size_t count = getTitleCount();
|
||||
hid.update(count);
|
||||
// change page
|
||||
if (hidKeysDown() & KEY_L) {
|
||||
hid.pageBack(count);
|
||||
}
|
||||
else if (hidKeysDown() & KEY_R) {
|
||||
hid.pageForward(count);
|
||||
}
|
||||
directoryList->resetIndex();
|
||||
}
|
||||
}
|
||||
|
@ -559,4 +552,4 @@ void MainScreen::updateButtons(void)
|
|||
std::string MainScreen::nameFromCell(size_t index) const
|
||||
{
|
||||
return directoryList->cellName(index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ void Scrollable::c2dText(size_t i, const std::string& v)
|
|||
void Scrollable::setIndex(size_t i)
|
||||
{
|
||||
IScrollable::index(i);
|
||||
mHid->index(mIndex);
|
||||
mHid->page(mPage);
|
||||
mHid.index(mIndex);
|
||||
mHid.page(mPage);
|
||||
}
|
||||
|
||||
void Scrollable::resetIndex(void)
|
||||
|
@ -56,15 +56,15 @@ void Scrollable::updateSelection(void)
|
|||
touchPosition touch;
|
||||
hidTouchRead(&touch);
|
||||
|
||||
const u32 hu = (mHid->maxEntries(size()) + 1) * mh / mVisibleEntries;
|
||||
const u32 hu = (mHid.maxEntries(size()) + 1) * mh / mVisibleEntries;
|
||||
|
||||
if (hidKeysHeld() & KEY_TOUCH && touch.py > (float)my && touch.py < (float)(my + hu) && touch.px > (float)mx && touch.px < (float)(mx + mw)) {
|
||||
mHid->index((size_t)((touch.py - my) * mVisibleEntries / mh));
|
||||
mHid.index((size_t)((touch.py - my) * mVisibleEntries / mh));
|
||||
}
|
||||
|
||||
mHid->update(size());
|
||||
mIndex = mHid->index();
|
||||
mPage = mHid->page();
|
||||
mHid.update(size());
|
||||
mIndex = mHid.index();
|
||||
mPage = mHid.page();
|
||||
}
|
||||
|
||||
void Scrollable::draw(bool condition)
|
||||
|
@ -86,4 +86,4 @@ void Scrollable::draw(bool condition)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
104
common/ihid.cpp
104
common/ihid.cpp
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* This file is part of Checkpoint
|
||||
* Copyright (C) 2017-2019 Bernardo Giordano, FlagBrew
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "ihid.hpp"
|
||||
|
||||
size_t IHid::index(void) const
|
||||
{
|
||||
return mIndex;
|
||||
}
|
||||
|
||||
void IHid::index(size_t v)
|
||||
{
|
||||
mIndex = v;
|
||||
}
|
||||
|
||||
size_t IHid::fullIndex(void) const
|
||||
{
|
||||
return mIndex + mPage * mMaxVisibleEntries;
|
||||
}
|
||||
|
||||
int IHid::page(void) const
|
||||
{
|
||||
return mPage;
|
||||
}
|
||||
|
||||
void IHid::page(int v)
|
||||
{
|
||||
mPage = v;
|
||||
}
|
||||
|
||||
void IHid::reset(void)
|
||||
{
|
||||
mIndex = 0;
|
||||
mPage = 0;
|
||||
}
|
||||
|
||||
size_t IHid::maxVisibleEntries(void) const
|
||||
{
|
||||
return mMaxVisibleEntries;
|
||||
}
|
||||
|
||||
size_t IHid::maxEntries(size_t count) const
|
||||
{
|
||||
return (count - mPage * mMaxVisibleEntries) > mMaxVisibleEntries ? mMaxVisibleEntries - 1 : count - mPage * mMaxVisibleEntries - 1;
|
||||
}
|
||||
|
||||
void IHid::page_back(void)
|
||||
{
|
||||
if (mPage > 0) {
|
||||
mPage--;
|
||||
}
|
||||
else if (mPage == 0) {
|
||||
mPage = mMaxPages - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void IHid::page_forward(void)
|
||||
{
|
||||
if (mPage < (int)mMaxPages - 1) {
|
||||
mPage++;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
140
common/ihid.hpp
140
common/ihid.hpp
|
@ -33,71 +33,111 @@
|
|||
|
||||
typedef uint64_t u64;
|
||||
|
||||
enum class HidDirection
|
||||
{
|
||||
VERTICAL,
|
||||
HORIZONTAL
|
||||
};
|
||||
|
||||
template <HidDirection ListDirection, HidDirection PageDirection, u64 Delay>
|
||||
class IHid {
|
||||
public:
|
||||
IHid(size_t entries, size_t columns) : mMaxVisibleEntries(entries), mColumns(columns)
|
||||
IHid(size_t entries, size_t columns)
|
||||
{
|
||||
reset();
|
||||
mMaxPages = 0;
|
||||
mCurrentTime = 0;
|
||||
mLastTime = 0;
|
||||
mDelayTicks = 1e10;
|
||||
mMaxVisibleEntries = entries;
|
||||
mColumns = columns;
|
||||
mRows = entries / columns;
|
||||
mIndex = 0;
|
||||
mPage = 0;
|
||||
mMaxPages = 0;
|
||||
mLastTime = 0;
|
||||
}
|
||||
|
||||
virtual ~IHid(void) {}
|
||||
virtual ~IHid() {}
|
||||
|
||||
size_t fullIndex(void) const;
|
||||
size_t index(void) const;
|
||||
void index(size_t v);
|
||||
size_t maxEntries(size_t max) const;
|
||||
size_t maxVisibleEntries(void) const;
|
||||
int page(void) const;
|
||||
void page(int v);
|
||||
void reset(void);
|
||||
void pageBack(size_t count);
|
||||
void pageForward(size_t count);
|
||||
size_t fullIndex(void) const { return mIndex + mPage * mMaxVisibleEntries; }
|
||||
size_t index(void) const { return mIndex; }
|
||||
void index(size_t v) { mIndex = v; }
|
||||
size_t maxVisibleEntries(void) const { return mMaxVisibleEntries; }
|
||||
int page(void) const { return mPage; }
|
||||
void page(int v) { mPage = v; }
|
||||
size_t maxEntries(size_t count) const
|
||||
{
|
||||
return (count - mPage * mMaxVisibleEntries) > mMaxVisibleEntries ? mMaxVisibleEntries - 1 : count - mPage * mMaxVisibleEntries - 1;
|
||||
}
|
||||
void pageBack()
|
||||
{
|
||||
if (mPage > 0)
|
||||
{
|
||||
mPage--;
|
||||
}
|
||||
else if (mPage == 0)
|
||||
{
|
||||
mPage = mMaxPages - 1;
|
||||
}
|
||||
}
|
||||
void pageForward()
|
||||
{
|
||||
if (mPage < (int)mMaxPages - 1)
|
||||
{
|
||||
mPage++;
|
||||
}
|
||||
else if (mPage == (int)mMaxPages - 1)
|
||||
{
|
||||
mPage = 0;
|
||||
}
|
||||
}
|
||||
void reset(void)
|
||||
{
|
||||
mIndex = 0;
|
||||
mPage = 0;
|
||||
}
|
||||
void correctIndex(size_t count)
|
||||
{
|
||||
if (mIndex > maxEntries(count))
|
||||
{
|
||||
if constexpr (ListDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
mIndex = mIndex % mColumns;
|
||||
}
|
||||
else
|
||||
{
|
||||
mIndex = mIndex % mRows;
|
||||
}
|
||||
// If the above doesn't fix, then forcibly fix
|
||||
if (mIndex > maxEntries(count))
|
||||
{
|
||||
mIndex = maxEntries(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
void page_back(void);
|
||||
void page_forward(void);
|
||||
virtual void update(size_t count) = 0;
|
||||
|
||||
virtual u64 down(void) = 0;
|
||||
virtual u64 held(void) = 0;
|
||||
virtual u64 tick(void) = 0;
|
||||
virtual u64 _KEY_ZL(void) = 0;
|
||||
virtual u64 _KEY_ZR(void) = 0;
|
||||
virtual u64 _KEY_LEFT(void) = 0;
|
||||
virtual u64 _KEY_RIGHT(void) = 0;
|
||||
virtual u64 _KEY_UP(void) = 0;
|
||||
virtual u64 _KEY_DOWN(void) = 0;
|
||||
void update(size_t count);
|
||||
|
||||
private:
|
||||
size_t mIndex;
|
||||
int mPage;
|
||||
size_t mMaxPages;
|
||||
size_t mMaxVisibleEntries;
|
||||
size_t mColumns;
|
||||
u64 mCurrentTime;
|
||||
size_t mRows;
|
||||
u64 mLastTime;
|
||||
u64 mDelayTicks;
|
||||
|
||||
virtual bool downDown() const = 0;
|
||||
virtual bool upDown() const = 0;
|
||||
virtual bool leftDown() const = 0;
|
||||
virtual bool rightDown() const = 0;
|
||||
virtual bool leftTriggerDown() const = 0;
|
||||
virtual bool rightTriggerDown() const = 0;
|
||||
virtual bool downHeld() const = 0;
|
||||
virtual bool upHeld() const = 0;
|
||||
virtual bool leftHeld() const = 0;
|
||||
virtual bool rightHeld() const = 0;
|
||||
virtual bool leftTriggerHeld() const = 0;
|
||||
virtual bool rightTriggerHeld() const = 0;
|
||||
virtual u64 tick() const = 0;
|
||||
};
|
||||
|
||||
class IHidVertical : public IHid {
|
||||
public:
|
||||
IHidVertical(size_t entries, size_t columns) : IHid(entries, columns) {}
|
||||
|
||||
virtual ~IHidVertical(void) {}
|
||||
|
||||
void update(size_t count) override;
|
||||
};
|
||||
|
||||
class IHidHorizontal : public IHid {
|
||||
public:
|
||||
IHidHorizontal(size_t entries, size_t columns) : IHid(entries, columns) {}
|
||||
|
||||
virtual ~IHidHorizontal(void) {}
|
||||
|
||||
void update(size_t count) override;
|
||||
};
|
||||
#include "ihid.tcc"
|
||||
|
||||
#endif
|
||||
|
|
375
common/ihid.tcc
Normal file
375
common/ihid.tcc
Normal file
|
@ -0,0 +1,375 @@
|
|||
/*
|
||||
* This file is part of PKSM
|
||||
* Copyright (C) 2016-2020 Bernardo Giordano, Admiral Fish, piepie62
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#ifndef IHID_HPP
|
||||
#error "This file should not be directly included!"
|
||||
#endif
|
||||
|
||||
template <HidDirection ListDirection, HidDirection PageDirection, u64 Delay>
|
||||
void IHid<ListDirection, PageDirection, Delay>::update(size_t count)
|
||||
{
|
||||
u64 currentTime = tick();
|
||||
|
||||
mMaxPages = (count % mMaxVisibleEntries == 0) ? count / mMaxVisibleEntries : count / mMaxVisibleEntries + 1;
|
||||
|
||||
if (leftTriggerDown())
|
||||
{
|
||||
pageBack();
|
||||
}
|
||||
else if (rightTriggerDown())
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
else if (leftTriggerHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pageBack();
|
||||
}
|
||||
else if (rightTriggerHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pageForward();
|
||||
}
|
||||
|
||||
if constexpr (ListDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
if (upDown())
|
||||
{
|
||||
if (mIndex < mColumns)
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageBack();
|
||||
}
|
||||
mIndex += mColumns * (mRows - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mIndex -= mColumns;
|
||||
}
|
||||
}
|
||||
else if (downDown())
|
||||
{
|
||||
mIndex += mColumns;
|
||||
if (mIndex > maxEntries(count))
|
||||
{
|
||||
mIndex %= mColumns;
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (upHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mIndex < mColumns)
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageBack();
|
||||
}
|
||||
mIndex += mColumns * (mRows - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mIndex -= mColumns;
|
||||
}
|
||||
}
|
||||
else if (downHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mIndex += mColumns;
|
||||
if (mIndex > maxEntries(count))
|
||||
{
|
||||
mIndex %= mColumns;
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (leftDown())
|
||||
{
|
||||
if (mIndex % mColumns != 0)
|
||||
{
|
||||
mIndex--;
|
||||
}
|
||||
else
|
||||
{
|
||||
mIndex += mColumns - 1;
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rightDown())
|
||||
{
|
||||
if (mIndex % mColumns != mColumns - 1)
|
||||
{
|
||||
mIndex++;
|
||||
if (mIndex > maxEntries(count))
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex = mIndex - (mIndex % mColumns);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex -= mColumns - 1;
|
||||
}
|
||||
}
|
||||
else if (leftHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mIndex % mColumns != 0)
|
||||
{
|
||||
mIndex--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageBack();
|
||||
}
|
||||
mIndex += mColumns - 1;
|
||||
}
|
||||
}
|
||||
else if (rightHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mIndex % mColumns != mColumns - 1)
|
||||
{
|
||||
mIndex++;
|
||||
if (mIndex > maxEntries(count))
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex = mIndex - (mIndex % mColumns);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex -= mColumns - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (leftDown())
|
||||
{
|
||||
if (mIndex / mRows != 0)
|
||||
{
|
||||
mIndex -= mRows;
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageBack();
|
||||
}
|
||||
mIndex += mRows * (mColumns - 1);
|
||||
}
|
||||
}
|
||||
else if (rightDown())
|
||||
{
|
||||
mIndex += mRows;
|
||||
if (mIndex > maxEntries(count))
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex %= mRows;
|
||||
}
|
||||
}
|
||||
else if (leftHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mIndex / mRows != 0)
|
||||
{
|
||||
mIndex -= mRows;
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageBack();
|
||||
}
|
||||
mIndex += mRows * (mColumns - 1);
|
||||
}
|
||||
}
|
||||
else if (rightHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mIndex += mRows;
|
||||
if (mIndex > maxEntries(count))
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::HORIZONTAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex %= mRows;
|
||||
}
|
||||
}
|
||||
|
||||
if (upDown())
|
||||
{
|
||||
if (mIndex % mRows > 0)
|
||||
{
|
||||
mIndex -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageBack();
|
||||
}
|
||||
mIndex = mIndex + mRows - 1;
|
||||
}
|
||||
}
|
||||
else if (downDown())
|
||||
{
|
||||
if ((mIndex % mRows) < mRows - 1)
|
||||
{
|
||||
if (mIndex + mPage * mMaxVisibleEntries == count - 1)
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex = mIndex - (mIndex % mRows);
|
||||
}
|
||||
else
|
||||
{
|
||||
mIndex += 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex = mIndex + 1 - mRows;
|
||||
}
|
||||
}
|
||||
else if (upHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mIndex % mRows > 0)
|
||||
{
|
||||
mIndex -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageBack();
|
||||
}
|
||||
mIndex = mIndex + mRows - 1;
|
||||
}
|
||||
}
|
||||
else if (downHeld())
|
||||
{
|
||||
if (currentTime <= mLastTime + Delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((mIndex % mRows) < mRows - 1)
|
||||
{
|
||||
if (mIndex + mPage * mMaxVisibleEntries == count - 1)
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex = mIndex - (mIndex % mRows);
|
||||
}
|
||||
else
|
||||
{
|
||||
mIndex += 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (PageDirection == HidDirection::VERTICAL)
|
||||
{
|
||||
pageForward();
|
||||
}
|
||||
mIndex = mIndex + 1 - mRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
correctIndex(count);
|
||||
|
||||
mLastTime = currentTime;
|
||||
}
|
|
@ -1,192 +0,0 @@
|
|||
/*
|
||||
* This file is part of Checkpoint
|
||||
* Copyright (C) 2017-2019 Bernardo Giordano, FlagBrew
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "ihid.hpp"
|
||||
|
||||
void IHidHorizontal::update(size_t count)
|
||||
{
|
||||
mCurrentTime = tick();
|
||||
size_t rows = mMaxVisibleEntries / mColumns;
|
||||
mMaxPages = (count % mMaxVisibleEntries == 0) ? count / mMaxVisibleEntries : count / mMaxVisibleEntries + 1;
|
||||
u64 kHeld = held();
|
||||
u64 kDown = down();
|
||||
|
||||
if (kDown & _KEY_ZL()) {
|
||||
page_back();
|
||||
if (mIndex > maxEntries(count)) {
|
||||
mIndex = maxEntries(count);
|
||||
}
|
||||
}
|
||||
else if (kDown & _KEY_ZR()) {
|
||||
page_forward();
|
||||
if (mIndex > maxEntries(count)) {
|
||||
mIndex = maxEntries(count);
|
||||
}
|
||||
}
|
||||
else if (mColumns > 1) {
|
||||
if (kDown & _KEY_LEFT()) {
|
||||
if (mIndex % mColumns != 0) {
|
||||
mIndex--;
|
||||
}
|
||||
else {
|
||||
page_back();
|
||||
mIndex += mColumns - 1;
|
||||
}
|
||||
}
|
||||
else if (kDown & _KEY_RIGHT()) {
|
||||
if (mIndex % mColumns != mColumns - 1) {
|
||||
if (mIndex + mPage * mMaxVisibleEntries == count - 1) {
|
||||
page_forward();
|
||||
mIndex = (mIndex / mColumns) * mColumns;
|
||||
}
|
||||
else {
|
||||
mIndex++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
page_forward();
|
||||
mIndex -= mColumns - 1;
|
||||
}
|
||||
}
|
||||
else if (kDown & _KEY_UP()) {
|
||||
if (mIndex < mColumns) {
|
||||
mIndex += mColumns * (rows - 1);
|
||||
}
|
||||
else {
|
||||
mIndex -= mColumns;
|
||||
}
|
||||
}
|
||||
else if (kDown & _KEY_DOWN()) {
|
||||
if (mIndex >= mColumns * (rows - 1)) {
|
||||
mIndex -= mColumns * (rows - 1);
|
||||
}
|
||||
else {
|
||||
mIndex += mColumns;
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_LEFT()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex % mColumns != 0) {
|
||||
mIndex--;
|
||||
}
|
||||
else {
|
||||
page_back();
|
||||
mIndex += mColumns - 1;
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_RIGHT()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex % mColumns != mColumns - 1) {
|
||||
if (mIndex + mPage * mMaxVisibleEntries == count - 1) {
|
||||
page_forward();
|
||||
mIndex = (mIndex / mColumns) * mColumns;
|
||||
}
|
||||
else {
|
||||
mIndex++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
page_forward();
|
||||
mIndex -= mColumns - 1;
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_UP()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex < mColumns) {
|
||||
mIndex += mColumns * (rows - 1);
|
||||
}
|
||||
else {
|
||||
mIndex -= mColumns;
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_DOWN()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex >= mColumns * (rows - 1)) {
|
||||
mIndex -= mColumns * (rows - 1);
|
||||
}
|
||||
else {
|
||||
mIndex += mColumns;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (kDown & _KEY_UP()) {
|
||||
if (mIndex > 0) {
|
||||
mIndex--;
|
||||
}
|
||||
else if (mIndex == 0) {
|
||||
page_back();
|
||||
mIndex = maxEntries(count);
|
||||
}
|
||||
}
|
||||
else if (kDown & _KEY_DOWN()) {
|
||||
if (mIndex < maxEntries(count)) {
|
||||
mIndex++;
|
||||
}
|
||||
else if (mIndex == maxEntries(count)) {
|
||||
page_forward();
|
||||
mIndex = 0;
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_UP()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex > 0) {
|
||||
mIndex--;
|
||||
}
|
||||
else if (mIndex == 0) {
|
||||
page_back();
|
||||
mIndex = maxEntries(count);
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_DOWN()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex < maxEntries(count)) {
|
||||
mIndex++;
|
||||
}
|
||||
else if (mIndex == maxEntries(count)) {
|
||||
page_forward();
|
||||
mIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mIndex > maxEntries(count)) {
|
||||
mIndex = maxEntries(count);
|
||||
}
|
||||
mLastTime = mCurrentTime;
|
||||
}
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* This file is part of Checkpoint
|
||||
* Copyright (C) 2017-2019 Bernardo Giordano, FlagBrew
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "ihid.hpp"
|
||||
|
||||
void IHidVertical::update(size_t count)
|
||||
{
|
||||
mCurrentTime = tick();
|
||||
size_t rows = mMaxVisibleEntries / mColumns;
|
||||
mMaxPages = (count % mMaxVisibleEntries == 0) ? count / mMaxVisibleEntries : count / mMaxVisibleEntries + 1;
|
||||
u64 kHeld = held();
|
||||
u64 kDown = down();
|
||||
|
||||
if (kDown & _KEY_ZL()) {
|
||||
page_back();
|
||||
}
|
||||
else if (kDown & _KEY_ZR()) {
|
||||
page_forward();
|
||||
}
|
||||
else if (mColumns > 1) {
|
||||
if (kDown & _KEY_LEFT()) {
|
||||
if (mIndex % rows != mIndex) {
|
||||
mIndex -= rows;
|
||||
}
|
||||
else {
|
||||
page_back();
|
||||
mIndex += rows;
|
||||
}
|
||||
}
|
||||
else if (kDown & _KEY_RIGHT()) {
|
||||
if (maxEntries(count) < rows) {
|
||||
page_forward();
|
||||
}
|
||||
else if (mIndex + rows < mMaxVisibleEntries) {
|
||||
mIndex += rows;
|
||||
}
|
||||
else {
|
||||
page_forward();
|
||||
mIndex -= rows;
|
||||
}
|
||||
}
|
||||
else if (kDown & _KEY_UP()) {
|
||||
if (mIndex % rows > 0) {
|
||||
mIndex -= 1;
|
||||
}
|
||||
else {
|
||||
mIndex = mIndex == rows ? mMaxVisibleEntries - 1 : ((mMaxVisibleEntries - 1) % rows);
|
||||
}
|
||||
}
|
||||
else if (kDown & _KEY_DOWN()) {
|
||||
if ((mIndex % rows) < rows - 1) {
|
||||
if (mIndex + mPage * mMaxVisibleEntries == count - 1) {
|
||||
mIndex = (mIndex / rows) * rows;
|
||||
}
|
||||
else {
|
||||
mIndex += 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mIndex = mIndex == rows - 1 ? 0 : rows;
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_LEFT()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex % rows != mIndex) {
|
||||
mIndex -= rows;
|
||||
}
|
||||
else {
|
||||
page_back();
|
||||
mIndex += rows;
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_RIGHT()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (maxEntries(count) < rows) {
|
||||
page_forward();
|
||||
}
|
||||
else if (mIndex + rows < mMaxVisibleEntries) {
|
||||
mIndex += rows;
|
||||
}
|
||||
else {
|
||||
page_forward();
|
||||
mIndex -= rows;
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_UP()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex % rows > 0) {
|
||||
mIndex -= 1;
|
||||
}
|
||||
else {
|
||||
mIndex = mIndex == rows ? mMaxVisibleEntries - 1 : ((mMaxVisibleEntries - 1) % rows);
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_DOWN()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if ((mIndex % rows) < rows - 1) {
|
||||
if (mIndex + mPage * mMaxVisibleEntries == count - 1) {
|
||||
mIndex = (mIndex / rows) * rows;
|
||||
}
|
||||
else {
|
||||
mIndex += 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mIndex = mIndex == rows - 1 ? 0 : rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (kDown & _KEY_UP()) {
|
||||
if (mIndex > 0) {
|
||||
mIndex--;
|
||||
}
|
||||
else if (mIndex == 0) {
|
||||
page_back();
|
||||
mIndex = maxEntries(count);
|
||||
}
|
||||
}
|
||||
else if (kDown & _KEY_DOWN()) {
|
||||
if (mIndex < maxEntries(count)) {
|
||||
mIndex++;
|
||||
}
|
||||
else if (mIndex == maxEntries(count)) {
|
||||
page_forward();
|
||||
mIndex = 0;
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_UP()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex > 0) {
|
||||
mIndex--;
|
||||
}
|
||||
else if (mIndex == 0) {
|
||||
page_back();
|
||||
mIndex = maxEntries(count);
|
||||
}
|
||||
}
|
||||
else if (kHeld & _KEY_DOWN()) {
|
||||
if (mCurrentTime <= mLastTime + mDelayTicks) {
|
||||
return;
|
||||
}
|
||||
if (mIndex < maxEntries(count)) {
|
||||
mIndex++;
|
||||
}
|
||||
else if (mIndex == maxEntries(count)) {
|
||||
page_forward();
|
||||
mIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mIndex > maxEntries(count)) {
|
||||
mIndex = maxEntries(count);
|
||||
}
|
||||
mLastTime = mCurrentTime;
|
||||
}
|
|
@ -33,7 +33,6 @@
|
|||
template <typename T>
|
||||
class IScrollable {
|
||||
public:
|
||||
IScrollable(void) {}
|
||||
IScrollable(int x, int y, u16 w, u16 h, size_t visibleEntries) : mx(x), my(y), mw(w), mh(h), mVisibleEntries(visibleEntries)
|
||||
{
|
||||
mIndex = 0;
|
||||
|
@ -96,4 +95,4 @@ protected:
|
|||
std::vector<IClickable<T>*> mCells;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -71,10 +71,10 @@ private:
|
|||
entryType_t type;
|
||||
int selectionTimer;
|
||||
bool pksmBridge;
|
||||
HidHorizontal hid;
|
||||
Hid<HidDirection::HORIZONTAL, HidDirection::HORIZONTAL> hid;
|
||||
std::unique_ptr<Scrollable> backupList;
|
||||
std::unique_ptr<Clickable> buttonCheats, buttonBackup, buttonRestore;
|
||||
char ver[8];
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -49,8 +49,8 @@ private:
|
|||
u32 textw, texth;
|
||||
std::string text;
|
||||
std::unique_ptr<Clickable> buttonYes, buttonNo;
|
||||
HidHorizontal hid;
|
||||
Hid<HidDirection::HORIZONTAL, HidDirection::HORIZONTAL> hid;
|
||||
std::function<void()> yesFunc, noFunc;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -30,44 +30,28 @@
|
|||
#include "ihid.hpp"
|
||||
#include <switch.h>
|
||||
|
||||
class HidVertical : public IHidVertical {
|
||||
#define DELAY_TICKS 2500000
|
||||
|
||||
template <HidDirection ListDirection, HidDirection PageDirection>
|
||||
class Hid : public IHid<ListDirection, PageDirection, DELAY_TICKS>
|
||||
{
|
||||
public:
|
||||
HidVertical(size_t entries, size_t columns) : IHidVertical(entries, columns) { mDelayTicks = 2500000; }
|
||||
Hid(size_t entries, size_t columns) : IHid<ListDirection, PageDirection, DELAY_TICKS>(entries, columns) {}
|
||||
|
||||
virtual ~HidVertical(void) {}
|
||||
|
||||
u64 down(void) override { return hidKeysDown(CONTROLLER_P1_AUTO); }
|
||||
|
||||
u64 held(void) override { return hidKeysHeld(CONTROLLER_P1_AUTO); }
|
||||
|
||||
u64 tick(void) override { return armGetSystemTick(); }
|
||||
|
||||
u64 _KEY_ZL(void) override { return 0; }
|
||||
u64 _KEY_ZR(void) override { return 0; }
|
||||
u64 _KEY_LEFT(void) override { return KEY_LEFT; }
|
||||
u64 _KEY_RIGHT(void) override { return KEY_RIGHT; }
|
||||
u64 _KEY_UP(void) override { return KEY_UP; }
|
||||
u64 _KEY_DOWN(void) override { return KEY_DOWN; }
|
||||
private:
|
||||
bool downDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_DOWN; }
|
||||
bool upDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_UP; }
|
||||
bool leftDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_LEFT; }
|
||||
bool rightDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_RIGHT; }
|
||||
bool leftTriggerDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_L; }
|
||||
bool rightTriggerDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_R; }
|
||||
bool downHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_DOWN; }
|
||||
bool upHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_UP; }
|
||||
bool leftHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_LEFT; }
|
||||
bool rightHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_RIGHT; }
|
||||
bool leftTriggerHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_L; }
|
||||
bool rightTriggerHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_R; }
|
||||
u64 tick() const override { return armGetSystemTick(); }
|
||||
};
|
||||
|
||||
class HidHorizontal : public IHidHorizontal {
|
||||
public:
|
||||
HidHorizontal(size_t entries, size_t columns) : IHidHorizontal(entries, columns) { mDelayTicks = 2500000; }
|
||||
|
||||
virtual ~HidHorizontal(void) {}
|
||||
|
||||
u64 down(void) override { return hidKeysDown(CONTROLLER_P1_AUTO); }
|
||||
|
||||
u64 held(void) override { return hidKeysHeld(CONTROLLER_P1_AUTO); }
|
||||
|
||||
u64 tick(void) override { return armGetSystemTick(); }
|
||||
|
||||
u64 _KEY_ZL(void) override { return 0; }
|
||||
u64 _KEY_ZR(void) override { return 0; }
|
||||
u64 _KEY_LEFT(void) override { return KEY_LEFT; }
|
||||
u64 _KEY_RIGHT(void) override { return KEY_RIGHT; }
|
||||
u64 _KEY_UP(void) override { return KEY_UP; }
|
||||
u64 _KEY_DOWN(void) override { return KEY_DOWN; }
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -37,14 +37,9 @@
|
|||
|
||||
class Scrollable : public IScrollable<SDL_Color> {
|
||||
public:
|
||||
Scrollable(void) : IScrollable() {}
|
||||
Scrollable(u32 x, u32 y, u32 w, u32 h, size_t visibleEntries) : IScrollable(x, y, w, h, visibleEntries), mHid(visibleEntries, 1) {}
|
||||
|
||||
Scrollable(u32 x, u32 y, u32 w, u32 h, size_t visibleEntries) : IScrollable(x, y, w, h, visibleEntries)
|
||||
{
|
||||
mHid = new HidVertical(visibleEntries, 1);
|
||||
}
|
||||
|
||||
virtual ~Scrollable(void) { delete mHid; };
|
||||
virtual ~Scrollable(void) {}
|
||||
|
||||
void draw(bool condition = false) override;
|
||||
void setIndex(size_t i);
|
||||
|
@ -54,7 +49,7 @@ public:
|
|||
void text(size_t i, const std::string& v);
|
||||
|
||||
protected:
|
||||
HidVertical* mHid;
|
||||
Hid<HidDirection::VERTICAL, HidDirection::HORIZONTAL> mHid;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -235,13 +235,6 @@ void MainScreen::updateSelector(touchPosition* touch)
|
|||
size_t count = getTitleCount(g_currentUId);
|
||||
size_t oldindex = hid.index();
|
||||
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++) {
|
||||
|
@ -636,4 +629,4 @@ std::string MainScreen::sortMode() const
|
|||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,14 +34,14 @@ void Scrollable::text(size_t i, const std::string& v)
|
|||
void Scrollable::setIndex(size_t i)
|
||||
{
|
||||
IScrollable::index(i);
|
||||
mHid->index(mIndex);
|
||||
mHid->page(mPage);
|
||||
mHid.index(mIndex);
|
||||
mHid.page(mPage);
|
||||
}
|
||||
|
||||
void Scrollable::resetIndex(void)
|
||||
{
|
||||
mHid->index(0);
|
||||
mHid->page(0);
|
||||
mHid.index(0);
|
||||
mHid.page(0);
|
||||
}
|
||||
|
||||
void Scrollable::push_back(SDL_Color color, SDL_Color colorMessage, const std::string& message, bool selected)
|
||||
|
@ -57,15 +57,15 @@ void Scrollable::updateSelection(void)
|
|||
touchPosition touch;
|
||||
hidTouchRead(&touch, 0);
|
||||
|
||||
const int hu = (mHid->maxEntries(size()) + 1) * mh / mVisibleEntries;
|
||||
const int hu = (mHid.maxEntries(size()) + 1) * mh / mVisibleEntries;
|
||||
if (hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_TOUCH && touch.py > (float)my && touch.py < (float)(my + hu) && touch.px > (float)mx &&
|
||||
touch.px < (float)(mx + mw)) {
|
||||
mHid->index(ceilf((touch.py - my) * mVisibleEntries / mh));
|
||||
mHid.index(ceilf((touch.py - my) * mVisibleEntries / mh));
|
||||
}
|
||||
|
||||
mHid->update(size());
|
||||
mIndex = mHid->index();
|
||||
mPage = mHid->page();
|
||||
mHid.update(size());
|
||||
mIndex = mHid.index();
|
||||
mPage = mHid.page();
|
||||
}
|
||||
|
||||
void Scrollable::draw(bool condition)
|
||||
|
@ -87,4 +87,4 @@ void Scrollable::draw(bool condition)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue