mirror of
https://github.com/wiiu-env/ScreenshotWUPS.git
synced 2024-11-22 06:29:15 +01:00
OSFatal when the Notification Module is missing
This commit is contained in:
parent
046d587ec5
commit
c0a2308edb
@ -1,7 +1,9 @@
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "retain_vars.hpp"
|
||||
#include "utils/WUPSConfigItemButtonCombo.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
#include <vpad/input.h>
|
||||
#include <wups.h>
|
||||
#include <wups/config/WUPSConfigItemBoolean.h>
|
||||
@ -146,6 +148,9 @@ void boolItemCallback(ConfigItemBoolean *item, bool newValue) {
|
||||
DEBUG_FUNCTION_LINE("New value in %s changed: %d", item->configId, newValue);
|
||||
if (std::string_view(item->configId) == ENABLED_CONFIG_STRING) {
|
||||
gEnabled = newValue;
|
||||
if (gEnabled) {
|
||||
InitNotificationModule();
|
||||
}
|
||||
WUPS_StoreBool(nullptr, item->configId, gEnabled);
|
||||
} else if (std::string_view(item->configId) == RESERVED_BIT_USAGE_CONFIG_STRING) {
|
||||
gReservedBitUsage = newValue;
|
||||
|
@ -7,4 +7,4 @@
|
||||
#define SCREEN_CONFIG_STRING "screen"
|
||||
#define RESERVED_BIT_USAGE_CONFIG_STRING "reservedBitUsage"
|
||||
|
||||
void InitConfig();
|
||||
void InitConfig();
|
||||
|
@ -23,13 +23,10 @@ WUPS_USE_WUT_DEVOPTAB();
|
||||
// Gets called once the loader exists.
|
||||
INITIALIZE_PLUGIN() {
|
||||
initLogging();
|
||||
|
||||
NotificationModuleStatus res;
|
||||
if ((res = NotificationModule_InitLibrary()) != NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
||||
DEBUG_FUNCTION_LINE_ERR("NotificationModule_InitLibrary failed: %s", NotificationModule_GetStatusStr(res));
|
||||
}
|
||||
|
||||
InitConfig();
|
||||
if (gEnabled) {
|
||||
InitNotificationModule();
|
||||
}
|
||||
}
|
||||
|
||||
DEINITIALIZE_PLUGIN() {
|
||||
|
@ -25,3 +25,5 @@ int32_t gThreadPriorityIncrease = 1;
|
||||
|
||||
bool gBlockDRCScreenshots = false;
|
||||
bool gBlockScreenshots = false;
|
||||
|
||||
bool gInitNotificationModule = false;
|
||||
|
@ -28,3 +28,5 @@ extern int32_t gThreadPriorityIncrease;
|
||||
|
||||
extern bool gBlockDRCScreenshots;
|
||||
extern bool gBlockScreenshots;
|
||||
|
||||
extern bool gInitNotificationModule;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "StringTools.h"
|
||||
#include "config.h"
|
||||
#include "logger.h"
|
||||
#include "retain_vars.hpp"
|
||||
#include <coreinit/title.h>
|
||||
@ -78,6 +79,34 @@ std::string GetSanitizedNameOfCurrentApplication() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void InitNotificationModule() {
|
||||
if (gInitNotificationModule) {
|
||||
return;
|
||||
}
|
||||
NotificationModuleStatus res;
|
||||
if ((res = NotificationModule_InitLibrary()) != NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
||||
gInitNotificationModule = true;
|
||||
std::string error = string_format("Failed to init Screenshot Plugin: \n"
|
||||
"NotificationModule_InitLibrary returned:\n%s\n\n"
|
||||
"Please update to latest Aroma before using the plugin.\n\n"
|
||||
"The plugin has been disabled. You need to enable again in the\n"
|
||||
"config menu after updating\n\n"
|
||||
"Hold the POWER button of your CONSOLE for 5 seconds to shut down.",
|
||||
NotificationModule_GetStatusStr(res));
|
||||
gEnabled = false;
|
||||
WUPSStorageError storageRes = WUPS_OpenStorage();
|
||||
if (storageRes == WUPS_STORAGE_ERROR_SUCCESS) {
|
||||
if (WUPS_StoreBool(nullptr, ENABLED_CONFIG_STRING, gEnabled) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to store value");
|
||||
}
|
||||
WUPS_CloseStorage();
|
||||
}
|
||||
|
||||
OSFatal(error.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyGameSpecificPatches() {
|
||||
uint64_t titleID = OSGetTitleID();
|
||||
// Mario Kart 8 has noticeable slowdown when taking screenshots in multiplayer
|
||||
|
@ -17,3 +17,5 @@ inline uint8_t RGBComponentToSRGB(uint8_t ci) {
|
||||
std::string GetSanitizedNameOfCurrentApplication();
|
||||
|
||||
void ApplyGameSpecificPatches();
|
||||
|
||||
void InitNotificationModule();
|
Loading…
Reference in New Issue
Block a user