Allow toggling sleep mode.
This commit is contained in:
parent
863ea8ef68
commit
c81239a407
@ -135,6 +135,18 @@ void aptWaitStatusEvent(void);
|
||||
/// Signals that the app is ready to sleep.
|
||||
void aptSignalReadyForSleep(void);
|
||||
|
||||
/**
|
||||
* @brief Gets whether to allow the system to enter sleep mode.
|
||||
* @return Whether sleep mode is allowed.
|
||||
*/
|
||||
bool aptIsSleepAllowed();
|
||||
|
||||
/**
|
||||
* @brief Sets whether to allow the system to enter sleep mode.
|
||||
* @param allowed Whether to allow sleep mode.
|
||||
*/
|
||||
void aptSetSleepAllowed(bool allowed);
|
||||
|
||||
/**
|
||||
* @brief Gets the menu's app ID.
|
||||
* @return The menu's app ID.
|
||||
|
@ -37,6 +37,7 @@ APT_AppStatus aptStatus = APP_NOTINITIALIZED;
|
||||
APT_AppStatus aptStatusBeforeSleep = APP_NOTINITIALIZED;
|
||||
u32 aptStatusPower;
|
||||
Handle aptSleepSync;
|
||||
static bool aptSleepAllowed = true;
|
||||
|
||||
u32 aptParameters[0x1000/4]; //TEMP
|
||||
|
||||
@ -336,14 +337,22 @@ static void __handle_notification(void) {
|
||||
|
||||
case APTSIGNAL_PREPARESLEEP:
|
||||
// Reply to sleep-request.
|
||||
aptStatusBeforeSleep = aptGetStatus();
|
||||
aptSetStatus(APP_PREPARE_SLEEPMODE);
|
||||
svcWaitSynchronization(aptSleepSync, U64_MAX);
|
||||
svcClearEvent(aptSleepSync);
|
||||
if(aptIsSleepAllowed())
|
||||
{
|
||||
aptStatusBeforeSleep = aptGetStatus();
|
||||
aptSetStatus(APP_PREPARE_SLEEPMODE);
|
||||
svcWaitSynchronization(aptSleepSync, U64_MAX);
|
||||
svcClearEvent(aptSleepSync);
|
||||
|
||||
aptOpenSession();
|
||||
APT_ReplySleepQuery(currentAppId, 0x1);
|
||||
aptCloseSession();
|
||||
aptOpenSession();
|
||||
APT_ReplySleepQuery(currentAppId, 0x1);
|
||||
aptCloseSession();
|
||||
} else
|
||||
{
|
||||
aptOpenSession();
|
||||
APT_ReplySleepQuery(currentAppId, 0x0);
|
||||
aptCloseSession();
|
||||
}
|
||||
break;
|
||||
|
||||
case APTSIGNAL_ENTERSLEEP:
|
||||
@ -710,6 +719,16 @@ void aptSignalReadyForSleep(void)
|
||||
svcSignalEvent(aptSleepSync);
|
||||
}
|
||||
|
||||
bool aptIsSleepAllowed()
|
||||
{
|
||||
return aptSleepAllowed;
|
||||
}
|
||||
|
||||
void aptSetSleepAllowed(bool allowed)
|
||||
{
|
||||
aptSleepAllowed = allowed;
|
||||
}
|
||||
|
||||
Result APT_GetLockHandle(u16 flags, Handle* lockHandle)
|
||||
{
|
||||
u32* cmdbuf=getThreadCommandBuffer();
|
||||
|
Loading…
Reference in New Issue
Block a user