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.
|
/// Signals that the app is ready to sleep.
|
||||||
void aptSignalReadyForSleep(void);
|
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.
|
* @brief Gets the menu's app ID.
|
||||||
* @return 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;
|
APT_AppStatus aptStatusBeforeSleep = APP_NOTINITIALIZED;
|
||||||
u32 aptStatusPower;
|
u32 aptStatusPower;
|
||||||
Handle aptSleepSync;
|
Handle aptSleepSync;
|
||||||
|
static bool aptSleepAllowed = true;
|
||||||
|
|
||||||
u32 aptParameters[0x1000/4]; //TEMP
|
u32 aptParameters[0x1000/4]; //TEMP
|
||||||
|
|
||||||
@ -336,14 +337,22 @@ static void __handle_notification(void) {
|
|||||||
|
|
||||||
case APTSIGNAL_PREPARESLEEP:
|
case APTSIGNAL_PREPARESLEEP:
|
||||||
// Reply to sleep-request.
|
// Reply to sleep-request.
|
||||||
aptStatusBeforeSleep = aptGetStatus();
|
if(aptIsSleepAllowed())
|
||||||
aptSetStatus(APP_PREPARE_SLEEPMODE);
|
{
|
||||||
svcWaitSynchronization(aptSleepSync, U64_MAX);
|
aptStatusBeforeSleep = aptGetStatus();
|
||||||
svcClearEvent(aptSleepSync);
|
aptSetStatus(APP_PREPARE_SLEEPMODE);
|
||||||
|
svcWaitSynchronization(aptSleepSync, U64_MAX);
|
||||||
|
svcClearEvent(aptSleepSync);
|
||||||
|
|
||||||
aptOpenSession();
|
aptOpenSession();
|
||||||
APT_ReplySleepQuery(currentAppId, 0x1);
|
APT_ReplySleepQuery(currentAppId, 0x1);
|
||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
aptOpenSession();
|
||||||
|
APT_ReplySleepQuery(currentAppId, 0x0);
|
||||||
|
aptCloseSession();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case APTSIGNAL_ENTERSLEEP:
|
case APTSIGNAL_ENTERSLEEP:
|
||||||
@ -710,6 +719,16 @@ void aptSignalReadyForSleep(void)
|
|||||||
svcSignalEvent(aptSleepSync);
|
svcSignalEvent(aptSleepSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool aptIsSleepAllowed()
|
||||||
|
{
|
||||||
|
return aptSleepAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void aptSetSleepAllowed(bool allowed)
|
||||||
|
{
|
||||||
|
aptSleepAllowed = allowed;
|
||||||
|
}
|
||||||
|
|
||||||
Result APT_GetLockHandle(u16 flags, Handle* lockHandle)
|
Result APT_GetLockHandle(u16 flags, Handle* lockHandle)
|
||||||
{
|
{
|
||||||
u32* cmdbuf=getThreadCommandBuffer();
|
u32* cmdbuf=getThreadCommandBuffer();
|
||||||
|
Loading…
Reference in New Issue
Block a user