add an exit request hook type, allow to delay exit (#183)

* add an exit request hook type, allow to delay exit
* appletMainLoop: return false on exit request msg
This commit is contained in:
Samuel P 2018-10-09 17:04:33 +02:00 committed by yellows8
parent 8178c0fa45
commit 74ebf370dd
2 changed files with 15 additions and 5 deletions

View File

@ -27,6 +27,7 @@ typedef enum {
AppletHookType_OnFocusState = 0, ///< FocusState changed.
AppletHookType_OnOperationMode, ///< OperationMode changed.
AppletHookType_OnPerformanceMode, ///< PerformanceMode changed.
AppletHookType_OnExitRequest, ///< Exit requested.
AppletHookType_Max, ///< Number of applet hook types.
} AppletHookType;
@ -63,6 +64,12 @@ Result appletBeginBlockingHomeButton(s64 val);
Result appletEndBlockingHomeButton(void);
/**
* @brief Delay exiting until appletUnlockExit is called
*/
Result appletLockExit(void);
Result appletUnlockExit(void);
/**
* @brief Controls whether screenshot-capture is allowed.
* @param val 0 = disable, 1 = enable.

View File

@ -71,8 +71,6 @@ static Result _appletSetOperationModeChangedNotification(u8 flag);
static Result _appletSetPerformanceModeChangedNotification(u8 flag);
static Result _appletSelfExit(void);
//static Result _appletLockExit(void);
//static Result _appletUnlockExit(void);
//static Result _appletSetTerminateResult(Result res);
static Result _appletExitProcessAndReturn(void);
@ -895,13 +893,13 @@ static Result _appletSelfExit(void) {
return _appletCmdNoIO(&g_appletISelfController, 0);
}
/*static Result _appletLockExit(void) {
Result appletLockExit(void) {
return _appletCmdNoIO(&g_appletISelfController, 1);
}
static Result _appletUnlockExit(void) {
Result appletUnlockExit(void) {
return _appletCmdNoIO(&g_appletISelfController, 2);
}*/
}
Result appletSetScreenShotPermission(s32 val) {
IpcCommand c;
@ -1211,6 +1209,11 @@ bool appletMainLoop(void) {
}
switch(msg) {
case 0x4:
appletCallHook(AppletHookType_OnExitRequest);
return false;
break;
case 0xF:
rc = _appletGetCurrentFocusState(&g_appletFocusState);
if (R_FAILED(rc))