From 384ffbd8a1fd071d71e6bed65fb917323ec1d883 Mon Sep 17 00:00:00 2001 From: 0verjoY <59394546+0verjoY@users.noreply.github.com> Date: Sun, 19 Feb 2023 21:21:09 +0100 Subject: [PATCH] - Disable Wii front buttons (Power + Reset) while installing / removing a title --- source/sys.c | 13 +++++++++++-- source/sys.h | 1 + source/wad.c | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/source/sys.c b/source/sys.c index e84ab28..8c8b530 100644 --- a/source/sys.c +++ b/source/sys.c @@ -13,16 +13,20 @@ /* Variables */ static const char certs_fs[] ATTRIBUTE_ALIGN(32) = "/sys/cert.sys"; u32 boot2version; +static bool gDisablePRButtons = false; + void __Sys_ResetCallback(__attribute__((unused)) u32 irq, __attribute__((unused)) void *ctx) { /* Reboot console */ - Sys_Reboot(); + if (!gDisablePRButtons) + Sys_Reboot(); } void __Sys_PowerCallback(void) { /* Poweroff console */ - Sys_Shutdown(); + if (!gDisablePRButtons) + Sys_Shutdown(); } bool isIOSstub(u8 ios_number) @@ -186,3 +190,8 @@ s32 Sys_GetCerts(signed_blob **certs, u32 *len) return ret; } + +void SetPRButtons(bool enabled) +{ + gDisablePRButtons = !enabled; +} diff --git a/source/sys.h b/source/sys.h index 766bffe..0e087fa 100644 --- a/source/sys.h +++ b/source/sys.h @@ -10,5 +10,6 @@ void Sys_Reboot(void); void Sys_Shutdown(void); void Sys_LoadMenu(void); s32 Sys_GetCerts(signed_blob **, u32 *); +void SetPRButtons(bool enabled); #endif diff --git a/source/wad.c b/source/wad.c index 942f55e..e0c9cc9 100644 --- a/source/wad.c +++ b/source/wad.c @@ -479,6 +479,7 @@ bool skipRegionSafetyCheck = false; s32 Wad_Install(FILE *fp) { + SetPRButtons(false); wadHeader *header = NULL; signed_blob *p_certs = NULL, *p_crl = NULL, *p_tik = NULL, *p_tmd = NULL; @@ -892,11 +893,13 @@ out: if (gForcedInstall) return Wad_Install(fp); + SetPRButtons(true); return ret; } s32 Wad_Uninstall(FILE *fp) { + SetPRButtons(false); wadHeader *header = NULL; tikview *viewData = NULL; @@ -1047,5 +1050,7 @@ s32 Wad_Uninstall(FILE *fp) out: /* Free memory */ free(header); + + SetPRButtons(true); return ret; }