diff --git a/.gitignore b/.gitignore index 74caf8d..fa7ebaa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .idea/ /build *.elf +*.wps diff --git a/Dockerfile b/Dockerfile index 9dcb816..b3782c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ -FROM wiiuenv/devkitppc:20220806 +FROM wiiuenv/devkitppc:20221228 +COPY --from=wiiuenv/libnotifications:20230126 /artifacts $DEVKITPRO COPY --from=wiiuenv/libkernel:20220724 /artifacts $DEVKITPRO COPY --from=wiiuenv/libmocha:20220903 /artifacts $DEVKITPRO -COPY --from=wiiuenv/wiiupluginsystem:20220826 /artifacts $DEVKITPRO +COPY --from=wiiuenv/wiiupluginsystem:20230126 /artifacts $DEVKITPRO WORKDIR /app -CMD make -f Makefile -j$(nproc) +CMD make -f Makefile -j$(nproc) \ No newline at end of file diff --git a/Inkay-pretendo.wps b/Inkay-pretendo.wps deleted file mode 100644 index 10b6d6d..0000000 Binary files a/Inkay-pretendo.wps and /dev/null differ diff --git a/Makefile b/Makefile index d6d368b..3e022aa 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) LDFLAGS += -T$(WUMS_ROOT)/share/libkernel.ld $(WUPSSPECS) -LIBS := -lwups -lmocha -lkernel -lwut +LIBS := -lwups -lmocha -lkernel -lwut -lnotifications #------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level diff --git a/src/Notification.cpp b/src/Notification.cpp new file mode 100644 index 0000000..24e3275 --- /dev/null +++ b/src/Notification.cpp @@ -0,0 +1,39 @@ +#include "Notification.h" +#include +#include +#include +#include +#include +#include + +static std::unique_ptr sShowHintThread; +static bool sShutdownHintThread = false; + +void ShowNotification(const char * notification) { + // Wait for notification module to be ready + bool isOverlayReady = false; + while (!sShutdownHintThread && NotificationModule_IsOverlayReady(&isOverlayReady) == NOTIFICATION_MODULE_RESULT_SUCCESS && !isOverlayReady) + OSSleepTicks(OSMillisecondsToTicks(16)); + if (sShutdownHintThread || !isOverlayReady) return; + NotificationModuleStatus err = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 15.0f); + if(err != NOTIFICATION_MODULE_RESULT_SUCCESS) return; + + NotificationModule_AddInfoNotification(notification); +} + +void StartNotificationThread(const char * value) { + uint64_t titleID = OSGetTitleID(); + if (titleID == 0x0005001010040000L || titleID == 0x0005001010040100L || titleID == 0x0005001010040200L) { + sShutdownHintThread = false; + sShowHintThread = std::make_unique(ShowNotification, value); + } +} + +void StopNotificationThread() { + if (sShowHintThread != nullptr) { + sShutdownHintThread = true; + OSMemoryBarrier(); + sShowHintThread->join(); + sShowHintThread.reset(); + } +} diff --git a/src/Notification.h b/src/Notification.h new file mode 100644 index 0000000..b25ed3b --- /dev/null +++ b/src/Notification.h @@ -0,0 +1,7 @@ +#pragma once + +void ShowNotification(const char * notification); + +void StartNotificationThread(const char * value); + +void StopNotificationThread(); diff --git a/src/main.cpp b/src/main.cpp index f393ae8..3900ce1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,10 +23,13 @@ #include #include #include +#include #include "wut_extra.h" #include #include "url_patches.h" #include "config.h" +#include "Notification.h" + /** Mandatory plugin information. @@ -95,6 +98,10 @@ INITIALIZE_PLUGIN() { return; } + if (NotificationModule_InitLibrary() != NOTIFICATION_MODULE_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE("NotificationModule_InitLibrary failed"); + } + //get os version MCP_SystemVersion os_version; int mcp = MCP_Open(); @@ -120,11 +127,12 @@ INITIALIZE_PLUGIN() { for (const auto& patch : url_patches) { write_string(patch.address, patch.url); } - DEBUG_FUNCTION_LINE("Pretendo URL and NoSSL patches applied successfully."); + StartNotificationThread("Using Pretendo Network"); } else { DEBUG_FUNCTION_LINE("Pretendo URL and NoSSL patches skipped."); + StartNotificationThread("Using Nintendo Network"); } @@ -133,6 +141,7 @@ INITIALIZE_PLUGIN() { DEINITIALIZE_PLUGIN() { WHBLogUdpDeinit(); Mocha_DeInitLibrary(); + NotificationModule_DeInitLibrary(); } bool check_olv_libs() { @@ -213,3 +222,8 @@ ON_APPLICATION_START() { replace(base_addr, size, original_url, sizeof(original_url), new_url, sizeof(new_url)); } + +ON_APPLICATION_ENDS() { + DEBUG_FUNCTION_LINE("Inkay: shutting down...\n"); + StopNotificationThread(); +}