Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ CFLAGS := -g -Wall -Wno-psabi -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(ARCH)

CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1 -DUC_KEY_REPEAT

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 $(CITRA)

Expand Down
2 changes: 0 additions & 2 deletions include/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
#define _UNISTORE_VERSION 4

inline std::unique_ptr<Config> config;
inline uint32_t hRepeat, hUp, hDown, hHeld;
inline touchPosition touch;
inline C2D_Font font;

extern Thread helperThread;
Expand Down
46 changes: 46 additions & 0 deletions include/overlays/tutorial.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2026 Universal-Team
*
* 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 _UNIVERSAL_UPDATER_TUTORIAL_HPP
#define _UNIVERSAL_UPDATER_TUTORIAL_HPP

#include "common.hpp"
#include "mainScreen.hpp"
#include <3ds.h>

#define KEYS_ALL 0xFFFFFFFF
#define KEYS_NONE 0
#define KEYS_DPAD (KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT)

namespace Tutorial {
void DrawTop(void);
void DrawBottom(void);
void Logic(u32 hDown, touchPosition &touch, MainScreen &ms);

u32 GetKeyMask(void);
};

#endif
7 changes: 5 additions & 2 deletions include/screens/mainScreen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ class MainScreen : public Screen {
public:
MainScreen();
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
void Logic(u32 hDown, u32 hRepeat, u32 hHeld, touchPosition touch) override;

void SwitchPage(int mode, int page) { storeMode = mode; sPage = page; }

private:
std::vector<std::string> dwnldList, dwnldSizes, dwnldTypes;

bool initialized = false, fetchDown = false, showMarks = false, showSettings = false,
bool initialized = false, fetchDown = false, showMarks = false,
screenshotFetch = false, canDisplay = false;

int storeMode = 0, markIndex = 0, sPage = 0, lMode = 0, sSelection = 0,
Expand Down
22 changes: 11 additions & 11 deletions include/store/storeUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,33 @@ namespace StoreUtils {

/* Grid. */
void DrawGrid();
void GridLogic(int &currentMode, int &lastMode, bool &fetch, int &smallDelay);
void GridLogic(u32 hDown, u32 hRepeat, int &currentMode, int &lastMode, bool &fetch, int &smallDelay);

/* Top List. */
void DrawList();
void ListLogic(int &currentMode, int &lastMode, bool &fetch, int &smallDelay);
void ListLogic(u32 hDown, u32 hRepeat, int &currentMode, int &lastMode, bool &fetch, int &smallDelay);

/* Entry Info. */
void DrawEntryInfo(const std::shared_ptr<StoreEntry> &entry);
void EntryHandle(bool &showMark, bool &fetch, bool &sFetch, int &mode, const std::shared_ptr<StoreEntry> &entry);
void EntryHandle(u32 hDown, touchPosition &touch, bool &showMark, bool &fetch, bool &sFetch, int &mode, const std::shared_ptr<StoreEntry> &entry);

/* Side Menu. */
void DrawSideMenu(int currentMenu);
void SideMenuHandle(int &currentMenu, bool &fetch, int &lastMenu);
void SideMenuHandle(u32 hDown, u32 hRepeat, touchPosition &touch, int &currentMenu, bool &fetch, int &lastMenu);

/* Download entries. */
void DrawDownList(const std::vector<std::string> &entries, bool fetch, const std::shared_ptr<StoreEntry> &entry, const std::vector<std::string> &sizes, const std::vector<bool> &installs);
void DownloadHandle(const std::shared_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, const int &lastMode, int &smallDelay, std::vector<bool> &installs, const std::vector<std::string> &types);
void DownloadHandle(u32 hDown, u32 hRepeat, touchPosition &touch, const std::shared_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, const int &lastMode, int &smallDelay, std::vector<bool> &installs, const std::vector<std::string> &types);

/* Queue System. */
void DrawQueueMenu(const int queueIndex);
void QueueMenuHandle(int &queueIndex, int &storeMode);
void QueueMenuHandle(u32 hDown, touchPosition &touch, int &queueIndex, int &storeMode);

/* Search + Favorite Menu. */
void ResetSearch();
void DoSearch();
void DrawSearchMenu();
void SearchHandle();
void SearchHandle(u32 hDown, touchPosition &touch);

/* Mark Menu. */
void DisplayMarkBox(int marks);
Expand All @@ -83,22 +83,22 @@ namespace StoreUtils {

/* Screenshot menu. */
void DrawScreenshotMenu(const C2D_Image &img, const int sIndex, const bool sFetch, const int screenshotSize, const std::string &name, const int zoom, const bool canDisplay);
void ScreenshotMenu(C2D_Image &img, int &sIndex, bool &sFetch, int &storeMode, const int screenshotSize, int &zoom, bool &canDisplay);
void ScreenshotMenu(u32 hDown, C2D_Image &img, int &sIndex, bool &sFetch, int &storeMode, const int screenshotSize, int &zoom, bool &canDisplay);

/* Settings. */
void DrawSettings(int page, int selection, int sPos);
void SettingsHandle(int &page, bool &dspSettings, int &storeMode, int &selection, int &sPos);
void SettingsHandle(u32 hDown, u32 hRepeat, touchPosition &touch, int &page, int &storeMode, int &selection, int &sPos);

/* Sorting. */
void DrawSorting(void);
void SortHandle(void);
void SortHandle(u32 hDown, touchPosition &touch);

/* Release Notes. */
size_t FindSplitPoint(const std::string &str, const std::vector<std::string> splitters);
const std::vector<std::string> &ProcessReleaseNotes(std::string ReleaseNotes, float wrapWidth, float fontSize);

void DrawReleaseNotes(const float &scrollOffset, const std::shared_ptr<StoreEntry> &entry);
void ReleaseNotesLogic(float &scrollOffset, float &scrollDelta, int &storeMode);
void ReleaseNotesLogic(u32 hDown, u32 hHeld, touchPosition &touch, float &scrollOffset, float &scrollDelta, int &storeMode);

bool compareTitleDescending(const std::shared_ptr<StoreEntry> &a, const std::shared_ptr<StoreEntry> &b);
bool compareTitleAscending(const std::shared_ptr<StoreEntry> &a, const std::shared_ptr<StoreEntry> &b);
Expand Down
10 changes: 5 additions & 5 deletions source/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ Result Init::MainLoop() {
/* Loop as long as the status is not fullExit. */
while (aptMainLoop() && !fullExit) {
hidScanInput();
hHeld = hidKeysHeld();
hUp = hidKeysUp();
hDown = hidKeysDown();
hRepeat = hidKeysDownRepeat();
u32 hHeld = hidKeysHeld();
u32 hDown = hidKeysDown();
u32 hRepeat = hidKeysDownRepeat();
touchPosition touch;
hidTouchRead(&touch);

Gui::clearTextBufs();
Expand All @@ -196,7 +196,7 @@ Result Init::MainLoop() {
Gui::DrawScreen(false);
C3D_FrameEnd(0);

if (!exiting) Gui::ScreenLogic(hDown, hHeld, touch, true, false);
if (!exiting) Gui::ScreenLogic(hDown, hRepeat, hHeld, touch, true, false);
else {
if (hidKeysDown() & KEY_START) fullExit = true; // Make it optionally faster.

Expand Down
5 changes: 4 additions & 1 deletion source/menu/downList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,17 @@ void StoreUtils::DrawDownList(const std::vector<std::string> &entries, bool fetc
- Execute an Entry of the download list.
- Return back to EntryInfo through `B`.

u32 hDown: Keys down.
u32 hRepeat: Keys down, repeating.
touchPosition &touch: Touch screen status.
const std::shared_ptr<StoreEntry> &entry: Const Reference to the current StoreEntry, since we do not modify anything in it.
const std::vector<std::string> &entries: Const Reference to the download list, since we do not modify anything in it.
int &currentMenu: Reference to the StoreMode / Menu, so we can switch back to EntryInfo with `B`.
const int &lastMode: Const Reference to the last mode.
int &smallDelay: Reference to the small delay. This helps to not directly press A.
std::vector<bool> &installs: Reference to the installed states.
*/
void StoreUtils::DownloadHandle(const std::shared_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, const int &lastMode, int &smallDelay, std::vector<bool> &installs, const std::vector<std::string> &types) {
void StoreUtils::DownloadHandle(u32 hDown, u32 hRepeat, touchPosition &touch, const std::shared_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, const int &lastMode, int &smallDelay, std::vector<bool> &installs, const std::vector<std::string> &types) {
if (StoreUtils::store && entry) { // Ensure, store & entry is not a nullptr.
if (smallDelay > 0) {
smallDelay--;
Expand Down
4 changes: 3 additions & 1 deletion source/menu/entryInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ void StoreUtils::DrawEntryInfo(const std::shared_ptr<StoreEntry> &entry) {
- Go to the download list, by pressing `A`.
- Show the MarkMenu with START.

u32 hDown: Keys down.
touchPosition &touch: Touch screen status.
bool &showMark: Reference to showMark.. to show the mark menu.
bool &fetch: Reference to fetch, so we know, if we need to fetch, when accessing download list.
bool &sFetch: Reference to the screenshot fetch.
int &mode: Reference to the store mode.
const std::shared_ptr<StoreEntry> &entry: The store Entry.
*/
void StoreUtils::EntryHandle(bool &showMark, bool &fetch, bool &sFetch, int &mode, const std::shared_ptr<StoreEntry> &entry) {
void StoreUtils::EntryHandle(u32 hDown, touchPosition &touch, bool &showMark, bool &fetch, bool &sFetch, int &mode, const std::shared_ptr<StoreEntry> &entry) {
if (entry) {
if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, btn))) showMark = true;

Expand Down
4 changes: 3 additions & 1 deletion source/menu/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ void StoreUtils::DrawGrid() {

- Scroll through the Grid with the D-Pad.

u32 hDown: Keys down.
u32 hRepeat: Keys down, repeating.
const int &currentMode: Reference to the current Mode.
int &lastMode: Reference to the last mode.
bool &fetch: Reference to fetch.
int &smallDelay: Reference to the small delay.
*/
void StoreUtils::GridLogic(int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
void StoreUtils::GridLogic(u32 hDown, u32 hRepeat, int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
if (StoreUtils::store) { // Ensure, store is not a nullptr.
if (hRepeat & KEY_DOWN) {
if (StoreUtils::store->GetBox() > 9) {
Expand Down
4 changes: 3 additions & 1 deletion source/menu/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ void StoreUtils::DrawList() {

- Scroll through the Grid with the D-Pad Up / Down and skip 3 entries with Left / Right.

u32 hDown: Keys down.
u32 hRepeat: Keys down, repeating.
int &currentMode: Const Reference to the current Mode.
int &lastMode: Reference to the last mode.
bool &fetch: Reference to fetch.
int &smallDelay: Reference to the small delay.
*/
void StoreUtils::ListLogic(int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
void StoreUtils::ListLogic(u32 hDown, u32 hRepeat, int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
if (StoreUtils::store) { // Ensure, store is not a nullptr.
if (hRepeat & KEY_DOWN) {
if (StoreUtils::store->GetEntry() < (int)StoreUtils::entries.size() - 1) StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() + 1);
Expand Down
2 changes: 1 addition & 1 deletion source/menu/queueMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void StoreUtils::DrawQueueMenu(const int queueIndex) {
}
}

void StoreUtils::QueueMenuHandle(int &queueIndex, int &storeMode) {
void StoreUtils::QueueMenuHandle(u32 hDown, touchPosition &touch, int &queueIndex, int &storeMode) {
if (!queueEntries.empty()) {
if ((1 + queueMenuIdx) > (int)queueEntries.size() - 1) queueMenuIdx = std::max<int>((int)(queueEntries.size() - 1) - 1, 0); // Ensure this really doesn't go below 0.
}
Expand Down
7 changes: 5 additions & 2 deletions source/menu/releaseNotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ void StoreUtils::DrawReleaseNotes(const float &scrollOffset, const std::shared_p
/*
As the name says: Release notes logic.

u32 hDown: Keys down.
u32 hHeld: Keys held.
touchPosition &touch: Touch screen status.
float &scrollOffset: The scroll offset for the Release Notes text.
float &scrollDelta: The scroll delta for the Release Notes text.
int &storeMode: The store mode to properly return back.
*/
void StoreUtils::ReleaseNotesLogic(float &scrollOffset, float &scrollDelta, int &storeMode) {
void StoreUtils::ReleaseNotesLogic(u32 hDown, u32 hHeld, touchPosition &touch, float &scrollOffset, float &scrollDelta, int &storeMode) {
int linesPerScreen = ((240.0f - 25.0f) / Gui::GetStringHeight(0.5f, "", font));
scrollOffset += scrollDelta;
if (scrollDelta > 0) {
Expand Down Expand Up @@ -146,7 +149,7 @@ void StoreUtils::ReleaseNotesLogic(float &scrollOffset, float &scrollDelta, int
touches[0] = touches[1];
touches[1] = touch;
}
if (hUp & KEY_TOUCH && touches[1].py > 25) {
if (!(hHeld & KEY_TOUCH) && touches[1].py > 25) {
scrollDelta = touches[0].py - touches[1].py;
}

Expand Down
3 changes: 2 additions & 1 deletion source/menu/screenshotMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ void StoreUtils::DrawScreenshotMenu(const C2D_Image &img, const int sIndex, cons
/*
Screenshot Menu handle.

u32 hDown: Keys down.
C2D_Image &img: The C2D_Image of the screenshot.
int &sIndex: The Screenshot index.
bool &sFetch: If fetching screenshots or not.
const int screenshotSize: The screenshot amount.
int &zoom: The zoom level, zoom out, 1x scale, or zoom in.
bool &canDisplay: If can display or not.
*/
void StoreUtils::ScreenshotMenu(C2D_Image &img, int &sIndex, bool &sFetch, int &storeMode, const int screenshotSize, int &zoom, bool &canDisplay) {
void StoreUtils::ScreenshotMenu(u32 hDown, C2D_Image &img, int &sIndex, bool &sFetch, int &storeMode, const int screenshotSize, int &zoom, bool &canDisplay) {
if (hDown & KEY_B) {
canDisplay = false;
zoom = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/menu/searchMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void StoreUtils::DrawSearchMenu() {
bool &updateFilter: Reference to the update filter.
bool &isAND: Reference to isAND boolean for AND / OR mode.
*/
void StoreUtils::SearchHandle() {
void StoreUtils::SearchHandle(u32 hDown, touchPosition &touch) {
/* Checkboxes. */
if (hDown & KEY_TOUCH) {
bool didTouch = false;
Expand Down
Loading
Loading