Skip to content

Commit f1b7766

Browse files
ask to update on <1.6.0 mariko
1 parent 0e476eb commit f1b7766

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

applet/main.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,32 @@ extern "C" void userAppExit(void) {
7070
}
7171

7272
int main(int const argc, char const *argv[]) {
73+
if (!util::IsErista() && !util::SupportsMarikoRebootToConfig()) {
74+
consoleInit(nullptr);
75+
76+
printf("Update to at least Atmosphère 1.6.1\n");
77+
78+
consoleUpdate(nullptr);
79+
80+
/* Configure input */
81+
padConfigureInput(8, HidNpadStyleSet_NpadStandard);
82+
83+
/* Initialize pad */
84+
PadState pad;
85+
padInitializeAny(&pad);
86+
87+
while (appletMainLoop()) {
88+
/* Update padstate */
89+
padUpdate(&pad);
90+
91+
if (padGetButtonsDown(&pad))
92+
break;
93+
}
94+
95+
consoleExit(nullptr);
96+
return 0;
97+
}
98+
7399
std::vector<TuiItem> items;
74100

75101
/* Load available boot configs */

common/util.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,48 @@
1717

1818
#include <switch.h>
1919

20+
#include <optional>
21+
#include <cstdio>
22+
2023
namespace util {
2124

2225
bool IsErista() {
23-
u64 type=0;
26+
static std::optional<bool> impl;
27+
28+
if (impl.has_value())
29+
return *impl;
30+
31+
u64 type = 0;
2432

2533
if (R_FAILED(splGetConfig(SplConfigItem_HardwareType, &type)))
2634
return false;
2735

28-
return type == 0 /* SplHardwareType_Icosa */ || type == 1 /* SplHardwareType_Copper */;
36+
impl = (type == 0 /* SplHardwareType_Icosa */ || type == 1 /* SplHardwareType_Copper */);
37+
38+
return *impl;
39+
}
40+
41+
/**
42+
* Since 1.6.0, Atmosphère bpc-mitm overwrites the reboot on mariko to prevent clearing
43+
* Timers. We are using those timing registers to communicate with hekate.
44+
*/
45+
bool SupportsMarikoRebootToConfig() {
46+
static std::optional<bool> impl;
47+
48+
if (impl.has_value())
49+
return *impl;
50+
51+
u64 version = 0;
52+
53+
if (R_FAILED(splGetConfig(static_cast<SplConfigItem>(65000), &version)))
54+
return false;
55+
56+
const u32 version_minor = (version >> 48) & 0xff;
57+
const u32 version_major = (version >> 56) & 0xff;
58+
59+
impl = (version_major >= 1 && version_minor >= 6);
60+
61+
return *impl;
2962
}
3063

3164
}

common/util.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ namespace util {
1919

2020
bool IsErista();
2121

22+
bool SupportsMarikoRebootToConfig();
23+
2224
}

overlay/main.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,25 @@ class PancakeGui : public tsl::Gui {
101101
}
102102
};
103103

104+
class PleaseUpdateGui final : public tsl::Gui {
105+
virtual tsl::elm::Element *createUI() override {
106+
auto const frame = new tsl::elm::OverlayFrame(AppTitle, AppVersion);
107+
108+
auto const custom = new tsl::elm::CustomDrawer([msgW = 0, msgH = 0](tsl::gfx::Renderer *drawer, u16 x, u16 y, u16 w, u16 h) mutable {
109+
drawer->drawString("\uE150", false, x + (w / 2) - (90 / 2), 300, 90, 0xffff);
110+
auto [width, height] = drawer->drawString("Update to at least\nAtmosphère 1.6.1", false, x + (w / 2) - (msgW / 2), 380, 25, 0xffff);
111+
if (msgW == 0) {
112+
msgW = width;
113+
msgH = height;
114+
}
115+
});
116+
117+
frame->setContent(custom);
118+
119+
return frame;
120+
}
121+
};
122+
104123
class PancakeOverlay final : public tsl::Overlay {
105124
public:
106125
virtual void initServices() override {
@@ -118,7 +137,11 @@ class PancakeOverlay final : public tsl::Overlay {
118137
}
119138

120139
virtual std::unique_ptr<tsl::Gui> loadInitialGui() override {
121-
return std::make_unique<PancakeGui>();
140+
if (!util::IsErista() && !util::SupportsMarikoRebootToConfig()) {
141+
return std::make_unique<PleaseUpdateGui>();
142+
} else {
143+
return std::make_unique<PancakeGui>();
144+
}
122145
}
123146
};
124147

0 commit comments

Comments
 (0)