Skip to content

Commit

Permalink
mariko "support"
Browse files Browse the repository at this point in the history
  • Loading branch information
HookedBehemoth committed Mar 9, 2021
1 parent 8023899 commit 7fefe94
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 11 deletions.
30 changes: 22 additions & 8 deletions applet/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "hekate.hpp"
#include <hekate.hpp>
#include <util.hpp>

#include <cstdio>
#include <cstdlib>
Expand Down Expand Up @@ -54,17 +55,30 @@ extern "C" void userAppExit(void) {
}

int main(int argc, char **argv) {
auto config_list = Hekate::LoadBootConfigList();
std::vector<TuiItem> 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;

Expand Down
31 changes: 31 additions & 0 deletions common/util.cpp
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "util.hpp"

#include <switch.h>

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 */;
}

}
22 changes: 22 additions & 0 deletions common/util.hpp
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once

namespace util {

bool IsErista();

}
34 changes: 31 additions & 3 deletions overlay/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define TESLA_INIT_IMPL
#include "hekate.hpp"
#include <hekate.hpp>
#include <util.hpp>

#include <tesla.hpp>

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;
Expand All @@ -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();

Expand Down Expand Up @@ -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 {
Expand All @@ -73,7 +97,11 @@ class PancakeOverlay : public tsl::Overlay {
}

virtual std::unique_ptr<tsl::Gui> loadInitialGui() override {
return std::make_unique<PancakeGui>();
if (util::IsErista()) {
return std::make_unique<PancakeGui>();
} else {
return std::make_unique<MarikoMenu>();
}
}
};

Expand Down

0 comments on commit 7fefe94

Please sign in to comment.