disable sleep whilst downloading, uploading, using usb, inside ftp menu.

This commit is contained in:
ITotalJustice
2025-05-20 23:33:51 +01:00
parent cf908d63b9
commit a67171e2b8
7 changed files with 42 additions and 3 deletions

View File

@@ -165,6 +165,26 @@ public:
return (paths.unk[0] != '\0') || (paths.nintendo[0] != '\0');
}
static void SetAutoSleepDisabled(bool enable) {
static Mutex mutex{};
static int ref_count{};
mutexLock(&mutex);
ON_SCOPE_EXIT(mutexUnlock(&mutex));
if (enable) {
appletSetAutoSleepDisabled(true);
ref_count++;
} else {
if (ref_count) {
ref_count--;
}
if (!ref_count) {
appletSetAutoSleepDisabled(false);
}
}
}
// private:
static constexpr inline auto CONFIG_PATH = "/config/sphaira/config.ini";