From 7fefe94a88a270cc194a5128b038ab25744b7703 Mon Sep 17 00:00:00 2001 From: Luis Scheurenbrand Date: Tue, 9 Mar 2021 20:19:57 +0100 Subject: [PATCH] mariko "support" --- applet/main.cpp | 30 ++++++++++++++++++++++-------- common/util.cpp | 31 +++++++++++++++++++++++++++++++ common/util.hpp | 22 ++++++++++++++++++++++ overlay/main.cpp | 34 +++++++++++++++++++++++++++++++--- 4 files changed, 106 insertions(+), 11 deletions(-) create mode 100644 common/util.cpp create mode 100644 common/util.hpp diff --git a/applet/main.cpp b/applet/main.cpp index 1fbd73c9..5c2cd9d8 100644 --- a/applet/main.cpp +++ b/applet/main.cpp @@ -13,7 +13,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "hekate.hpp" +#include +#include #include #include @@ -54,17 +55,30 @@ extern "C" void userAppExit(void) { } int main(int argc, char **argv) { - auto config_list = Hekate::LoadBootConfigList(); std::vector items; - items.reserve(config_list.size() + 3); + /* Build menu item list */ + if (util::IsErista()) { + /* Load available boot configs */ + auto config_list = Hekate::LoadBootConfigList(); - items.emplace_back("Configs", nullptr, nullptr, false); - for (auto &entry : config_list) - items.emplace_back(entry.name, ConfigCallback, &entry, true); + /* TODO: Load available ini configs */ - items.emplace_back("Miscellaneous", nullptr, nullptr, false); - items.emplace_back("Reboot to UMS", UmsCallback, nullptr, true); + items.reserve(config_list.size() + 4); + + items.emplace_back("Configs", nullptr, nullptr, false); + for (auto &entry : config_list) + items.emplace_back(entry.name, ConfigCallback, &entry, true); + + items.emplace_back("Miscellaneous", nullptr, nullptr, false); + items.emplace_back("Reboot to UMS", UmsCallback, nullptr, true); + } else { + items.reserve(2); + + items.emplace_back("Mariko consoles unsupported", nullptr, nullptr, false); + } + + items.emplace_back("Exit", nullptr, nullptr, true); std::size_t index = 0; diff --git a/common/util.cpp b/common/util.cpp new file mode 100644 index 00000000..71affa00 --- /dev/null +++ b/common/util.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020-2021 Studious Pancake + * + * 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 . + */ +#include "util.hpp" + +#include + +namespace util { + + bool IsErista() { + u64 type=0; + + if (R_FAILED(splGetConfig(SplConfigItem_HardwareType, &type))) + return false; + + return type == 0 /* SplHardwareType_Icosa */ || type == 1 /* SplHardwareType_Copper */; + } + +} diff --git a/common/util.hpp b/common/util.hpp new file mode 100644 index 00000000..cd430844 --- /dev/null +++ b/common/util.hpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020-2021 Studious Pancake + * + * 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 . + */ +#pragma once + +namespace util { + + bool IsErista(); + +} diff --git a/overlay/main.cpp b/overlay/main.cpp index 2237ea3c..ca741ad2 100644 --- a/overlay/main.cpp +++ b/overlay/main.cpp @@ -14,10 +14,18 @@ * along with this program. If not, see . */ #define TESLA_INIT_IMPL -#include "hekate.hpp" +#include +#include #include +namespace { + + constexpr const char AppTitle[] = "Studius Pancake"; + constexpr const char AppVersion[] = "0.2.0"; + +} + class PancakeGui : public tsl::Gui { private: Hekate::BootConfigList const config_list; @@ -28,7 +36,7 @@ class PancakeGui : public tsl::Gui { } virtual tsl::elm::Element *createUI() override { - auto frame = new tsl::elm::OverlayFrame("Studious Pancake", "v0.1.0"); + auto frame = new tsl::elm::OverlayFrame(AppTitle, AppVersion); auto list = new tsl::elm::List(); @@ -60,6 +68,22 @@ class PancakeGui : public tsl::Gui { } }; +class MarikoMenu : public tsl::Gui { + public: + virtual tsl::elm::Element *createUI() override { + auto frame = new tsl::elm::OverlayFrame(AppTitle, AppVersion); + + /* Display incompatibility error */ + auto drawer = new tsl::elm::CustomDrawer([](tsl::gfx::Renderer* r, s32 x, s32 y, s32 w, s32 h) { + r->drawString("\uE150", false, x + (w / 2) - (90 / 2), 300, 90, 0xffff); + r->drawString("Mariko consoles unsupported", false, x, 380, 25, 0xffff); + }); + + frame->setContent(drawer); + return frame; + } +}; + class PancakeOverlay : public tsl::Overlay { public: virtual void initServices() override { @@ -73,7 +97,11 @@ class PancakeOverlay : public tsl::Overlay { } virtual std::unique_ptr loadInitialGui() override { - return std::make_unique(); + if (util::IsErista()) { + return std::make_unique(); + } else { + return std::make_unique(); + } } };