mirror of
https://github.com/wiiu-env/AromaBasePlugin.git
synced 2024-11-27 05:54:17 +01:00
WUPS 0.8.0 support
This commit is contained in:
parent
f96f82e2c0
commit
85288e1bf5
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ sysapp.cbp
|
|||||||
.idea/
|
.idea/
|
||||||
cmake-build-debug/
|
cmake-build-debug/
|
||||||
CMakeLists.txt
|
CMakeLists.txt
|
||||||
|
*.zip
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
FROM ghcr.io/wiiu-env/devkitppc:20230621
|
FROM ghcr.io/wiiu-env/devkitppc:20231112
|
||||||
|
|
||||||
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230719 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:0.8.0-dev-20231221-ca17105 /artifacts $DEVKITPRO
|
||||||
COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO
|
||||||
COPY --from=ghcr.io/wiiu-env/librpxloader:20230621 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/librpxloader:20230621 /artifacts $DEVKITPRO
|
||||||
COPY --from=ghcr.io/wiiu-env/libcurlwrapper:20230715 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/libcurlwrapper:20230715 /artifacts $DEVKITPRO
|
||||||
|
@ -5,11 +5,15 @@
|
|||||||
#include <notifications/notification_defines.h>
|
#include <notifications/notification_defines.h>
|
||||||
#include <notifications/notifications.h>
|
#include <notifications/notifications.h>
|
||||||
#include <sdutils/sdutils.h>
|
#include <sdutils/sdutils.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
std::unique_ptr<std::thread> sShowHintThread;
|
std::unique_ptr<std::thread> sShowHintThread;
|
||||||
static bool sShutdownHintThread = false;
|
static bool sShutdownHintThread = false;
|
||||||
|
|
||||||
|
bool SaveHintShownToStorage(bool hintShown);
|
||||||
|
|
||||||
void ShowHints() {
|
void ShowHints() {
|
||||||
bool isOverlayReady = false;
|
bool isOverlayReady = false;
|
||||||
while (!sShutdownHintThread &&
|
while (!sShutdownHintThread &&
|
||||||
@ -50,20 +54,31 @@ void ShowHints() {
|
|||||||
NotificationModuleStatus err;
|
NotificationModuleStatus err;
|
||||||
if ((err = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 15.0f)) == NOTIFICATION_MODULE_RESULT_SUCCESS &&
|
if ((err = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 15.0f)) == NOTIFICATION_MODULE_RESULT_SUCCESS &&
|
||||||
(err = NotificationModule_AddInfoNotification("Tip: You can open a configuration menu by pressing \ue052 + \ue07A + \ue046")) == NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
(err = NotificationModule_AddInfoNotification("Tip: You can open a configuration menu by pressing \ue052 + \ue07A + \ue046")) == NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
||||||
if (WUPS_OpenStorage() == WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
gConfigMenuHintShown = true;
|
gConfigMenuHintShown = true;
|
||||||
wups_storage_item_t *cat_other = nullptr;
|
SaveHintShownToStorage(gConfigMenuHintShown);
|
||||||
if (WUPS_GetSubItem(nullptr, CAT_OTHER, &cat_other) == WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
WUPS_StoreInt(cat_other, CONFIG_MENU_HINT_SHOWN_ID, gConfigMenuHintShown);
|
|
||||||
}
|
|
||||||
WUPS_CloseStorage();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to show Notification: %d %s", err, NotificationModule_GetStatusStr(err));
|
DEBUG_FUNCTION_LINE_ERR("Failed to show Notification: %d %s", err, NotificationModule_GetStatusStr(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SaveHintShownToStorage(bool hintShown) {
|
||||||
|
WUPSStorageError storageError;
|
||||||
|
auto subItem = WUPSStorageAPI::GetSubItem(CAT_OTHER, storageError);
|
||||||
|
if (!subItem) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get sub category");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
storageError = subItem->Store(CONFIG_MENU_HINT_SHOWN_ID, hintShown);
|
||||||
|
if (storageError != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to store hint shown");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return WUPSStorageAPI::SaveStorage() == WUPS_STORAGE_ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
void StartHintThread() {
|
void StartHintThread() {
|
||||||
sShowHintThread.reset();
|
sShowHintThread.reset();
|
||||||
sShutdownHintThread = false;
|
sShutdownHintThread = false;
|
||||||
|
@ -11,14 +11,17 @@
|
|||||||
#include <padscore/wpad.h>
|
#include <padscore/wpad.h>
|
||||||
#include <rpxloader/rpxloader.h>
|
#include <rpxloader/rpxloader.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vpad/input.h>
|
#include <vpad/input.h>
|
||||||
|
#include <wups/function_patching.h>
|
||||||
|
|
||||||
static NotificationModuleHandle sAromaUpdateHandle = 0;
|
static NotificationModuleHandle sAromaUpdateHandle = 0;
|
||||||
std::unique_ptr<std::thread> sCheckUpdateThread;
|
std::unique_ptr<std::thread> sCheckUpdateThread;
|
||||||
static bool sShutdownUpdateThread = false;
|
static bool sShutdownUpdateThread = false;
|
||||||
void UpdateCheckThreadEntry();
|
void UpdateCheckThreadEntry();
|
||||||
|
|
||||||
|
void ShowUpdateNotification();
|
||||||
constexpr uint32_t HIDE_UPDATE_WARNING_VPAD_COMBO = VPAD_BUTTON_MINUS;
|
constexpr uint32_t HIDE_UPDATE_WARNING_VPAD_COMBO = VPAD_BUTTON_MINUS;
|
||||||
constexpr uint32_t LAUNCH_AROMA_UPDATER_VPAD_COMBO = VPAD_BUTTON_PLUS;
|
constexpr uint32_t LAUNCH_AROMA_UPDATER_VPAD_COMBO = VPAD_BUTTON_PLUS;
|
||||||
constexpr uint32_t sHoldForFramesTarget = 60;
|
constexpr uint32_t sHoldForFramesTarget = 60;
|
||||||
@ -41,6 +44,26 @@ void StopUpdaterCheckThread() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool saveLatestUpdateHash(const std::string &hash) {
|
||||||
|
WUPSStorageError err;
|
||||||
|
auto subItem = WUPSStorageAPI::GetSubItem(CAT_OTHER, err);
|
||||||
|
if (!subItem) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get sub category");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (subItem->Store(LAST_UPDATE_HASH_ID, hash) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to store latest update hash");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to save strorage");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateCheckThreadEntry() {
|
void UpdateCheckThreadEntry() {
|
||||||
bool isOverlayReady = false;
|
bool isOverlayReady = false;
|
||||||
while (!sShutdownUpdateThread &&
|
while (!sShutdownUpdateThread &&
|
||||||
@ -57,45 +80,46 @@ void UpdateCheckThreadEntry() {
|
|||||||
std::string errorTextOut;
|
std::string errorTextOut;
|
||||||
float progress;
|
float progress;
|
||||||
|
|
||||||
if (DownloadUtils::DownloadFileToBuffer(AROMA_UPDATER_LAST_UPDATE_URL, outBuffer, responseCodeOut, errorOut, errorTextOut, &progress) == 0) {
|
if (DownloadUtils::DownloadFileToBuffer(AROMA_UPDATER_LAST_UPDATE_URL, outBuffer, responseCodeOut, errorOut, errorTextOut, &progress) != 0) {
|
||||||
try {
|
DEBUG_FUNCTION_LINE_INFO("Download failed: %d %s", errorOut, errorTextOut.c_str());
|
||||||
AromaUpdater::LatestVersion data = nlohmann::json::parse(outBuffer);
|
return;
|
||||||
gUpdateChecked = true;
|
}
|
||||||
if (gLastHash.empty()) { // don't show update warning on first boot
|
try {
|
||||||
gLastHash = data.getHash();
|
AromaUpdater::LatestVersion data = nlohmann::json::parse(outBuffer);
|
||||||
} else if (gLastHash != data.getHash()) {
|
gUpdateChecked = true;
|
||||||
struct stat st {};
|
|
||||||
if (stat(AROMA_UPDATER_PATH_FULL, &st) >= 0 && S_ISREG(st.st_mode)) {
|
|
||||||
NotificationModuleStatus err;
|
|
||||||
if ((err = NotificationModule_AddDynamicNotification("A new Aroma Update is available. "
|
|
||||||
"Hold \ue045 to launch the Aroma Updater, press \ue046 to hide this message",
|
|
||||||
&sAromaUpdateHandle)) != NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to add update notification. %s", NotificationModule_GetStatusStr(err));
|
|
||||||
sAromaUpdateHandle = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 15.0f);
|
|
||||||
NotificationModule_AddInfoNotification("A new Aroma Update is available. Please launch the Aroma Updater!");
|
|
||||||
}
|
|
||||||
|
|
||||||
gLastHash = data.getHash();
|
if (gLastHash == data.getHash()) {
|
||||||
} else {
|
DEBUG_FUNCTION_LINE_VERBOSE("We don't need to update the hash");
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("We don't need to update the hash");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (WUPS_OpenStorage() == WUPS_STORAGE_ERROR_SUCCESS) {
|
// Update hash
|
||||||
wups_storage_item_t *cat_other = nullptr;
|
gLastHash = data.getHash();
|
||||||
if (WUPS_GetSubItem(nullptr, CAT_OTHER, &cat_other) == WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
WUPS_StoreString(cat_other, LAST_UPDATE_HASH_ID, gLastHash.c_str());
|
if (!gLastHash.empty()) { // don't show update warning on first boot
|
||||||
}
|
ShowUpdateNotification();
|
||||||
WUPS_CloseStorage();
|
}
|
||||||
}
|
|
||||||
} catch (std::exception &e) {
|
saveLatestUpdateHash(gLastHash);
|
||||||
DEBUG_FUNCTION_LINE_WARN("Failed to parse AromaUpdater::LatestVersion");
|
} catch (std::exception &e) {
|
||||||
|
DEBUG_FUNCTION_LINE_WARN("Failed to parse AromaUpdater::LatestVersion");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowUpdateNotification() {
|
||||||
|
struct stat st {};
|
||||||
|
// Check if the Aroma Updater is on the sd card
|
||||||
|
if (stat(AROMA_UPDATER_PATH_FULL, &st) >= 0 && S_ISREG(st.st_mode)) {
|
||||||
|
NotificationModuleStatus err;
|
||||||
|
if ((err = NotificationModule_AddDynamicNotification("A new Aroma Update is available. "
|
||||||
|
"Hold \ue045 to launch the Aroma Updater, press \ue046 to hide this message",
|
||||||
|
&sAromaUpdateHandle)) != NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to add update notification. %s", NotificationModule_GetStatusStr(err));
|
||||||
|
sAromaUpdateHandle = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE_INFO("Download failed: %d %s", errorOut, errorTextOut.c_str());
|
NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 15.0f);
|
||||||
|
NotificationModule_AddInfoNotification("A new Aroma Update is available. Please launch the Aroma Updater!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,6 +182,7 @@ DECL_FUNCTION(int32_t, VPADRead, VPADChan chan,
|
|||||||
|
|
||||||
static uint32_t sWPADLastButtonHold[4] = {0, 0, 0, 0};
|
static uint32_t sWPADLastButtonHold[4] = {0, 0, 0, 0};
|
||||||
static uint32_t sHoldForXFramesWPAD[4] = {0, 0, 0, 0};
|
static uint32_t sHoldForXFramesWPAD[4] = {0, 0, 0, 0};
|
||||||
|
|
||||||
DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatusProController *data) {
|
DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatusProController *data) {
|
||||||
real_WPADRead(chan, data);
|
real_WPADRead(chan, data);
|
||||||
if (!sAromaUpdateHandle) {
|
if (!sAromaUpdateHandle) {
|
||||||
|
88
src/main.cpp
88
src/main.cpp
@ -22,7 +22,52 @@ WUPS_PLUGIN_LICENSE("GPL");
|
|||||||
WUPS_USE_WUT_DEVOPTAB();
|
WUPS_USE_WUT_DEVOPTAB();
|
||||||
WUPS_USE_STORAGE("aroma_base_plugin"); // Unique id for the storage api
|
WUPS_USE_STORAGE("aroma_base_plugin"); // Unique id for the storage api
|
||||||
|
|
||||||
static bool sSDUtilsInitDone = false;
|
bool InitConfigValuesFromStorage() {
|
||||||
|
WUPSStorageError storageError;
|
||||||
|
auto subItemConfig = WUPSStorageAPI::GetOrCreateSubItem(CAT_CONFIG, storageError);
|
||||||
|
if (!subItemConfig) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create sub category \"%s\"", CAT_CONFIG);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subItemConfig->GetOrStoreDefault(USTEALTH_CONFIG_ID, gActivateUStealth, gActivateUStealth) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", USTEALTH_CONFIG_ID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (subItemConfig->GetOrStoreDefault(POWEROFFWARNING_CONFIG_ID, gSkip4SecondOffStatusCheck, gSkip4SecondOffStatusCheck) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", POWEROFFWARNING_CONFIG_ID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (subItemConfig->GetOrStoreDefault(FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, gForceNDMSuspendSuccess, gForceNDMSuspendSuccess) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (subItemConfig->GetOrStoreDefault(ALLOW_ERROR_NOTIFICATIONS, gAllowErrorNotifications, gAllowErrorNotifications) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", ALLOW_ERROR_NOTIFICATIONS);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto subItemOther = WUPSStorageAPI::GetOrCreateSubItem(CAT_OTHER, storageError);
|
||||||
|
if (!subItemOther) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create sub category \"%s\"", CAT_OTHER);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subItemOther->GetOrStoreDefault(CONFIG_MENU_HINT_SHOWN_ID, gConfigMenuHintShown, gConfigMenuHintShown) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", CONFIG_MENU_HINT_SHOWN_ID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (subItemOther->GetOrStoreDefault(CONFIG_MENU_HINT_SHOWN_ID, gLastHash, gLastHash) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", CONFIG_MENU_HINT_SHOWN_ID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to save storage");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
INITIALIZE_PLUGIN() {
|
INITIALIZE_PLUGIN() {
|
||||||
initLogging();
|
initLogging();
|
||||||
@ -36,45 +81,7 @@ INITIALIZE_PLUGIN() {
|
|||||||
DEBUG_FUNCTION_LINE_ERR("SDUtils_InitLibrary failed");
|
DEBUG_FUNCTION_LINE_ERR("SDUtils_InitLibrary failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open storage to read values
|
InitConfigValuesFromStorage();
|
||||||
WUPSStorageError storageRes = WUPS_OpenStorage();
|
|
||||||
if (storageRes == WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
wups_storage_item_t *cat_config = nullptr;
|
|
||||||
if (WUPS_GetSubItem(nullptr, CAT_CONFIG, &cat_config) == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
|
||||||
if (WUPS_CreateSubItem(nullptr, CAT_CONFIG, &cat_config) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
cat_config = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cat_config != nullptr) {
|
|
||||||
LOAD_BOOL_FROM_STORAGE(cat_config, USTEALTH_CONFIG_ID, gActivateUStealth);
|
|
||||||
LOAD_BOOL_FROM_STORAGE(cat_config, POWEROFFWARNING_CONFIG_ID, gSkip4SecondOffStatusCheck);
|
|
||||||
LOAD_BOOL_FROM_STORAGE(cat_config, FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, gForceNDMSuspendSuccess);
|
|
||||||
LOAD_BOOL_FROM_STORAGE(cat_config, ALLOW_ERROR_NOTIFICATIONS, gAllowErrorNotifications);
|
|
||||||
}
|
|
||||||
|
|
||||||
wups_storage_item_t *cat_other = nullptr;
|
|
||||||
if (WUPS_GetSubItem(nullptr, CAT_OTHER, &cat_other) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
if (WUPS_CreateSubItem(nullptr, CAT_OTHER, &cat_other) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
cat_other = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cat_other != nullptr) {
|
|
||||||
LOAD_BOOL_FROM_STORAGE(cat_other, CONFIG_MENU_HINT_SHOWN_ID, gConfigMenuHintShown);
|
|
||||||
char hash[41];
|
|
||||||
memset(hash, 0, sizeof(hash));
|
|
||||||
LOAD_STRING_FROM_STORAGE(cat_other, LAST_UPDATE_HASH_ID, hash, sizeof(hash));
|
|
||||||
gLastHash = hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close storage
|
|
||||||
if (WUPS_CloseStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to close storage");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to open storage %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ON_APPLICATION_START() {
|
ON_APPLICATION_START() {
|
||||||
@ -92,6 +99,7 @@ ON_APPLICATION_START() {
|
|||||||
ON_APPLICATION_ENDS() {
|
ON_APPLICATION_ENDS() {
|
||||||
StopHintThread();
|
StopHintThread();
|
||||||
StopUpdaterCheckThread();
|
StopUpdaterCheckThread();
|
||||||
|
DownloadUtils::Deinit();
|
||||||
deinitLogging();
|
deinitLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,52 +1,75 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
bool gActivateUStealth = false;
|
bool gActivateUStealth = ACTIVATE_USTEALTH_DEFAULT;
|
||||||
bool gSkip4SecondOffStatusCheck = true;
|
bool gSkip4SecondOffStatusCheck = SKIP_4_SECOND_OFF_STATUS_CHECK_DEFAULT;
|
||||||
bool gConfigMenuHintShown = false;
|
bool gConfigMenuHintShown = CONFIG_MENU_HINT_SHOWN_DEFAULT;
|
||||||
bool gUpdateChecked = false;
|
bool gUpdateChecked = UPDATE_CHECKED_DEFAULT;
|
||||||
bool gForceNDMSuspendSuccess = true;
|
bool gForceNDMSuspendSuccess = FORCE_NDM_SUSPEND_SUCCESS_DEFAULT;
|
||||||
bool gAllowErrorNotifications = true;
|
bool gAllowErrorNotifications = ALLOW_ERROR_NOTIFICATIONS_DEFAULT;
|
||||||
std::string gLastHash = {};
|
std::string gLastHash = LAST_UPDATE_HASH_DEFAULT;
|
||||||
|
|
||||||
void boolItemChangedConfig(ConfigItemBoolean *item, bool newValue) {
|
void boolItemChangedConfig(ConfigItemBoolean *item, bool newValue) {
|
||||||
wups_storage_item_t *cat_config;
|
WUPSStorageError storageError;
|
||||||
if (WUPS_GetSubItem(nullptr, CAT_CONFIG, &cat_config) == WUPS_STORAGE_ERROR_SUCCESS) {
|
auto subItemConfig = WUPSStorageAPI::GetSubItem(CAT_CONFIG, storageError);
|
||||||
PROCESS_BOOL_ITEM_CHANGED(cat_config, USTEALTH_CONFIG_ID, gActivateUStealth);
|
if (!subItemConfig) {
|
||||||
PROCESS_BOOL_ITEM_CHANGED(cat_config, POWEROFFWARNING_CONFIG_ID, gSkip4SecondOffStatusCheck);
|
DEBUG_FUNCTION_LINE_ERR("Failed to get sub item \"%s\": %s", CAT_CONFIG, WUPSStorageAPI::GetStatusStr(storageError).data());
|
||||||
PROCESS_BOOL_ITEM_CHANGED(cat_config, FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, gForceNDMSuspendSuccess);
|
return;
|
||||||
PROCESS_BOOL_ITEM_CHANGED(cat_config, ALLOW_ERROR_NOTIFICATIONS, gAllowErrorNotifications);
|
}
|
||||||
|
if (std::string_view(USTEALTH_CONFIG_ID) == item->identifier) {
|
||||||
|
gActivateUStealth = newValue;
|
||||||
|
storageError = subItemConfig->Store(USTEALTH_CONFIG_ID, newValue);
|
||||||
|
} else if (std::string_view(POWEROFFWARNING_CONFIG_ID) == item->identifier) {
|
||||||
|
gSkip4SecondOffStatusCheck = newValue;
|
||||||
|
storageError = subItemConfig->Store(POWEROFFWARNING_CONFIG_ID, newValue);
|
||||||
|
} else if (std::string_view(ALLOW_ERROR_NOTIFICATIONS) == item->identifier) {
|
||||||
|
gAllowErrorNotifications = newValue;
|
||||||
|
storageError = subItemConfig->Store(ALLOW_ERROR_NOTIFICATIONS, newValue);
|
||||||
|
} else if (std::string_view(FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID) == item->identifier) {
|
||||||
|
gForceNDMSuspendSuccess = newValue;
|
||||||
|
storageError = subItemConfig->Store(FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, newValue);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to get sub item: %s", CAT_CONFIG);
|
return;
|
||||||
|
}
|
||||||
|
if (storageError != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to store %s. New value was %d", item->identifier, newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPS_GET_CONFIG() {
|
WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle) {
|
||||||
// We open the storage, so we can persist the configuration the user did.
|
try {
|
||||||
if (WUPS_OpenStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
WUPSConfigCategory root = WUPSConfigCategory(rootHandle);
|
||||||
DEBUG_FUNCTION_LINE("Failed to open storage");
|
|
||||||
return 0;
|
auto menuPatches = WUPSConfigCategory::Create("Wii U Menu patches");
|
||||||
}
|
|
||||||
|
|
||||||
WUPSConfigHandle config;
|
menuPatches.add(WUPSConfigItemBoolean::Create(USTEALTH_CONFIG_ID,
|
||||||
WUPSConfig_CreateHandled(&config, "Aroma Base Plugin");
|
"Avoid \"Format\" dialog on Wii U Menu",
|
||||||
|
ACTIVATE_USTEALTH_DEFAULT, gActivateUStealth,
|
||||||
WUPSConfigCategoryHandle cat;
|
&boolItemChangedConfig));
|
||||||
WUPSConfig_AddCategoryByNameHandled(config, "Wii U Menu patches", &cat);
|
|
||||||
WUPSConfigCategoryHandle catOther;
|
menuPatches.add(WUPSConfigItemBoolean::Create(POWEROFFWARNING_CONFIG_ID,
|
||||||
WUPSConfig_AddCategoryByNameHandled(config, "Other patches", &catOther);
|
"Skip \"Shutdown warning\" on boot",
|
||||||
|
SKIP_4_SECOND_OFF_STATUS_CHECK_DEFAULT, gSkip4SecondOffStatusCheck,
|
||||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, USTEALTH_CONFIG_ID, "Avoid \"Format\" dialog on Wii U Menu", gActivateUStealth, &boolItemChangedConfig);
|
&boolItemChangedConfig));
|
||||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, POWEROFFWARNING_CONFIG_ID, "Skip \"Shutdown warning\" on boot", gSkip4SecondOffStatusCheck, &boolItemChangedConfig);
|
|
||||||
|
root.add(std::move(menuPatches));
|
||||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, catOther, ALLOW_ERROR_NOTIFICATIONS, "Allow error notifications", gAllowErrorNotifications, &boolItemChangedConfig);
|
|
||||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, catOther, FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, "Fix connecting to a 3DS in Mii Maker", gForceNDMSuspendSuccess, &boolItemChangedConfig);
|
auto otherPatches = WUPSConfigCategory::Create("Other patches");
|
||||||
|
|
||||||
return config;
|
otherPatches.add(WUPSConfigItemBoolean::Create(ALLOW_ERROR_NOTIFICATIONS,
|
||||||
}
|
"Allow error notifications",
|
||||||
|
ALLOW_ERROR_NOTIFICATIONS_DEFAULT, gAllowErrorNotifications,
|
||||||
WUPS_CONFIG_CLOSED() {
|
&boolItemChangedConfig));
|
||||||
// Save all changes
|
|
||||||
if (WUPS_CloseStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
otherPatches.add(WUPSConfigItemBoolean::Create(FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID,
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to close storage");
|
"Fix connecting to a 3DS in Mii Maker",
|
||||||
|
FORCE_NDM_SUSPEND_SUCCESS_DEFAULT, gForceNDMSuspendSuccess,
|
||||||
|
&boolItemChangedConfig));
|
||||||
|
root.add(std::move(otherPatches));
|
||||||
|
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
OSReport("Exception T_T : %s\n", e.what());
|
||||||
|
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS;
|
||||||
}
|
}
|
@ -4,46 +4,24 @@
|
|||||||
#include <wups/config/WUPSConfigItemBoolean.h>
|
#include <wups/config/WUPSConfigItemBoolean.h>
|
||||||
#include <wups/storage.h>
|
#include <wups/storage.h>
|
||||||
|
|
||||||
#define CAT_CONFIG "config"
|
#define CAT_CONFIG "config"
|
||||||
#define CAT_OTHER "other"
|
#define CAT_OTHER "other"
|
||||||
|
|
||||||
#define USTEALTH_CONFIG_ID "ustealth"
|
#define USTEALTH_CONFIG_ID "ustealth"
|
||||||
#define POWEROFFWARNING_CONFIG_ID "SkipPowerOffWarning"
|
#define POWEROFFWARNING_CONFIG_ID "SkipPowerOffWarning"
|
||||||
#define FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID "forceNDMSuspendSuccess"
|
#define FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID "forceNDMSuspendSuccess"
|
||||||
#define ALLOW_ERROR_NOTIFICATIONS "allowErrorNotifications"
|
#define ALLOW_ERROR_NOTIFICATIONS "allowErrorNotifications"
|
||||||
|
|
||||||
|
#define CONFIG_MENU_HINT_SHOWN_ID "configMenuHintShown"
|
||||||
|
#define LAST_UPDATE_HASH_ID "lastUpdateHash"
|
||||||
|
|
||||||
#define CONFIG_MENU_HINT_SHOWN_ID "configMenuHintShown"
|
#define ACTIVATE_USTEALTH_DEFAULT false
|
||||||
#define LAST_UPDATE_HASH_ID "lastUpdateHash"
|
#define SKIP_4_SECOND_OFF_STATUS_CHECK_DEFAULT false
|
||||||
|
#define CONFIG_MENU_HINT_SHOWN_DEFAULT false
|
||||||
#define LOAD_BOOL_FROM_STORAGE(__cat, config_name, __variable__) \
|
#define UPDATE_CHECKED_DEFAULT false
|
||||||
if ((storageRes = WUPS_GetBool(__cat, config_name, &__variable__)) == WUPS_STORAGE_ERROR_NOT_FOUND) { \
|
#define FORCE_NDM_SUSPEND_SUCCESS_DEFAULT false
|
||||||
if (WUPS_StoreBool(__cat, config_name, __variable__) != WUPS_STORAGE_ERROR_SUCCESS) { \
|
#define ALLOW_ERROR_NOTIFICATIONS_DEFAULT false
|
||||||
DEBUG_FUNCTION_LINE_WARN("Failed to store bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \
|
#define LAST_UPDATE_HASH_DEFAULT std::string()
|
||||||
} \
|
|
||||||
} else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { \
|
|
||||||
DEBUG_FUNCTION_LINE_WARN("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \
|
|
||||||
} \
|
|
||||||
while (0)
|
|
||||||
|
|
||||||
#define LOAD_STRING_FROM_STORAGE(__cat, config_name, __string, __string_length) \
|
|
||||||
if ((storageRes = WUPS_GetString(__cat, config_name, __string, __string_length)) == WUPS_STORAGE_ERROR_NOT_FOUND) { \
|
|
||||||
if (WUPS_StoreString(__cat, config_name, __string) != WUPS_STORAGE_ERROR_SUCCESS) { \
|
|
||||||
DEBUG_FUNCTION_LINE_WARN("Failed to store string %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \
|
|
||||||
} \
|
|
||||||
} else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { \
|
|
||||||
DEBUG_FUNCTION_LINE_WARN("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \
|
|
||||||
} \
|
|
||||||
while (0)
|
|
||||||
|
|
||||||
#define PROCESS_BOOL_ITEM_CHANGED(cat, __config__name, __variable__) \
|
|
||||||
if (std::string_view(item->configId) == __config__name) { \
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("New value in %s: %d", __config__name, newValue); \
|
|
||||||
__variable__ = newValue; \
|
|
||||||
WUPS_StoreInt(cat, __config__name, __variable__); \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
while (0)
|
|
||||||
|
|
||||||
extern bool gActivateUStealth;
|
extern bool gActivateUStealth;
|
||||||
extern bool gSkip4SecondOffStatusCheck;
|
extern bool gSkip4SecondOffStatusCheck;
|
||||||
|
Loading…
Reference in New Issue
Block a user