mirror of
https://github.com/PretendoNetwork/Inkay.git
synced 2025-04-02 11:02:05 -04:00
Compare commits
13 commits
c847ef8161
...
f8bc367e92
Author | SHA1 | Date | |
---|---|---|---|
|
f8bc367e92 | ||
|
cca4c57f20 | ||
|
d43faeefdf | ||
|
f3ec04dc77 | ||
|
18182f90b7 | ||
|
29a9e2e2b4 | ||
|
ac18b95632 | ||
|
f7f3977f2c | ||
|
7eb7608a35 | ||
|
f039c5948d | ||
|
3e2721b48f | ||
|
b207e3475d | ||
|
1f18eba8b2 |
8 changed files with 59 additions and 100 deletions
|
@ -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)
|
2
Makefile
2
Makefile
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
29
src/main.cpp
29
src/main.cpp
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue