Compare commits

..

1 commit

Author SHA1 Message Date
TraceEntertains
70455e9211
Merge c847ef8161 into b239ae82db 2024-05-08 06:33:33 +00:00
8 changed files with 100 additions and 59 deletions

View file

@ -1,10 +1,10 @@
FROM ghcr.io/wiiu-env/devkitppc:20240505 FROM ghcr.io/wiiu-env/devkitppc:20231112
COPY --from=ghcr.io/wiiu-env/libnotifications:20240426 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libkernel:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libkernel:20230621 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libmocha:20231127 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libmocha:20231127 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20240505 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230719 /artifacts $DEVKITPRO
WORKDIR /app WORKDIR /app
CMD make -f Makefile -j$(nproc) CMD make -f Makefile -j$(nproc)

View file

@ -24,7 +24,7 @@ BUILD := build
SOURCES := src src/patches src/utils src/ext/inih SOURCES := src src/patches src/utils src/ext/inih
DATA := data DATA := data
INCLUDES := src src/ext/inih INCLUDES := src src/ext/inih
#DEBUG := 1 DEBUG := 1
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# options for code generation # options for code generation

View file

@ -15,17 +15,37 @@
*/ */
#include "Notification.h" #include "Notification.h"
#include <coreinit/cache.h>
#include <coreinit/thread.h>
#include <notifications/notification_defines.h> #include <notifications/notification_defines.h>
#include <notifications/notifications.h> #include <notifications/notifications.h>
#include <thread>
void ShowNotification(std::string_view notification) { static std::unique_ptr<std::thread> sShowHintThread;
auto err1 = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, static bool sShutdownHintThread = false;
NOTIFICATION_MODULE_DEFAULT_OPTION_KEEP_UNTIL_SHOWN, true);
auto err2 = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO,
NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT,
15.0f);
if (err1 != NOTIFICATION_MODULE_RESULT_SUCCESS || err2 != NOTIFICATION_MODULE_RESULT_SUCCESS) return;
NotificationModule_AddInfoNotification(notification.data()); 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) {
sShutdownHintThread = false;
sShowHintThread = std::make_unique<std::thread>(ShowNotification, value);
}
void StopNotificationThread() {
if (sShowHintThread != nullptr) {
sShutdownHintThread = true;
OSMemoryBarrier();
sShowHintThread->join();
sShowHintThread.reset();
}
} }

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <string_view> void ShowNotification(const char * notification);
void ShowNotification(std::string_view notification); void StartNotificationThread(const char * value);
void StopNotificationThread();

View file

@ -36,6 +36,7 @@ bool Config::connect_to_network = true;
bool Config::need_relaunch = false; bool Config::need_relaunch = false;
bool Config::unregister_task_item_pressed = false; bool Config::unregister_task_item_pressed = false;
bool Config::is_wiiu_menu = false; bool Config::is_wiiu_menu = false;
bool Config::has_displayed_popup = false;
config_strings strings; config_strings strings;
@ -53,7 +54,7 @@ constexpr config_strings get_config_strings(nn::swkbd::LanguageType language) {
.restart_to_apply_action = "Restart to apply", .restart_to_apply_action = "Restart to apply",
.need_menu_action = "From WiiU menu only" .need_menu_action = "From WiiU menu only"
}; };
case nn::swkbd::LanguageType::Spanish: case nn::swkbd::LanguageType::Spanish:
return { return {
.plugin_name = "Inkay", .plugin_name = "Inkay",
@ -65,7 +66,7 @@ constexpr config_strings get_config_strings(nn::swkbd::LanguageType language) {
.restart_to_apply_action = "Reinicia para confirmar", .restart_to_apply_action = "Reinicia para confirmar",
.need_menu_action = "Sólo desde el menú de WiiU", .need_menu_action = "Sólo desde el menú de WiiU",
}; };
case nn::swkbd::LanguageType::French: case nn::swkbd::LanguageType::French:
return { return {
.plugin_name = "Inkay", .plugin_name = "Inkay",
@ -88,7 +89,7 @@ constexpr config_strings get_config_strings(nn::swkbd::LanguageType language) {
.restart_to_apply_action = "Riavvia per applicare", .restart_to_apply_action = "Riavvia per applicare",
.need_menu_action = "Solo dal menu WiiU", .need_menu_action = "Solo dal menu WiiU",
}; };
case nn::swkbd::LanguageType::German: case nn::swkbd::LanguageType::German:
return { return {
.plugin_name = "Inkay", .plugin_name = "Inkay",
@ -107,11 +108,12 @@ static void connect_to_network_changed(ConfigItemBoolean* item, bool new_value)
DEBUG_FUNCTION_LINE("connect_to_network changed to: %d", new_value); DEBUG_FUNCTION_LINE("connect_to_network changed to: %d", new_value);
if (new_value != Config::connect_to_network) { if (new_value != Config::connect_to_network) {
Config::need_relaunch = true; Config::need_relaunch = true;
// make popup display again when rebooting into another network (caused by aroma beta 17+ api changes as far as i know)
Config::has_displayed_popup = false;
} }
Config::connect_to_network = new_value; Config::connect_to_network = new_value;
if (WUPSStorageAPI::Store<bool>("connect_to_network", Config::connect_to_network) != WUPS_STORAGE_ERROR_SUCCESS) { WUPSStorageAPI::Store<bool>("connect_to_network", Config::connect_to_network);
DEBUG_FUNCTION_LINE("Failed to save \"connect_to_network\" value (%d)", Config::connect_to_network);
}
} }
static void unregister_task_item_on_input_cb(void *context, WUPSConfigSimplePadData input) { static void unregister_task_item_on_input_cb(void *context, WUPSConfigSimplePadData input) {
@ -124,21 +126,21 @@ static void unregister_task_item_on_input_cb(void *context, WUPSConfigSimplePadD
{ {
if (nn::act::IsSlotOccupied(i) && nn::act::IsNetworkAccountEx(i)) if (nn::act::IsSlotOccupied(i) && nn::act::IsNetworkAccountEx(i))
{ {
nn::boss::Task task{}; nn::boss::Task task;
nn::act::PersistentId persistentId = nn::act::GetPersistentIdEx(i); nn::act::PersistentId persistentId = nn::act::GetPersistentIdEx(i);
__ct__Q3_2nn4boss4TaskFv(&task); __ct__Q3_2nn4boss4TaskFv(&task);
Initialize__Q3_2nn4boss4TaskFPCcUi(&task, "oltopic", persistentId); Initialize__Q3_2nn4boss4TaskFPCcUi(&task, "oltopic", persistentId);
// bypasses compiler warning about unused variable // bypasses compiler warning about unused variable
#ifdef DEBUG #ifdef DEBUG
uint32_t res = Unregister__Q3_2nn4boss4TaskFv(&task); uint32_t res = Unregister__Q3_2nn4boss4TaskFv(&task);
DEBUG_FUNCTION_LINE_VERBOSE("Unregistered oltopic for: SlotNo %d | Persistent ID %08x -> 0x%08x", i, persistentId, res); DEBUG_FUNCTION_LINE_VERBOSE("Unregistered oltopic for: SlotNo %d | Persistent ID %08x -> 0x%08x", i, persistentId, res);
#else #else
Unregister__Q3_2nn4boss4TaskFv(&task); Unregister__Q3_2nn4boss4TaskFv(&task);
#endif #endif
} }
} }
Finalize__Q2_2nn4bossFv(); Finalize__Q2_2nn4bossFv();
nn::act::Finalize(); nn::act::Finalize();
@ -153,7 +155,7 @@ static int32_t unregister_task_item_get_display_value(void *context, char *out_b
strncpy(out_buf, strings.need_menu_action, out_size); strncpy(out_buf, strings.need_menu_action, out_size);
else else
strncpy(out_buf, Config::unregister_task_item_pressed ? strings.restart_to_apply_action : strings.press_a_action, out_size); strncpy(out_buf, Config::unregister_task_item_pressed ? strings.restart_to_apply_action : strings.press_a_action, out_size);
return 0; return 0;
} }
@ -164,7 +166,7 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
// get translation strings // get translation strings
strings = get_config_strings(get_system_language()); strings = get_config_strings(get_system_language());
// create root config category // create root config category
WUPSConfigCategory root = WUPSConfigCategory(rootHandle); WUPSConfigCategory root = WUPSConfigCategory(rootHandle);
@ -172,7 +174,7 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
auto patching_cat = WUPSConfigCategory::Create(strings.network_category); auto patching_cat = WUPSConfigCategory::Create(strings.network_category);
// config id display name default current value changed callback // config id display name default current value changed callback
patching_cat.add(WUPSConfigItemBoolean::Create("connect_to_network", strings.connect_to_network_setting, true, Config::connect_to_network, &connect_to_network_changed)); patching_cat.add(WUPSConfigItemBoolean::Create("connect_to_network", strings.connect_to_network_setting, false, Config::connect_to_network, &connect_to_network_changed));
root.add(std::move(patching_cat)); root.add(std::move(patching_cat));
auto other_cat = WUPSConfigCategory::Create(strings.other_category); auto other_cat = WUPSConfigCategory::Create(strings.other_category);
@ -188,7 +190,7 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
.onInputEx = nullptr, .onInputEx = nullptr,
.onDelete = nullptr .onDelete = nullptr
}; };
WUPSConfigAPIItemOptionsV2 unregisterTasksItemOptions = { WUPSConfigAPIItemOptionsV2 unregisterTasksItemOptions = {
.displayName = strings.reset_wwp_setting, .displayName = strings.reset_wwp_setting,
.context = nullptr, .context = nullptr,
@ -196,20 +198,15 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
}; };
WUPSConfigItemHandle unregisterTasksItem; WUPSConfigItemHandle unregisterTasksItem;
WUPSConfigAPIStatus err; WUPSConfigAPI_Item_Create(unregisterTasksItemOptions, &unregisterTasksItem);
if ((err = WUPSConfigAPI_Item_Create(unregisterTasksItemOptions, &unregisterTasksItem)) != WUPSCONFIG_API_RESULT_SUCCESS) { WUPSConfigAPI_Category_AddItem(other_cat.getHandle(), unregisterTasksItem);
throw std::runtime_error(std::string("Failed to create config item: ").append(WUPSConfigAPI_GetStatusStr(err)));
}
if ((err = WUPSConfigAPI_Category_AddItem(other_cat.getHandle(), unregisterTasksItem)) != WUPSCONFIG_API_RESULT_SUCCESS) {
throw std::runtime_error(std::string("Failed to add config item: ").append(WUPSConfigAPI_GetStatusStr(err)));
}
root.add(std::move(other_cat)); root.add(std::move(other_cat));
} }
catch (std::exception &e) { catch (std::exception &e) {
DEBUG_FUNCTION_LINE("Creating config menu failed: %s", e.what()); DEBUG_FUNCTION_LINE("Creating config menu failed: %s", e.what());
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR; return WUPSCONFIG_API_CALLBACK_RESULT_ERROR;
} }
return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS; return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS;
} }
@ -235,23 +232,23 @@ void Config::Init() {
DEBUG_FUNCTION_LINE("Failed to initialize WUPS Config API"); DEBUG_FUNCTION_LINE("Failed to initialize WUPS Config API");
return; return;
} }
WUPSStorageError storageRes; WUPSStorageError storageRes;
// Try to get value from storage // Try to get value from storage
if ((storageRes = WUPSStorageAPI::Get<bool>("connect_to_network", Config::connect_to_network)) == WUPS_STORAGE_ERROR_NOT_FOUND) { if ((storageRes = WUPSStorageAPI::Get<bool>("connect_to_network", Config::connect_to_network)) == WUPS_STORAGE_ERROR_NOT_FOUND) {
DEBUG_FUNCTION_LINE("Connect to network value not found, attempting to migrate/create"); DEBUG_FUNCTION_LINE("Connect to network value not found, attempting to migrate/create");
bool skipPatches = false; bool skipPatches = false;
if (WUPSStorageAPI::Get<bool>("skipPatches", skipPatches) == WUPS_STORAGE_ERROR_SUCCESS) { if ((storageRes = WUPSStorageAPI::Get<bool>("skipPatches", skipPatches)) != WUPS_STORAGE_ERROR_NOT_FOUND) {
// Migrate old config value // Migrate old config value
Config::connect_to_network = !skipPatches; Config::connect_to_network = !skipPatches;
WUPSStorageAPI::DeleteItem("skipPatches"); WUPSStorageAPI::DeleteItem("skipPatches");
} }
// Add the value to the storage if it's missing. // Add the value to the storage if it's missing.
if (WUPSStorageAPI::Store<bool>("connect_to_network", connect_to_network) != WUPS_STORAGE_ERROR_SUCCESS) { //if (WUPSStorageAPI::Store<bool>("connect_to_network", Config::connect_to_network) != WUPS_STORAGE_ERROR_SUCCESS) {
DEBUG_FUNCTION_LINE("Failed to store bool"); // DEBUG_FUNCTION_LINE("Failed to store bool");
} //}
// commented indefinitely due to defaults likely being handled by the config api already
} }
else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
DEBUG_FUNCTION_LINE("Failed to get bool %s (%d)", WUPSStorageAPI_GetStatusStr(storageRes), storageRes); DEBUG_FUNCTION_LINE("Failed to get bool %s (%d)", WUPSStorageAPI_GetStatusStr(storageRes), storageRes);

View file

@ -19,6 +19,9 @@ public:
static bool is_wiiu_menu; static bool is_wiiu_menu;
static bool unregister_task_item_pressed; static bool unregister_task_item_pressed;
// for notifications to work correctly in aroma beta 17+
static bool has_displayed_popup;
}; };
struct config_strings { struct config_strings {

View file

@ -179,13 +179,9 @@ INITIALIZE_PLUGIN() {
write_string(patch.address, patch.url); write_string(patch.address, patch.url);
} }
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully."); DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully.");
ShowNotification(get_pretendo_message());
} }
else { else {
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped."); DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped.");
ShowNotification(get_nintendo_network_message());
} }
MCP_Close(mcp); MCP_Close(mcp);
@ -208,14 +204,37 @@ DEINITIALIZE_PLUGIN() {
} }
ON_APPLICATION_START() { ON_APPLICATION_START() {
WHBLogModuleInit();
WHBLogCafeInit();
WHBLogUdpInit();
DEBUG_FUNCTION_LINE_VERBOSE("Inkay " INKAY_VERSION " starting up...\n"); DEBUG_FUNCTION_LINE_VERBOSE("Inkay " INKAY_VERSION " starting up...\n");
uint64_t titleID = OSGetTitleID();
if (titleID == _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_WII_U_MENU) && !Config::has_displayed_popup)
{
if (Config::connect_to_network) {
StartNotificationThread(get_pretendo_message());
}
else {
StartNotificationThread(get_nintendo_network_message());
}
Config::has_displayed_popup = true;
}
setup_olv_libs(); setup_olv_libs();
matchmaking_notify_titleswitch(); matchmaking_notify_titleswitch();
patchAccountSettings(); patchAccountSettings();
} }
ON_APPLICATION_ENDS() { ON_APPLICATION_ENDS() {
// commented because it doesnt really unload inkay // commented because it doesnt really unload inkay, just the application thread, which is a bit misleading
//DEBUG_FUNCTION_LINE_VERBOSE("Unloading Inkay...\n"); //DEBUG_FUNCTION_LINE_VERBOSE("Unloading Inkay...\n");
WHBLogModuleDeinit();
WHBLogCafeDeinit();
WHBLogUdpDeinit();
StopNotificationThread();
} }

View file

@ -28,7 +28,7 @@ extern "C" {
#ifdef DEBUG #ifdef DEBUG
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) DEBUG_FUNCTION_LINE(FMT, ##ARGS) #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) DEBUG_FUNCTION_LINE(FMT, ##ARGS)
#else #else
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0); #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus