]> Chaos Git - corbenik/ctrulib.git/commitdiff
Implemented APT_GetAppletManInfo. Implemented loading the menu AppID with APT_GetAppl...
authoryellows8 <yellowstar6@gmail.com>
Thu, 22 May 2014 04:22:56 +0000 (00:22 -0400)
committeryellows8 <yellowstar6@gmail.com>
Thu, 22 May 2014 04:22:56 +0000 (00:22 -0400)
libctru/include/ctr/APT.h
libctru/source/APT.c

index a5c2e94c00929655bb8e40f72cc0063cb013b2cc..3d5f5fa52e4f67b11f51361d6a2d5b117ade2f04 100644 (file)
@@ -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);
index cdc3fd23fc404f7f4f593ea80f0c3541ce4f00e7..7e54cea34055c7946d0c605e11ddec735d5b50a1 100644 (file)
@@ -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;