Compare commits

...

13 commits

Author SHA1 Message Date
Pancake-Pal-Productions
f8bc367e92 Fix compiler warnings 2024-05-08 15:23:22 -04:00
Pancake-Pal-Productions
cca4c57f20 Disable debug by default 2024-05-08 15:22:38 -04:00
Pancake-Pal-Productions
d43faeefdf Fix notifications (yay) (thanks maschell) 2024-05-08 15:19:27 -04:00
Pancake-Pal-Productions
f3ec04dc77 Even more notifications stuff 2024-05-08 13:13:04 -04:00
Pancake-Pal-Productions
18182f90b7 More notifications stuff 2024-05-08 13:12:06 -04:00
Pancake-Pal-Productions
29a9e2e2b4 Remove remnants of has_displayed_popup variables (not needed anymore) 2024-05-08 12:32:41 -04:00
TraceEntertains
ac18b95632
Merge pull request #1 from Maschell/pr_fixes
Fixes for the Aroma Beta 17 PR
2024-05-08 12:31:24 -04:00
TraceEntertains
f7f3977f2c
Merge branch 'main' into pr_fixes 2024-05-08 12:30:15 -04:00
Maschell
7eb7608a35 Small fixes for the storage/config API usage 2024-05-07 17:12:10 +02:00
Maschell
f039c5948d Init nn::boss::Task 2024-05-07 17:02:55 +02:00
Maschell
3e2721b48f Simplify notifcations 2024-05-07 17:02:37 +02:00
Maschell
b207e3475d Fix logger.h 2024-05-07 16:58:53 +02:00
Maschell
1f18eba8b2 Update Dockerfile 2024-05-07 16:58:41 +02:00
8 changed files with 59 additions and 100 deletions

View file

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

View file

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

View file

@ -15,37 +15,17 @@
*/
#include "Notification.h"
#include <coreinit/cache.h>
#include <coreinit/thread.h>
#include <notifications/notification_defines.h>
#include <notifications/notifications.h>
#include <thread>
static std::unique_ptr<std::thread> sShowHintThread;
static bool sShutdownHintThread = false;
void ShowNotification(std::string_view notification) {
auto err1 = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO,
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;
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();
}
NotificationModule_AddInfoNotification(notification.data());
}

View file

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

View file

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

View file

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

View file

@ -179,9 +179,13 @@ INITIALIZE_PLUGIN() {
write_string(patch.address, patch.url);
}
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully.");
ShowNotification(get_pretendo_message());
}
else {
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped.");
ShowNotification(get_nintendo_network_message());
}
MCP_Close(mcp);
@ -204,37 +208,14 @@ DEINITIALIZE_PLUGIN() {
}
ON_APPLICATION_START() {
WHBLogModuleInit();
WHBLogCafeInit();
WHBLogUdpInit();
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();
matchmaking_notify_titleswitch();
patchAccountSettings();
}
ON_APPLICATION_ENDS() {
// commented because it doesnt really unload inkay, just the application thread, which is a bit misleading
// commented because it doesnt really unload inkay
//DEBUG_FUNCTION_LINE_VERBOSE("Unloading Inkay...\n");
WHBLogModuleDeinit();
WHBLogCafeDeinit();
WHBLogUdpDeinit();
StopNotificationThread();
}

View file

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