Initial Commit

This commit is contained in:
2026-03-05 20:18:29 +01:00
commit 5a4d3ee8e0
901 changed files with 296682 additions and 0 deletions

16
include/JC_page.hpp Normal file
View File

@@ -0,0 +1,16 @@
#pragma once
#include <borealis.hpp>
class JCPage : public brls::AppletFrame
{
private:
brls::List* list;
brls::Label* label;
brls::ListItem* listItem;
brls::ListItem* restore;
brls::ListItem* backup;
public:
JCPage();
};

16
include/PC_page.hpp Normal file
View File

@@ -0,0 +1,16 @@
#pragma once
#include <borealis.hpp>
class PCPage : public brls::AppletFrame
{
private:
brls::List* list;
brls::Label* label;
brls::ListItem* listItem;
brls::ListItem* restore;
brls::ListItem* backup;
public:
PCPage();
};

14
include/about_tab.hpp Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include <borealis.hpp>
class AboutTab : public brls::List
{
public:
AboutTab();
View* getDefaultFocus() override
{
return nullptr;
}
};

31
include/ams_bpc.h Normal file
View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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/>.
*/
#pragma once
#include <switch.h>
#ifdef __cplusplus
extern "C" {
#endif
Result amsBpcInitialize();
void amsBpcExit();
Service* amsBpcGetServiceSession(void);
Result amsBpcSetRebootPayload(const void* src, size_t src_size);
#ifdef __cplusplus
}
#endif

57
include/ams_tab.hpp Normal file
View File

@@ -0,0 +1,57 @@
#pragma once
#include <borealis.hpp>
#include <json.hpp>
#include <set>
#include "constants.hpp"
class AmsTab : public brls::List
{
protected:
brls::ListItem* listItem;
bool erista;
nlohmann::ordered_json nxlinks;
nlohmann::ordered_json hekate;
contentType type;
void CreateStagedFrames(const std::string& text, const std::string& url, bool erista, bool ams = true, bool hekate = false, const std::string& text_hekate = "", const std::string& hekate_url = "");
bool CreateDownloadItems(const nlohmann::ordered_json& cfw_links, bool hekate = true, bool ams = true);
void CreateNotFoundLabel();
virtual void RegisterListItemAction(brls::ListItem* listItem);
public:
AmsTab(const nlohmann::ordered_json& nxlinks, const bool erista = true);
};
class AmsTab_Regular : public AmsTab
{
private:
void CreateLists();
bool CreateDownloadItems(const nlohmann::ordered_json& cfw_links, bool hekate = true, bool ams = true);
void ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules);
std::set<std::string> GetLastDownloadedModules(const std::string& json_path);
nlohmann::ordered_json SortDeepseaModules(const nlohmann::ordered_json& modules);
std::string GetRepoName(const std::string& repo);
public:
AmsTab_Regular(const nlohmann::ordered_json& nxlinks, const bool erista = true);
};
class AmsTab_Custom : public AmsTab
{
private:
nlohmann::ordered_json custom_packs;
void CreateLists();
void RegisterListItemAction(brls::ListItem* listItem) override;
void AddLinkCreator();
public:
AmsTab_Custom(const nlohmann::ordered_json& nxlinks, const bool erista = true);
};
class UnTogglableListItem : public brls::ToggleListItem
{
public:
UnTogglableListItem(const std::string& label, bool initialValue, std::string description = "", std::string onValue = "On", std::string offValue = "Off") : ToggleListItem(label, initialValue, description, onValue, offValue) {}
virtual bool onClick() override;
};

103
include/app_page.hpp Normal file
View File

@@ -0,0 +1,103 @@
#pragma once
#include <switch.h>
#include <algorithm>
#include <borealis.hpp>
#include <filesystem>
#include <json.hpp>
#include <set>
static constexpr uint32_t MaxTitleCount = 64000;
enum class appPageType
{
base,
cheatSlips,
gbatempCheats
};
class AppPage : public brls::AppletFrame
{
private:
brls::ListItem* download;
std::set<std::string> titles;
protected:
brls::List* list;
brls::Label* label;
brls::ListItem* listItem;
void CreateDownloadAllButton();
uint64_t GetCurrentApplicationId();
u32 InitControlData(NsApplicationControlData** controlData);
uint32_t GetControlData(u64 tid, NsApplicationControlData* controlData, u64& controlSize, std::string& name);
virtual void PopulatePage();
virtual void CreateLabel(){};
virtual void AddListItem(const std::string& name, uint64_t tid);
public:
AppPage();
};
class AppPage_Exclude : public AppPage
{
private:
std::set<std::pair<brls::ToggleListItem*, std::string>> items;
void PopulatePage() override;
void CreateLabel() override;
public:
AppPage_Exclude();
};
class AppPage_CheatSlips : public AppPage
{
private:
void CreateLabel() override;
void AddListItem(const std::string& name, uint64_t tid) override;
public:
AppPage_CheatSlips();
};
class AppPage_Gbatemp : public AppPage
{
private:
void CreateLabel() override;
void AddListItem(const std::string& name, uint64_t tid) override;
public:
AppPage_Gbatemp();
};
class AppPage_Gfx : public AppPage
{
private:
void CreateLabel() override;
void AddListItem(const std::string& name, uint64_t tid) override;
public:
AppPage_Gfx();
};
class AppPage_DownloadedCheats : public AppPage
{
private:
std::set<std::string> titles;
void CreateLabel() override;
void AddListItem(const std::string& name, uint64_t tid) override;
void GetExistingCheatsTids();
public:
AppPage_DownloadedCheats();
};
class AppPage_OutdatedTitles : public AppPage
{
private:
nlohmann::ordered_json versions;
void AddListItem(const std::string& name, uint64_t tid) override;
public:
AppPage_OutdatedTitles();
};

View File

@@ -0,0 +1,14 @@
#pragma once
#include <borealis.hpp>
class ChangelogPage : public brls::AppletFrame
{
private:
brls::List* list;
brls::ListItem* listItem;
public:
ChangelogPage();
void ShowChangelogContent(const std::string version, const std::string content);
};

14
include/cheats_page.hpp Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include <borealis.hpp>
class CheatsPage : public brls::AppletFrame
{
private:
brls::List* list;
brls::ListItem* item;
brls::StagedAppletFrame* stagedFrame;
public:
CheatsPage();
};

17
include/choice_page.hpp Normal file
View File

@@ -0,0 +1,17 @@
#pragma once
#include <borealis.hpp>
class ChoicePage : public brls::View
{
private:
brls::Button* yes = nullptr;
brls::Button* no = nullptr;
brls::Label* label = nullptr;
public:
ChoicePage(brls::StagedAppletFrame* frame, const std::string text);
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
brls::View* getDefaultFocus() override;
};

34
include/color_swapper.hpp Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#include <json.hpp>
#include <deque>
namespace JC {
int setColor(const std::vector<int>& colors);
int backupToJSON(nlohmann::ordered_json& profiles, const std::string& path);
std::deque<std::pair<std::string, std::vector<int>>> getProfiles(const std::string& path);
void changeJCColor(const std::vector<int>& values);
nlohmann::ordered_json backupProfile();
void backupJCColor(const std::string& path);
} // namespace JC
namespace PC {
int setColor(const std::vector<int>& colors);
int backupToJSON(nlohmann::ordered_json& profiles, const std::string& path);
std::deque<std::pair<std::string, std::vector<int>>> getProfiles(const std::string& path);
void changePCColor(const std::vector<int>& values);
nlohmann::ordered_json backupProfile();
void backupPCColor(const std::string& path);
} // namespace PC
namespace ColorSwapper {
int hexToBGR(const std::string& hex);
std::string BGRToHex(int v);
bool isHexaAnd3Bytes(const std::string& str);
} // namespace ColorSwapper

39
include/confirm_page.hpp Normal file
View File

@@ -0,0 +1,39 @@
#pragma once
#include <borealis.hpp>
#include <chrono>
class ConfirmPage : public brls::View
{
protected:
brls::Button* button = nullptr;
brls::Label* label = nullptr;
std::chrono::system_clock::time_point start = std::chrono::high_resolution_clock::now();
bool done = false;
public:
ConfirmPage(brls::StagedAppletFrame* frame, const std::string& text);
~ConfirmPage();
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
brls::View* getDefaultFocus() override;
};
class ConfirmPage_Done : public ConfirmPage
{
public:
ConfirmPage_Done(brls::StagedAppletFrame* frame, const std::string& text);
};
class ConfirmPage_AppUpdate : public ConfirmPage_Done
{
public:
ConfirmPage_AppUpdate(brls::StagedAppletFrame* frame, const std::string& text);
};
class ConfirmPage_AmsUpdate : public ConfirmPage_Done
{
public:
ConfirmPage_AmsUpdate(brls::StagedAppletFrame* frame, const std::string& text, bool erista = true);
};

131
include/constants.hpp Normal file
View File

@@ -0,0 +1,131 @@
#pragma once
constexpr const char ROOT_PATH[] = "/";
constexpr const char APP_PATH[] = "/switch/cheats-updater/";
constexpr const char NRO_PATH[] = "/switch/cheats-updater/cheats-updater.nro";
constexpr const char NRO_PATH_REGEX[] = ".*(/switch/.*cheats-updater.nro).*";
constexpr const char DOWNLOAD_PATH[] = "/config/cheats-updater/";
constexpr const char CONFIG_PATH[] = "/config/cheats-updater/";
constexpr const char CONFIG_FILE[] = "/config/cheats-updater/config.json";
constexpr const char CONFIG_PATH_UNZIP[] = "config\\cheats-updater";
constexpr const char RCM_PAYLOAD_PATH[] = "romfs:/aio_rcm.bin";
constexpr const char MARIKO_PAYLOAD_PATH[] = "/payload.bin";
constexpr const char MARIKO_PAYLOAD_PATH_TEMP[] = "/payload.bin.aio";
constexpr const char CHANGELOG_URL[] = "https://git.niklascfw.de/OmniNX/switch-cheats-db/releases";
constexpr const char APP_URL[] = "";
constexpr const char TAGS_INFO[] = "";
constexpr const char APP_FILENAME[] = "/config/cheats-updater/app.zip";
constexpr const char NXLINKS_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/nx-links.json";
constexpr const char CUSTOM_FILENAME[] = "/config/cheats-updater/custom.zip";
constexpr const char HEKATE_IPL_PATH[] = "/bootloader/hekate_ipl.ini";
constexpr const char FIRMWARE_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/firmwares.json";
constexpr const char FIRMWARE_FILENAME[] = "/config/cheats-updater/firmware.zip";
constexpr const char FIRMWARE_PATH[] = "/firmware/";
constexpr const char CFW_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/bootloaders.json";
constexpr const char BOOTLOADER_FILENAME[] = "/config/cheats-updater/bootloader.zip";
constexpr const char AMS_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/cfws.json";
constexpr const char SXOS_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/sxos.json";
constexpr const char AMS_FILENAME[] = "/config/cheats-updater/ams.zip";
constexpr const char HEKATE_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/hekate.json";
constexpr const char PAYLOAD_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/payloads.json";
constexpr const char DEEPSEA_META_JSON[] = "https://builder.teamneptune.net/meta.json";
constexpr const char DEEPSEA_BUILD_URL[] = "https://builder.teamneptune.net/build/";
constexpr const char DEEPSEA_PACKAGE_PATH[] = "/config/deepsea/customPackage.json";
constexpr const char CUSTOM_PACKS_PATH[] = "/config/cheats-updater/custom_packs.json";
constexpr const char CHEATS_URL_TITLES[] = "https://github.com/muxi1/switch-cheats-db/releases/latest/download/titles.zip";
constexpr const char CHEATS_URL_CONTENTS[] = "https://git.niklascfw.de/OmniNX/switch-cheats-db/releases/download/latest/contents.zip";
constexpr const char GFX_CHEATS_URL_TITLES[] = "https://github.com/HamletDuFromage/switch-cheats-db/releases/latest/download/titles_60fps-res-gfx.zip";
constexpr const char GFX_CHEATS_URL_CONTENTS[] = "https://github.com/HamletDuFromage/switch-cheats-db/releases/latest/download/contents_60fps-res-gfx.zip";
constexpr const char CHEATS_URL_VERSION[] = "https://git.niklascfw.de/OmniNX/switch-cheats-db/releases/download/latest/VERSION";
constexpr const char LOOKUP_TABLE_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/switch-cheats-db/master/versions.json";
constexpr const char LOOKUP_TABLE_CBOR[] = "https://github.com/HamletDuFromage/switch-cheats-db/raw/master/versions.cbor";
constexpr const char VERSIONS_DIRECTORY[] = "https://raw.githubusercontent.com/HamletDuFromage/switch-cheats-db/master/versions/";
constexpr const char CHEATS_DIRECTORY[] = "https://raw.githubusercontent.com/HamletDuFromage/switch-cheats-db/master/cheats/";
constexpr const char CHEATS_DIRECTORY_GBATEMP[] = "https://raw.githubusercontent.com/HamletDuFromage/switch-cheats-db/master/cheats_gbatemp/";
constexpr const char CHEATS_DIRECTORY_GFX[] = "https://raw.githubusercontent.com/HamletDuFromage/switch-cheats-db/master/cheats_gfx/";
constexpr const char CHEATSLIPS_CHEATS_URL[] = "https://www.cheatslips.com/api/v1/cheats/";
constexpr const char CHEATSLIPS_TOKEN_URL[] = "https://www.cheatslips.com/api/v1/token";
constexpr const char TOKEN_PATH[] = "/config/cheats-updater/token.json";
constexpr const char CHEATS_FILENAME[] = "/config/cheats-updater/cheats.zip";
constexpr const char CHEATS_EXCLUDE[] = "/config/cheats-updater/exclude.txt";
constexpr const char FILES_IGNORE[] = "/config/cheats-updater/preserve.txt";
constexpr const char INTERNET_JSON[] = "/config/cheats-updater/internet.json";
constexpr const char UPDATED_TITLES_PATH[] = "/config/cheats-updater/updated.dat";
constexpr const char CHEATS_VERSION[] = "/config/cheats-updater/cheats_version.dat";
constexpr const char AMS_CONTENTS[] = "/atmosphere/contents/";
constexpr const char REINX_CONTENTS[] = "/ReiNX/contents/";
constexpr const char SXOS_TITLES[] = "/sxos/titles/";
constexpr const char AMS_PATH[] = "/atmosphere/";
constexpr const char SXOS_PATH[] = "/sxos/";
constexpr const char REINX_PATH[] = "/ReiNX/";
constexpr const char CONTENTS_PATH[] = "contents/";
constexpr const char TITLES_PATH[] = "titles/";
constexpr const char COLOR_PICKER_URL[] = "https://git.io/jcpicker";
constexpr const char JC_COLOR_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/aio-switch-updater/master/jc_profiles.json";
constexpr const char JC_COLOR_PATH[] = "/config/cheats-updater/jc_profiles.json";
constexpr const char PC_COLOR_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/aio-switch-updater/master/pc_profiles.json";
constexpr const char PC_COLOR_PATH[] = "/config/cheats-updater/pc_profiles.json";
constexpr const char PAYLOAD_PATH[] = "/payloads/";
constexpr const char BOOTLOADER_PATH[] = "/bootloader/";
constexpr const char BOOTLOADER_PL_PATH[] = "/bootloader/payloads/";
constexpr const char UPDATE_BIN_PATH[] = "/bootloader/update.bin";
constexpr const char REBOOT_PAYLOAD_PATH[] = "/atmosphere/reboot_payload.bin";
constexpr const char FUSEE_SECONDARY[] = "/atmosphere/fusee-secondary.bin";
constexpr const char FUSEE_MTC[] = "/atmosphere/fusee-mtc.bin";
constexpr const char AMS_DIRECTORY_PATH[] = "/config/cheats-updater/atmosphere/";
constexpr const char SEPT_DIRECTORY_PATH[] = "/config/cheats-updater/sept/";
constexpr const char FW_DIRECTORY_PATH[] = "/firmware/";
constexpr const char HIDE_TABS_JSON[] = "/config/cheats-updater/hide_tabs.json";
constexpr const char COPY_FILES_TXT[] = "/config/cheats-updater/copy_files.txt";
constexpr const char LANGUAGE_JSON[] = "/config/cheats-updater/language.json";
constexpr const char HOMEBREW[] = "/config/cheats-updater/language.json";
constexpr const char ROMFS_PATH[] = "romfs:/";
constexpr const char ROMFS_FORWARDER[] = "romfs:/aiosu-forwarder.nro";
constexpr const char FORWARDER_PATH[] = "/config/cheats-updater/aiosu-forwarder.nro";
constexpr const char DAYBREAK_PATH[] = "/switch/daybreak.nro";
constexpr const char HIDDEN_AIO_FILE[] = "/config/cheats-updater/.cheats-updater";
constexpr const char LOCALISATION_FILE[] = "romfs:/i18n/{}/menus.json";
constexpr const int LISTITEM_HEIGHT = 50;
enum class contentType
{
custom,
cheats,
fw,
app,
bootloaders,
ams_cfw,
payloads,
hekate_ipl,
};
constexpr std::string_view contentTypeNames[8]{"custom", "cheats", "firmwares", "app", "bootloaders", "cfws", "payloads", "hekate_ipl"};
enum class CFW
{
rnx,
sxos,
ams,
};

13
include/current_cfw.hpp Normal file
View File

@@ -0,0 +1,13 @@
#pragma once
#include <string>
#include "constants.hpp"
namespace CurrentCfw {
CFW getCFW();
std::string getAmsInfo();
extern CFW running_cfw;
} // namespace CurrentCfw

61
include/dialogue_page.hpp Normal file
View File

@@ -0,0 +1,61 @@
#pragma once
#include <borealis.hpp>
#include <chrono>
class DialoguePage : public brls::View
{
private:
brls::NavigationMap navigationMap;
protected:
brls::Button* button1 = nullptr;
brls::Button* button2 = nullptr;
brls::Label* label = nullptr;
virtual void CreateView();
virtual void instantiateButtons(){};
public:
DialoguePage(){};
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
brls::View* getDefaultFocus() override;
brls::View* getNextFocus(brls::FocusDirection direction, brls::View* currentView);
};
class DialoguePage_fw : public DialoguePage
{
private:
void instantiateButtons() override;
std::string text;
brls::StagedAppletFrame* frame;
public:
DialoguePage_fw(brls::StagedAppletFrame* frame, const std::string& text) : DialoguePage(), text(text), frame(frame) { CreateView(); }
};
class DialoguePage_ams : public DialoguePage
{
private:
std::chrono::system_clock::time_point start = std::chrono::high_resolution_clock::now();
void instantiateButtons() override;
bool erista = true;
std::string text;
brls::StagedAppletFrame* frame;
public:
DialoguePage_ams(brls::StagedAppletFrame* frame, const std::string& text, bool erista = true) : DialoguePage(), erista(erista), text(text), frame(frame) { CreateView(); }
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
};
class DialoguePage_confirm : public DialoguePage
{
private:
void instantiateButtons() override;
std::string text;
brls::StagedAppletFrame* frame;
public:
DialoguePage_confirm(brls::StagedAppletFrame* frame, const std::string& text) : DialoguePage(), text(text), frame(frame) { CreateView(); }
};

18
include/download.hpp Normal file
View File

@@ -0,0 +1,18 @@
#pragma once
constexpr int ON = 1;
constexpr int OFF = 0;
#include <json.hpp>
namespace download {
long downloadFile(const std::string& url, std::vector<std::uint8_t>& res, const std::string& output = "", int api = OFF);
long downloadFile(const std::string& url, const std::string& output = "", int api = OFF);
std::vector<std::pair<std::string, std::string>> getLinks(const std::string& url);
std::vector<std::pair<std::string, std::string>> getLinksFromJson(const nlohmann::ordered_json& json_object);
std::string fetchTitle(const std::string& url);
long downloadPage(const std::string& url, std::string& res, const std::vector<std::string>& headers = {}, const std::string& body = "");
long getRequest(const std::string& url, nlohmann::ordered_json& res, const std::vector<std::string>& headers = {}, const std::string& body = "");
} // namespace download

View File

@@ -0,0 +1,98 @@
#pragma once
#include <switch.h>
#include <borealis.hpp>
#include <filesystem>
#include <json.hpp>
#include "constants.hpp"
namespace cheats_util {
u32 GetVersion(uint64_t title_id);
void ShowCheatFiles(uint64_t tid, const std::string& name);
void ShowCheatSheet(u64 tid, const std::string& bid, const std::string& name);
bool CreateCheatList(const std::filesystem::path& path, brls::List** cheatsList);
void DeleteCheats(u64 tid, const std::string& bid);
} // namespace cheats_util
class DownloadCheatsPage : public brls::AppletFrame
{
protected:
brls::List* list;
brls::Label* label;
brls::ListItem* del;
uint64_t tid = 0;
std::string bid = "";
std::string name;
u32 version = 0;
DownloadCheatsPage(uint64_t tid, const std::string& name);
void GetBuildID();
void GetBuildIDFromDmnt();
void GetBuildIDFromFile();
void WriteCheats(const std::string& cheatContent);
void AddCheatsfileListItem();
void ShowBidNotFound();
void ShowCheatsNotFound(const std::string& versionsWithCheats = "");
typedef struct
{
u64 base;
u64 size;
} DmntMemoryRegionExtents;
typedef struct
{
u64 process_id;
u64 title_id;
DmntMemoryRegionExtents main_nso_extents;
DmntMemoryRegionExtents heap_extents;
DmntMemoryRegionExtents alias_extents;
DmntMemoryRegionExtents address_space_extents;
u8 main_nso_build_id[0x20];
} DmntCheatProcessMetadata;
};
class DownloadCheatsPage_CheatSlips : public DownloadCheatsPage
{
private:
brls::ToggleListItem* listItem;
std::vector<std::pair<brls::ToggleListItem*, int>> toggles;
std::string GetCheatsTitle(nlohmann::ordered_json cheat);
void ShowCheatsContent(nlohmann::ordered_json titles);
public:
DownloadCheatsPage_CheatSlips(uint64_t tid, const std::string& name);
};
class DownloadCheatsPage_Github : public DownloadCheatsPage
{
private:
brls::ListItem* listItem;
public:
DownloadCheatsPage_Github(uint64_t tid, const std::string& name);
void PopulateList(uint64_t tid, const std::string& name);
protected:
virtual std::string get_url() { return CHEATS_DIRECTORY; }
};
class DownloadCheatsPage_Gbatemp : public DownloadCheatsPage_Github
{
public:
DownloadCheatsPage_Gbatemp(uint64_t tid, const std::string& name);
private:
std::string get_url() override { return CHEATS_DIRECTORY_GBATEMP; }
};
class DownloadCheatsPage_Gfx : public DownloadCheatsPage_Github
{
public:
DownloadCheatsPage_Gfx(uint64_t tid, const std::string& name);
private:
std::string get_url() override { return CHEATS_DIRECTORY_GFX; }
};

View File

@@ -0,0 +1,16 @@
#pragma once
#include <borealis.hpp>
#include <json.hpp>
class DownloadPayloadPage : public brls::AppletFrame
{
private:
brls::Label* label;
brls::Label* notFound;
brls::List* list;
brls::ListItem* listItem;
public:
DownloadPayloadPage(const nlohmann::ordered_json& payloads);
};

20
include/exclude_page.hpp Normal file
View File

@@ -0,0 +1,20 @@
#pragma once
#include <borealis.hpp>
#include <set>
#include "utils.hpp"
class ExcludePage : public brls::AppletFrame
{
private:
brls::List* list;
brls::Label* label;
brls::ListItem* save;
std::vector<util::app*> apps;
std::set<std::string> titles;
std::set<std::pair<brls::ToggleListItem*, std::string>> items;
public:
ExcludePage();
};

40
include/extract.hpp Normal file
View File

@@ -0,0 +1,40 @@
#pragma once
#include <switch.h>
#include <functional>
#include <set>
#include <string>
#include <vector>
#include "constants.hpp"
namespace extract {
static constexpr u32 MaxTitleCount = 64000;
typedef struct Title
{
std::string id;
std::string name;
bool operator==(const Title& x) const
{
return id == x.id;
}
bool operator<(const Title& x) const
{
return id < x.id;
}
} Title;
void extract(
const std::string& filename, const std::string& workingPath = ROOT_PATH, bool preserveInis = false, std::function<void()> func = []() { return; });
std::vector<std::string> getInstalledTitlesNs();
std::vector<std::string> excludeTitles(const std::string& path, const std::vector<std::string>& listedTitles);
void writeTitlesToFile(const std::set<std::string>& titles, const std::string& path);
void extractCheats(const std::string& archivePath, const std::vector<std::string>& titles, CFW cfw, const std::string& version, bool extractAll = false);
void extractAllCheats(const std::string& archivePath, CFW cfw, const std::string& version);
void removeCheats();
void removeOrphanedCheats();
bool removeCheatsDirectory(const std::string& entry);
bool isBID(const std::string& bid);
} // namespace extract

18
include/fs.hpp Normal file
View File

@@ -0,0 +1,18 @@
#pragma once
#include <switch.h>
#include <json.hpp>
#include <set>
namespace fs {
std::vector<std::string> splitString(const std::string& s, char delimiter);
bool removeDir(const std::string& path);
nlohmann::ordered_json parseJsonFile(const std::string& path);
void writeJsonToFile(nlohmann::ordered_json& data, const std::string& path);
bool copyFile(const std::string& from, const std::string& to);
std::string copyFiles(const std::string& path);
void createTree(std::string path);
std::set<std::string> readLineByLine(const std::string& path);
Result getFreeStorageSD(s64& free);
} // namespace fs

View File

@@ -0,0 +1,29 @@
#pragma once
#include <borealis.hpp>
class HideTabsPage : public brls::AppletFrame
{
private:
brls::List* list;
brls::Label* label;
brls::ToggleListItem* about;
brls::ToggleListItem* ams;
brls::ToggleListItem* cfws;
brls::ToggleListItem* fws;
brls::ToggleListItem* cheats;
brls::ToggleListItem* custom;
brls::ToggleListItem* outdatedTitles;
brls::ToggleListItem* jccolor;
brls::ToggleListItem* pccolor;
brls::ToggleListItem* downloadpayload;
brls::ToggleListItem* rebootpayload;
brls::ToggleListItem* netsettings;
brls::ToggleListItem* browser;
brls::ToggleListItem* move;
brls::ToggleListItem* cleanup;
brls::ToggleListItem* language;
public:
HideTabsPage();
};

View File

@@ -0,0 +1,27 @@
#pragma once
#include <borealis.hpp>
#include <json.hpp>
#include "constants.hpp"
class ListDownloadTab : public brls::List
{
private:
brls::ListItem* listItem;
nlohmann::ordered_json nxlinks;
std::string currentCheatsVer = "";
std::string newCheatsVer = "";
contentType type;
void createList();
void createList(contentType type);
void createCheatSlipItem();
void createGbatempItem();
void createGfxItem();
void setDescription();
void setDescription(contentType type);
void displayNotFound();
public:
ListDownloadTab(const contentType type, const nlohmann::ordered_json& nxlinks = nlohmann::ordered_json::object());
};

12
include/main_frame.hpp Normal file
View File

@@ -0,0 +1,12 @@
#pragma once
#include <borealis.hpp>
class MainFrame : public brls::TabFrame
{
private:
//RefreshTask *refreshTask;
public:
MainFrame();
};

19
include/net_page.hpp Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include <borealis.hpp>
constexpr int AF_INET = 2;
class NetPage : public brls::AppletFrame
{
private:
brls::List* list;
brls::Label* label;
brls::ListItem* listItem;
brls::ListItem* cancel;
public:
NetPage();
std::string ipToString(unsigned char* ip);
int stringToIp(const std::string& ip, unsigned char* out);
};

5
include/ntcp.hpp.meh Normal file
View File

@@ -0,0 +1,5 @@
#pragma once
#include <string>
std::string syncTime();

17
include/payload_page.hpp Normal file
View File

@@ -0,0 +1,17 @@
#pragma once
#include <borealis.hpp>
class PayloadPage : public brls::AppletFrame
{
private:
brls::Label* label;
brls::List* list;
brls::ListItem* listItem;
brls::ListItem* reboot;
brls::ListItem* shutDown;
void RegisterCopyAction(brls::Key key, const std::string& payload_path, const std::string& payload_dest, const std::string& action_name);
public:
PayloadPage();
};

View File

@@ -0,0 +1,54 @@
#pragma once
class ProgressEvent
{
private:
ProgressEvent() {}
int _current = 0;
int _max = 60;
double _now = 0;
double _total = 0;
double _speed = 0;
long _status_code = 0;
bool _interupt = false;
public:
ProgressEvent(const ProgressEvent&) = delete;
ProgressEvent& operator=(const ProgressEvent&) = delete;
ProgressEvent(ProgressEvent&&) = delete;
ProgressEvent& operator=(ProgressEvent&&) = delete;
static auto& instance()
{
static ProgressEvent event;
return event;
}
void reset()
{
_current = 0;
_max = 60;
_now = 0;
_total = 0;
_speed = 0;
_status_code = 0;
_interupt = false;
}
inline void setTotalSteps(int steps) { _max = steps; }
inline void setTotalCount(double total) { _total = total; }
inline void setSpeed(double speed) { _speed = speed; }
inline void setStep(int step) { _current = step; }
inline void setStatusCode(long status_code) { _status_code = status_code; }
inline void incrementStep(int increment) { _current += increment; }
inline void setNow(double now) { _now = now; }
inline int getStep() { return _current; }
inline double getNow() { return _now; }
inline bool finished() { return (_current == _max); }
inline int getMax() { return _max; }
inline double getTotal() { return _total; }
inline double getSpeed() { return _speed; }
inline double getStatusCode() { return _status_code; }
inline void setInterupt(bool interupt) { _interupt = interupt; }
inline bool getInterupt() { return _interupt; }
};

19
include/reboot_payload.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef __REBOOT_PAYLOAD_H__
#define __REBOOT_PAYLOAD_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <switch.h>
int reboot_to_payload(const char* path, bool legacy);
#ifdef __cplusplus
}
#endif
#endif

57
include/service_guard.h Normal file
View File

@@ -0,0 +1,57 @@
#pragma once
#include <switch/kernel/mutex.h>
#include <switch/result.h>
#include <switch/services/sm.h>
#include <switch/sf/service.h>
#include <switch/types.h>
typedef struct ServiceGuard
{
Mutex mutex;
u32 refCount;
} ServiceGuard;
NX_INLINE bool serviceGuardBeginInit(ServiceGuard* g)
{
mutexLock(&g->mutex);
return (g->refCount++) == 0;
}
NX_INLINE Result serviceGuardEndInit(ServiceGuard* g, Result rc, void (*cleanupFunc)(void))
{
if (R_FAILED(rc)) {
cleanupFunc();
--g->refCount;
}
mutexUnlock(&g->mutex);
return rc;
}
NX_INLINE void serviceGuardExit(ServiceGuard* g, void (*cleanupFunc)(void))
{
mutexLock(&g->mutex);
if (g->refCount && (--g->refCount) == 0)
cleanupFunc();
mutexUnlock(&g->mutex);
}
#define NX_GENERATE_SERVICE_GUARD_PARAMS(name, _paramdecl, _parampass) \
\
static ServiceGuard g_##name##Guard; \
NX_INLINE Result _##name##Initialize _paramdecl; \
static void _##name##Cleanup(void); \
\
Result name##Initialize _paramdecl \
{ \
Result rc = 0; \
if (serviceGuardBeginInit(&g_##name##Guard)) \
rc = _##name##Initialize _parampass; \
return serviceGuardEndInit(&g_##name##Guard, rc, _##name##Cleanup); \
} \
\
void name##Exit(void) \
{ \
serviceGuardExit(&g_##name##Guard, _##name##Cleanup); \
}
#define NX_GENERATE_SERVICE_GUARD(name) NX_GENERATE_SERVICE_GUARD_PARAMS(name, (void), ())

14
include/tools_tab.hpp Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include <borealis.hpp>
#include <json.hpp>
//#include "ntcp.hpp"
class ToolsTab : public brls::List
{
private:
brls::StagedAppletFrame* stagedFrame;
public:
ToolsTab(const std::string& tag, const nlohmann::ordered_json& payloads, bool erista = true, const nlohmann::ordered_json& hideStatus = {});
};

55
include/utils.hpp Normal file
View File

@@ -0,0 +1,55 @@
#pragma once
#include <switch.h>
#include <borealis.hpp>
#include <json.hpp>
#include <regex>
#include <set>
#include "constants.hpp"
namespace util {
typedef char NsApplicationName[0x201];
typedef uint8_t NsApplicationIcon[0x20000];
typedef struct
{
uint64_t tid;
NsApplicationName name;
NsApplicationIcon icon;
brls::ListItem* listItem;
} app;
void clearConsole();
bool isArchive(const std::string& path);
void downloadArchive(const std::string& url, contentType type);
void downloadArchive(const std::string& url, contentType type, long& status_code);
void extractArchive(contentType type, const std::string& version = "");
std::string formatListItemTitle(const std::string& str, size_t maxScore = 140);
std::string formatApplicationId(u64 ApplicationId);
std::vector<std::string> fetchPayloads();
void shutDown(bool reboot = false);
void rebootToPayload(const std::string& path);
void showDialogBoxInfo(const std::string& text);
int showDialogBoxBlocking(const std::string& text, const std::string& opt);
int showDialogBoxBlocking(const std::string& text, const std::string& opt1, const std::string& opt2);
std::string getLatestTag(const std::string& url);
std::string downloadFileToString(const std::string& url);
std::string getCheatsVersion();
void saveToFile(const std::string& text, const std::string& path);
std::string readFile(const std::string& path);
std::string getAppPath();
void restartApp();
bool isErista();
void removeSysmodulesFlags(const std::string& directory);
std::string lowerCase(const std::string& str);
std::string upperCase(const std::string& str);
std::string getErrorMessage(long status_code);
bool isApplet();
std::string getContentsPath();
bool getBoolValue(const nlohmann::ordered_json& jsonFile, const std::string& key);
const nlohmann::ordered_json getValueFromKey(const nlohmann::ordered_json& jsonFile, const std::string& key);
int openWebBrowser(const std::string url);
} // namespace util

20
include/warning_page.hpp Normal file
View File

@@ -0,0 +1,20 @@
#pragma once
#include <borealis.hpp>
#include <chrono>
class WarningPage : public brls::View
{
private:
brls::Button* button = nullptr;
brls::Label* label = nullptr;
std::chrono::system_clock::time_point start = std::chrono::high_resolution_clock::now();
public:
WarningPage(const std::string& text);
~WarningPage();
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
brls::View* getDefaultFocus() override;
};

30
include/worker_page.hpp Normal file
View File

@@ -0,0 +1,30 @@
#pragma once
#include <borealis.hpp>
#include <thread>
typedef std::function<void()> worker_func_t;
class WorkerPage : public brls::View
{
private:
brls::ProgressDisplay* progressDisp = nullptr;
brls::StagedAppletFrame* frame;
brls::Button* button;
brls::Label* label;
std::string text;
int progressValue = 0;
bool workStarted = false;
bool draw_page = true;
std::thread* workerThread;
worker_func_t workerFunc;
public:
WorkerPage(brls::StagedAppletFrame* frame, const std::string& text, worker_func_t worker_func);
~WorkerPage();
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
void doWork();
brls::View* getDefaultFocus() override;
};