Add appletBeginBlockingHomeButton() and appletEndBlockingHomeButton() (#165)

This commit is contained in:
neonsea 2018-09-09 20:55:53 +03:00 committed by fincs
parent cd813ddb60
commit 20a39ef86c
2 changed files with 81 additions and 0 deletions

View File

@ -54,6 +54,15 @@ Result appletCreateManagedDisplayLayer(u64 *out);
Result appletGetDesiredLanguage(u64 *LanguageCode);
/**
* @brief Blocks the usage of the home button.
* @param val Unknown nanoseconds. Value 0 can be used.
* @note Can only be used in regularapps.
*/
Result appletBeginBlockingHomeButton(s64 val);
Result appletEndBlockingHomeButton(void);
/**
* @brief Controls whether screenshot-capture is allowed.
* @param val 0 = disable, 1 = enable.

View File

@ -569,6 +569,78 @@ Result appletGetDesiredLanguage(u64 *LanguageCode) {
return rc;
}
Result appletBeginBlockingHomeButton(s64 val) {
IpcCommand c;
ipcInitialize(&c);
if (!serviceIsActive(&g_appletSrv) || (__nx_applet_type!=AppletType_Application
&& __nx_applet_type!=AppletType_SystemApplication))
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
struct {
u64 magic;
u64 cmd_id;
s64 val;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 32;
raw->val = val;
Result rc = serviceIpcDispatch(&g_appletIFunctions);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
}
return rc;
}
Result appletEndBlockingHomeButton(void) {
IpcCommand c;
ipcInitialize(&c);
if (!serviceIsActive(&g_appletSrv) || (__nx_applet_type!=AppletType_Application
&& __nx_applet_type!=AppletType_SystemApplication))
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
struct {
u64 magic;
u64 cmd_id;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 33;
Result rc = serviceIpcDispatch(&g_appletIFunctions);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
}
return rc;
}
void appletNotifyRunning(u8 *out) {
IpcCommand c;
ipcInitialize(&c);