From ce92c8b20db15be0da559ccfbe7fac61a394177f Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 22 May 2014 00:22:56 -0400 Subject: [PATCH] Implemented APT_GetAppletManInfo. Implemented loading the menu AppID with APT_GetAppletManInfo, instead of using a hard-coded AppID. --- libctru/include/ctr/APT.h | 2 ++ libctru/source/APT.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/libctru/include/ctr/APT.h b/libctru/include/ctr/APT.h index a5c2e94..3d5f5fa 100644 --- a/libctru/include/ctr/APT.h +++ b/libctru/include/ctr/APT.h @@ -30,10 +30,12 @@ u32 aptGetStatusPower();//This can be used when the status is APP_SUSPEND* to ch void aptSetStatusPower(u32 status); void aptReturnToMenu();//This should be called by the user application when aptGetStatus() returns APP_SUSPENDING, not calling this will result in return-to-menu being disabled with the status left at APP_SUSPENDING. This function will not return until the system returns to the application, or when the status was changed to APP_EXITING. void aptWaitStatusEvent(); +NS_APPID aptGetMenuAppID(); Result APT_GetLockHandle(Handle* handle, u16 flags, Handle* lockHandle); Result APT_Initialize(Handle* handle, NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2); Result APT_Enable(Handle* handle, u32 a); +Result APT_GetAppletManInfo(Handle* handle, u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid); Result APT_PrepareToJumpToHomeMenu(Handle* handle); Result APT_JumpToHomeMenu(Handle* handle, u32 a, u32 b, u32 c); Result APT_InquireNotification(Handle* handle, u32 appID, u8* signalType); diff --git a/libctru/source/APT.c b/libctru/source/APT.c index cdc3fd2..7e54cea 100644 --- a/libctru/source/APT.c +++ b/libctru/source/APT.c @@ -104,8 +104,20 @@ void aptAppletUtility_Exit_RetToApp() aptCloseSession(); } +NS_APPID aptGetMenuAppID() +{ + NS_APPID menu_appid; + + aptOpenSession(); + APT_GetAppletManInfo(NULL, 0xff, NULL, NULL, &menu_appid, NULL); + aptCloseSession(); + + return menu_appid; +} + void aptReturnToMenu() { + NS_APPID menu_appid; u32 tmp0 = 1, tmp1 = 0; u32 ns_capinfo[0x20>>2]; u32 tmp_params[0x20>>2]; @@ -128,8 +140,10 @@ void aptReturnToMenu() aptInitCaptureInfo(ns_capinfo); + menu_appid = aptGetMenuAppID(); + aptOpenSession(); - APT_SendParameter(NULL, currentAppId, 0x101, 0x20, ns_capinfo, 0x0, 0x10); + APT_SendParameter(NULL, currentAppId, menu_appid, 0x20, ns_capinfo, 0x0, 0x10); aptCloseSession(); aptOpenSession(); @@ -450,6 +464,24 @@ Result APT_Enable(Handle* handle, u32 a) return cmdbuf[1]; } +Result APT_GetAppletManInfo(Handle* handle, u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid) +{ + if(!handle)handle=&aptuHandle; + u32* cmdbuf=getThreadCommandBuffer(); + cmdbuf[0]=0x00050040; //request header code + cmdbuf[1]=inval; + + Result ret=0; + if((ret=svc_sendSyncRequest(*handle)))return ret; + + if(outval8)*outval8=cmdbuf[2]; + if(outval32)*outval32=cmdbuf[3]; + if(menu_appid)*menu_appid=cmdbuf[4]; + if(active_appid)*active_appid=cmdbuf[5]; + + return cmdbuf[1]; +} + Result APT_InquireNotification(Handle* handle, u32 appID, u8* signalType) { if(!handle)handle=&aptuHandle;