From 574eeef4f05dc88b8c5790fcefddfb32868d1905 Mon Sep 17 00:00:00 2001 From: James Benton Date: Fri, 2 Jun 2017 14:24:00 +0100 Subject: [PATCH] whb: Use OSGetTitleID to check if we were launched from WHB. --- samples/gx2/triangle/src/main.c | 2 +- src/libwhb/include/whb/proc.h | 2 +- src/libwhb/src/proc.c | 22 ++++++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/samples/gx2/triangle/src/main.c b/samples/gx2/triangle/src/main.c index 373da75..c93277e 100644 --- a/samples/gx2/triangle/src/main.c +++ b/samples/gx2/triangle/src/main.c @@ -43,7 +43,7 @@ int main(int argc, char **argv) int result = 0; WHBLogUdpInit(); - WHBProcInit(TRUE); + WHBProcInit(); WHBGfxInit(); if (!WHBMountSdCard()) { diff --git a/src/libwhb/include/whb/proc.h b/src/libwhb/include/whb/proc.h index 5c20e72..b07cd57 100644 --- a/src/libwhb/include/whb/proc.h +++ b/src/libwhb/include/whb/proc.h @@ -12,7 +12,7 @@ extern "C" { #endif void -WHBProcInit(BOOL fromHBL); +WHBProcInit(); void WHBProcShutdown(); diff --git a/src/libwhb/src/proc.c b/src/libwhb/src/proc.c index 7179ddb..25ada6b 100644 --- a/src/libwhb/src/proc.c +++ b/src/libwhb/src/proc.c @@ -1,14 +1,20 @@ #include #include #include -#include #include +#include +#include #include #include #include #include #include +#define HBL_TITLE_ID (0x0005000013374842) +#define MII_MAKER_JPN_TITLE_ID (0x000500101004A000) +#define MII_MAKER_USA_TITLE_ID (0x000500101004A100) +#define MII_MAKER_EUR_TITLE_ID (0x000500101004A200) + static uint32_t sMainCore; @@ -40,20 +46,24 @@ procHomeButtonDenied(void *context) } void -WHBProcInit(BOOL fromHBL) +WHBProcInit() { - sMainCore = OSGetCoreId(); - sRunning = TRUE; + uint64_t titleID = OSGetTitleID(); // Homebrew Launcher does not like the standard ProcUI application loop, // so instead we disable the home buttom menu and use the home button // to trigger an exit. - sFromHBL = fromHBL; - if (sFromHBL) { + if (titleID == HBL_TITLE_ID || + titleID == MII_MAKER_JPN_TITLE_ID || + titleID == MII_MAKER_USA_TITLE_ID || + titleID == MII_MAKER_EUR_TITLE_ID) { // Important: OSEnableHomeButtonMenu must come before ProcUIInitEx. OSEnableHomeButtonMenu(FALSE); + sFromHBL = TRUE; } + sMainCore = OSGetCoreId(); + sRunning = TRUE; ProcUIInitEx(&procSaveCallback, NULL); ProcUIRegisterCallback(PROCUI_CALLBACK_HOME_BUTTON_DENIED, &procHomeButtonDenied, NULL, 100); }