diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 7aba4ea0..2bbf2304 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -11,6 +11,7 @@ #include "../services/apm.h" #include "../services/pdm.h" #include "../services/caps.h" +#include "../services/pm.h" #include "../kernel/tmem.h" #include "../kernel/event.h" @@ -136,7 +137,7 @@ typedef enum { AppletTvPowerStateMatchingMode_Unknown1 = 1, ///< Unknown. } AppletTvPowerStateMatchingMode; -/// Type values for \ref PerformSystemButtonPressingIfInFocus. +/// Type values for \ref appletPerformSystemButtonPressingIfInFocus. typedef enum { AppletSystemButtonType_HomeButtonShortPressing = 1, ///< Short-pressing with the HOME-button. AppletSystemButtonType_HomeButtonLongPressing = 2, ///< Long-pressing with the HOME-button. @@ -242,6 +243,18 @@ AppletThemeColorType appletGetThemeColorType(void); */ Result appletHomeButtonReaderLockAccessorGetEvent(Event *out_event); +/** + * @brief Gets the CradleStatus. + * @param[out] status Output Dock status. + */ +Result appletGetCradleStatus(u8 *status); + +/** + * @brief Gets the BootMode which originated from \ref pmbmGetBootMode. + * @param[out] mode \ref PmBootMode + */ +Result appletGetBootMode(PmBootMode *mode); + /** * @brief Pushes a storage to the general channel. Used for sending requests to qlaunch. * @note This is not usable under an Application, however it is usable under a LibraryApplet. @@ -910,14 +923,14 @@ Result appletGetGpuErrorDetectedSystemEvent(Event *out_event); /** * @brief Gets the \ref AppletIdentityInfo for the MainApplet. * @note Only available with AppletType_LibraryApplet. - * @param[out] \ref AppletIdentityInfo + * @param[out] info \ref AppletIdentityInfo */ Result appletGetMainAppletIdentityInfo(AppletIdentityInfo *info); /** * @brief Gets the \ref AppletIdentityInfo for the CallerApplet. * @note Only available with AppletType_LibraryApplet. - * @param[out] \ref AppletIdentityInfo + * @param[out] info \ref AppletIdentityInfo */ Result appletGetCallerAppletIdentityInfo(AppletIdentityInfo *info); @@ -933,7 +946,7 @@ Result appletGetCallerAppletIdentityInfoStack(AppletIdentityInfo *stack, s32 cou /** * @brief Gets the \ref AppletIdentityInfo for the NextReturnDestinationApplet. * @note Only available with AppletType_LibraryApplet on [4.0.0+]. - * @param[out] \ref AppletIdentityInfo + * @param[out] info \ref AppletIdentityInfo */ Result appletGetNextReturnDestinationAppletIdentityInfo(AppletIdentityInfo *info); diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 3d15b0b1..86ed6976 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -10,6 +10,7 @@ #include "services/applet.h" #include "services/apm.h" #include "services/caps.h" +#include "services/pm.h" #include "services/sm.h" #include "runtime/env.h" #include "runtime/hosversion.h" @@ -744,7 +745,7 @@ static Result _appletCmdNoInOut32(Service* srv, u32 *out, u64 cmd_id) { return rc; } -static Result _appletCmdNoInOutBool(Service* srv, bool *out, u64 cmd_id) { +static Result _appletCmdNoInOutU8(Service* srv, u8 *out, u64 cmd_id) { IpcCommand c; ipcInitialize(&c); @@ -774,13 +775,20 @@ static Result _appletCmdNoInOutBool(Service* srv, bool *out, u64 cmd_id) { rc = resp->result; if (R_SUCCEEDED(rc) && out) { - *out = resp->out!=0; + *out = resp->out; } } return rc; } +static Result _appletCmdNoInOutBool(Service* srv, bool *out, u64 cmd_id) { + u8 tmp=0; + Result rc = _appletCmdNoInOutU8(srv, &tmp, cmd_id); + if (R_SUCCEEDED(rc) && out) *out = tmp!=0; + return rc; +} + static Result _appletCmdInU8(Service* srv, u8 inval, u64 cmd_id) { IpcCommand c; ipcInitialize(&c); @@ -1140,6 +1148,17 @@ static Result _appletGetPerformanceMode(u32 *out) { return rc; } +Result appletGetCradleStatus(u8 *status) { + return _appletCmdNoInOutU8(&g_appletICommonStateGetter, status, 7); +} + +Result appletGetBootMode(PmBootMode *mode) { + u8 tmp=0; + Result rc = _appletCmdNoInOutU8(&g_appletICommonStateGetter, &tmp, 8); + if (R_SUCCEEDED(rc) && mode) *mode = tmp; + return rc; +} + static Result _appletGetCurrentFocusState(u8 *out) { IpcCommand c; ipcInitialize(&c);