示例#1
0
文件: apt.c 项目: minexew/ctrulib
static bool __handle_incoming_parameter() {
	u8 type;

	aptOpenSession();
	APT_ReceiveParameter(NULL, currentAppId, 0x1000, aptParameters, NULL, &type);
	aptCloseSession();

	switch(type)
	{
	case 0x1: // Application just started.
		aptAppStarted();
		return true;

	case 0x3: // "Launched library applet finished loading"
		aptSetStatus(APP_APPLETSTARTED);
		return true;
	case 0xA: // "Launched library applet closed"
		if(__apt_launchapplet_parambuf && __apt_launchapplet_parambufsize)memcpy(__apt_launchapplet_parambuf, aptParameters, __apt_launchapplet_parambufsize);
		aptSetStatus(APP_APPLETCLOSED);
		return true;
	case 0xB: // Just returned from menu.
		GSPGPU_AcquireRight(NULL, 0x0);
		GSPGPU_RestoreVramSysArea(NULL);
		aptAppletUtility_Exit_RetToApp(0);
		aptSetStatus(APP_RUNNING);
		return true;

	case 0xC: // Exiting application.
		aptSetStatus(APP_EXITING);
		return false;
	}

	return true;
}
示例#2
0
Result aptInit(void)
{
	Result ret=0;

	if (aptInitialised) return ret;

	aptStatusMutex = 0;

	// Initialize APT stuff, escape load screen.
	ret = __apt_initservicehandle();
	if(ret!=0)return ret;
	if((ret=APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle)))return ret;
	svcCloseHandle(aptuHandle);

	currentAppId = __apt_appid;

	svcCreateEvent(&aptStatusEvent, 0);
	svcCreateEvent(&aptSleepSync, 0);

	if(!aptIsCrippled())
	{
		aptOpenSession();
		if((ret=APT_Initialize(NULL, currentAppId, &aptEvents[0], &aptEvents[1])))return ret;
		aptCloseSession();
		
		aptOpenSession();
		if((ret=APT_Enable(NULL, 0x0)))return ret;
		aptCloseSession();
		
		// create APT close event
		svcCreateEvent(&aptEvents[2], 0);

		// After a cycle of APT_Finalize+APT_Initialize APT thinks the
		// application is suspended, so we need to tell it to unsuspend us.
		if (aptIsReinit())
		{
			aptOpenSession();
			APT_PrepareToJumpToApplication(NULL, 0x0);
			aptCloseSession();

			aptOpenSession();
			APT_JumpToApplication(NULL, 0x0, 0x0, 0x0);
			aptCloseSession();
		}
		
		aptOpenSession();
		if((ret=APT_NotifyToWait(NULL, currentAppId)))return ret;
		aptCloseSession();

		// create APT event handler thread
		svcCreateThread(&aptEventHandlerThread, aptEventHandler, 0x0,
			(u32*)(&aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]), 0x31, 0xfffffffe);
	} else
		aptAppStarted();

	aptInitialised = true;

	return 0;
}
示例#3
0
文件: apt.c 项目: Almamu/ctrulib
Result aptInit(void)
{
	Result ret=0;

	if (aptInitialised) return ret;

	// Initialize APT stuff, escape load screen.
	ret = __apt_initservicehandle();
	if(ret!=0)return ret;
	if((ret=APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle)))return ret;
	svcCloseHandle(aptuHandle);

	currentAppId = __apt_appid;

	svcCreateEvent(&aptStatusEvent, 0);
	svcCreateEvent(&aptSleepSync, 0);

	if(!(__system_runflags&RUNFLAG_APTWORKAROUND))
	{
		aptOpenSession();
		if((ret=APT_Initialize(NULL, currentAppId, &aptEvents[0], &aptEvents[1])))return ret;
		aptCloseSession();
		
		aptOpenSession();
		if((ret=APT_Enable(NULL, 0x0)))return ret;
		aptCloseSession();
		
		aptOpenSession();
		if((ret=APT_NotifyToWait(NULL, currentAppId)))return ret;
		aptCloseSession();
		
		// create APT event handler thread
		svcCreateThread(&aptEventHandlerThread, aptEventHandler, 0x0,
			(u32*)(&aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]), 0x31, 0xfffffffe);
	} else
		aptAppStarted();

	aptInitialised = true;

	return 0;
}
示例#4
0
文件: apt.c 项目: botanyaki/ctrulib
Result aptInit(void)
{
	Result ret=0;

	if (AtomicPostIncrement(&aptRefCount)) return 0;

	// Initialize APT stuff, escape load screen.
	ret = __apt_initservicehandle();
	if(R_FAILED(ret)) goto _fail;
	if(R_FAILED(ret=APT_GetLockHandle(0x0, &aptLockHandle))) goto _fail;
	svcCloseHandle(aptuHandle);

	currentAppId = envGetAptAppId();

	svcCreateEvent(&aptStatusEvent, 0);
	svcCreateEvent(&aptSleepSync, 0);
	LightLock_Init(&aptStatusMutex);
	aptStatus=0;

	if(!aptIsCrippled())
	{
		aptOpenSession();
		if(R_FAILED(ret=APT_Initialize(currentAppId, &aptEvents[0], &aptEvents[1])))return ret;
		aptCloseSession();
		
		aptOpenSession();
		if(R_FAILED(ret=APT_Enable(0x0))) goto _fail;
		aptCloseSession();
		
		// create APT close event
		svcCreateEvent(&aptEvents[2], 0);

		// After a cycle of APT_Finalize+APT_Initialize APT thinks the
		// application is suspended, so we need to tell it to unsuspend us.
		if (aptIsReinit())
		{
			aptOpenSession();
			APT_PrepareToJumpToApplication(0x0);
			aptCloseSession();

			aptOpenSession();
			APT_JumpToApplication(0x0, 0x0, 0x0);
			aptCloseSession();
		}
		
		aptOpenSession();
		if(R_FAILED(ret=APT_NotifyToWait(currentAppId)))goto _fail;
		aptCloseSession();

		// create APT event handler thread
		aptEventHandlerThread = threadCreate(aptEventHandler, 0x0, APT_HANDLER_STACKSIZE, 0x31, -2, true);

		// Wait for the state to become APT_RUNNING
		aptWaitStatusEvent();
	} else
		aptAppStarted();

	return 0;

_fail:
	AtomicDecrement(&aptRefCount);
	return ret;
}