Allow blocking HOME button

Signed-off-by: Alex Taber <alexftaber@gmail.com>
This commit is contained in:
LiquidFenrir 2018-05-28 22:40:49 +02:00 committed by fincs
parent d0b6343342
commit 9b4ac1118d
2 changed files with 25 additions and 2 deletions

View File

@ -158,6 +158,18 @@ bool aptIsSleepAllowed(void);
*/
void aptSetSleepAllowed(bool allowed);
/**
* @brief Gets whether to allow the system to go back to HOME menu.
* @return Whether going back to HOME menu is allowed.
*/
bool aptIsHomeAllowed(void);
/**
* @brief Sets whether to allow the system to go back to HOME menu.
* @param allowed Whether going back to HOME menu is allowed.
*/
void aptSetHomeAllowed(bool allowed);
/**
* @brief Processes the current APT status. Generally used within a main loop.
* @return Whether the application should continue running.

View File

@ -41,6 +41,7 @@ enum
static u8 aptHomeButtonState;
static u32 aptFlags = FLAG_ALLOWSLEEP;
static bool home_allowed = false;
static u32 aptParameters[0x1000/4];
static u64 aptChainloadTid;
static u8 aptChainloadMediatype;
@ -267,6 +268,16 @@ void aptSetSleepAllowed(bool allowed)
}
}
bool aptIsHomeAllowed(void)
{
return home_allowed;
}
void aptSetHomeAllowed(bool allowed)
{
home_allowed = allowed;
}
void aptSetChainloader(u64 programID, u8 mediatype)
{
aptChainloadTid = programID;
@ -338,10 +349,10 @@ void aptEventHandler(void *arg)
switch (signal)
{
case APTSIGNAL_HOMEBUTTON:
if (!aptHomeButtonState) aptHomeButtonState = 1;
if (!aptHomeButtonState && aptIsHomeAllowed()) aptHomeButtonState = 1;
break;
case APTSIGNAL_HOMEBUTTON2:
if (!aptHomeButtonState) aptHomeButtonState = 2;
if (!aptHomeButtonState && aptIsHomeAllowed()) aptHomeButtonState = 2;
break;
case APTSIGNAL_SLEEP_QUERY:
APT_ReplySleepQuery(envGetAptAppId(), aptIsSleepAllowed() ? APTREPLY_ACCEPT : APTREPLY_REJECT);