]> Chaos Git - corbenik/ctrulib.git/commitdiff
With RUNFLAG_APTWORKAROUND enabled, at the start of aptReturnToMenu just set the...
authoryellows8 <yellows8@users.noreply.github.com>
Wed, 19 Nov 2014 04:48:50 +0000 (23:48 -0500)
committeryellows8 <yellows8@users.noreply.github.com>
Wed, 19 Nov 2014 04:48:50 +0000 (23:48 -0500)
libctru/source/services/apt.c

index db3b011f68aa81e1dae8a67c767e8e58a14897ae..4f417fa949127d317e1d5183ed2924fe31155f0d 100644 (file)
@@ -145,6 +145,13 @@ void aptReturnToMenu()
        u32 ns_capinfo[0x20>>2];
        u32 tmp_params[0x20>>2];
 
+       if(__system_runflags&RUNFLAG_APTWORKAROUND)
+       {
+               svcClearEvent(aptStatusEvent);
+               aptSetStatus(APP_EXITING);
+               return;
+       }
+
        // This is only executed when ret-to-menu was triggered via the home-button, not the power-button.
        if(aptGetStatusPower() == 0)
        {
@@ -209,12 +216,15 @@ void aptReturnToMenu()
 
 static void __handle_notification() {
        u8 type;
+       Result ret=0;
 
        // Get notification type.
        aptOpenSession();
-       APT_InquireNotification(NULL, currentAppId, &type);
+       ret = APT_InquireNotification(NULL, currentAppId, &type);
        aptCloseSession();
 
+       if(ret!=0)return;
+
        switch(type)
        {
        case APTSIGNAL_HOMEBUTTON:
@@ -367,7 +377,7 @@ Result aptInit(void)
 
 void aptExit()
 {
-       aptAppletUtility_Exit_RetToApp();
+       if(!(__system_runflags&RUNFLAG_APTWORKAROUND))aptAppletUtility_Exit_RetToApp();
 
        // This is only executed when application-termination was triggered via the home-menu power-off screen.
        if(aptGetStatusPower() == 1)
@@ -399,6 +409,8 @@ bool aptMainLoop()
 {
        while(1)
        {
+               //if(__system_runflags&RUNFLAG_APTWORKAROUND)__handle_notification();
+
                switch(aptGetStatus())
                {
                        case APP_RUNNING:
@@ -461,11 +473,8 @@ APP_STATUS aptGetStatus()
 
 void aptSetStatus(APP_STATUS status)
 {
-       u32 prevstatus;
-
        svcWaitSynchronization(aptStatusMutex, U64_MAX);
 
-       prevstatus = aptStatus;
        aptStatus = status;
 
        //if(prevstatus != APP_NOTINITIALIZED)
@@ -876,8 +885,14 @@ Result APT_CheckNew3DS(Handle* handle, u8 *out)
        }
 
        aptOpenSession();
-       if(currentAppId==APPID_APPLICATION)ret = APT_CheckNew3DS_Application(NULL, out);
-       ret = APT_CheckNew3DS_System(NULL, out);
+       if(currentAppId==APPID_APPLICATION)
+       {
+               ret = APT_CheckNew3DS_Application(NULL, out);
+       }
+       else
+       {
+               ret = APT_CheckNew3DS_System(NULL, out);
+       }
        aptCloseSession();
 
        __apt_new3dsflag_initialized = 1;