mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Added AppletIdentityInfo and AppletId_application. Moved sections in applet.h to match the applet.c order. Added/updated comments/docs. Check applet-type in _appletExitProcessAndReturn. Added appletSetScreenShotAppletIdentityInfo, appletGetMainAppletIdentityInfo, appletGetCallerAppletIdentityInfo, appletGetCallerAppletIdentityInfoStack, and appletGetNextReturnDestinationAppletIdentityInfo.
This commit is contained in:
parent
b59682652d
commit
974f5b9a1b
@ -83,6 +83,7 @@ typedef enum {
|
|||||||
|
|
||||||
/// AppletId
|
/// AppletId
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
AppletId_application = 0x01, ///< Application. Not valid for use with LibraryApplets.
|
||||||
AppletId_overlayDisp = 0x02, ///< 010000000000100C "overlayDisp"
|
AppletId_overlayDisp = 0x02, ///< 010000000000100C "overlayDisp"
|
||||||
AppletId_qlaunch = 0x03, ///< 0100000000001000 "qlaunch" (SystemAppletMenu)
|
AppletId_qlaunch = 0x03, ///< 0100000000001000 "qlaunch" (SystemAppletMenu)
|
||||||
AppletId_starter = 0x04, ///< 0100000000001012 "starter"
|
AppletId_starter = 0x04, ///< 0100000000001012 "starter"
|
||||||
@ -179,6 +180,13 @@ typedef struct {
|
|||||||
LibAppletExitReason exitreason; ///< Set by \ref appletHolderJoin using the output from cmd GetResult, see \ref LibAppletExitReason.
|
LibAppletExitReason exitreason; ///< Set by \ref appletHolderJoin using the output from cmd GetResult, see \ref LibAppletExitReason.
|
||||||
} AppletHolder;
|
} AppletHolder;
|
||||||
|
|
||||||
|
/// IdentityInfo
|
||||||
|
typedef struct {
|
||||||
|
AppletId appletId; ///< \ref AppletId
|
||||||
|
u32 pad; ///< Padding.
|
||||||
|
u64 titleID; ///< titleID, only set with appletId == ::AppletId_application.
|
||||||
|
} AppletIdentityInfo;
|
||||||
|
|
||||||
/// Attributes for launching applications for Quest.
|
/// Attributes for launching applications for Quest.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 unk_x0; ///< See AppletApplicationAttribute::unk_x0.
|
u32 unk_x0; ///< See AppletApplicationAttribute::unk_x0.
|
||||||
@ -200,7 +208,10 @@ Result appletInitialize(void);
|
|||||||
/// Exit applet, called automatically during app exit.
|
/// Exit applet, called automatically during app exit.
|
||||||
void appletExit(void);
|
void appletExit(void);
|
||||||
|
|
||||||
|
/// Get the cached AppletResourceUserId.
|
||||||
Result appletGetAppletResourceUserId(u64 *out);
|
Result appletGetAppletResourceUserId(u64 *out);
|
||||||
|
|
||||||
|
/// Get the \ref AppletType.
|
||||||
AppletType appletGetAppletType(void);
|
AppletType appletGetAppletType(void);
|
||||||
|
|
||||||
/// Sets the state field for \ref AppletThemeColorType.
|
/// Sets the state field for \ref AppletThemeColorType.
|
||||||
@ -209,6 +220,8 @@ void appletSetThemeColorType(AppletThemeColorType theme);
|
|||||||
/// Gets the state field for \ref AppletThemeColorType. Used internally by \ref libappletArgsCreate.
|
/// Gets the state field for \ref AppletThemeColorType. Used internally by \ref libappletArgsCreate.
|
||||||
AppletThemeColorType appletGetThemeColorType(void);
|
AppletThemeColorType appletGetThemeColorType(void);
|
||||||
|
|
||||||
|
// IFunctions for AppletType_*Application (IApplicationFunctions).
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Pops a LaunchParameter AppletStorage, the storage will be removed from sysmodule state during this.
|
* @brief Pops a LaunchParameter AppletStorage, the storage will be removed from sysmodule state during this.
|
||||||
* @param s Output storage.
|
* @param s Output storage.
|
||||||
@ -373,6 +386,68 @@ Result appletQueryApplicationPlayStatisticsByUid(u128 userID, PdmApplicationPlay
|
|||||||
*/
|
*/
|
||||||
Result appletGetGpuErrorDetectedSystemEvent(Event *out_event);
|
Result appletGetGpuErrorDetectedSystemEvent(Event *out_event);
|
||||||
|
|
||||||
|
// IFunctions for AppletType_OverlayApplet (IOverlayFunctions).
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stops forwarding the input to the foreground app, works only in the Overlay applet context.
|
||||||
|
* @note You have to call this to receive inputs through the hid service when running as the overlay applet.
|
||||||
|
*/
|
||||||
|
Result appletBeginToWatchShortHomeButtonMessage(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Forwards input to the foreground app, works only in the Overlay applet context.
|
||||||
|
* @note After calling this the overlay applet won't receive any input until \ref appletBeginToWatchShortHomeButtonMessage is called again.
|
||||||
|
*/
|
||||||
|
Result appletEndToWatchShortHomeButtonMessage(void);
|
||||||
|
|
||||||
|
// ICommonStateGetter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get an event that fires when the home button is pressed, doesn't interfere with home menu. This event does not auto clear.
|
||||||
|
* @note Doesn't fire for long press.
|
||||||
|
*/
|
||||||
|
Result appletHomeButtonReaderLockAccessorGetEvent(Event *out_event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
||||||
|
* @note This uses \ref appletStorageClose automatically.
|
||||||
|
* @param s Storage object.
|
||||||
|
*/
|
||||||
|
Result appletPushToGeneralChannel(AppletStorage *s);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets whether VrMode is enabled.
|
||||||
|
* @note Only available with [3.0.0+].
|
||||||
|
* @param out Output flag
|
||||||
|
*/
|
||||||
|
Result appletIsVrModeEnabled(bool *out);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets whether VrMode is enabled.
|
||||||
|
* @note This is only fully usable system-side with [6.0.0+].
|
||||||
|
* @note For checking Parental Controls, see \ref pctlIsStereoVisionPermitted.
|
||||||
|
* @note On pre-7.0.0 this uses cmd SetVrModeEnabled internally, while on [7.0.0+] this uses cmds BeginVrModeEx/EndVrModeEx.
|
||||||
|
* @param flag Flag
|
||||||
|
*/
|
||||||
|
Result appletSetVrModeEnabled(bool flag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the \ref ApmCpuBoostMode.
|
||||||
|
* @note Only available with [7.0.0+] (not fully usable system-side with 6.x).
|
||||||
|
* @param mode \ref ApmCpuBoostMode.
|
||||||
|
*/
|
||||||
|
Result appletSetCpuBoostMode(ApmCpuBoostMode mode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the current PerformanceConfiguration.
|
||||||
|
* @note Only available with [7.0.0+].
|
||||||
|
* @param PerformanceConfiguration Output PerformanceConfiguration.
|
||||||
|
*/
|
||||||
|
Result appletGetCurrentPerformanceConfiguration(u32 *PerformanceConfiguration);
|
||||||
|
|
||||||
|
// ISelfController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delay exiting until \ref appletUnlockExit is called, with a 15 second timeout once exit is requested.
|
* @brief Delay exiting until \ref appletUnlockExit is called, with a 15 second timeout once exit is requested.
|
||||||
* @note When exit is requested \ref appletMainLoop will return false, hence any main-loop using appletMainLoop will exit. This allows the app to handle cleanup post-main-loop instead of being force-terminated.
|
* @note When exit is requested \ref appletMainLoop will return false, hence any main-loop using appletMainLoop will exit. This allows the app to handle cleanup post-main-loop instead of being force-terminated.
|
||||||
@ -406,6 +481,12 @@ Result appletSetScreenShotPermission(AppletScreenShotPermission permission);
|
|||||||
*/
|
*/
|
||||||
Result appletSetRestartMessageEnabled(bool flag);
|
Result appletSetRestartMessageEnabled(bool flag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the \ref AppletIdentityInfo for screenshots.
|
||||||
|
* @param[in] info \ref AppletIdentityInfo
|
||||||
|
*/
|
||||||
|
Result appletSetScreenShotAppletIdentityInfo(AppletIdentityInfo *info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets ControllerFirmwareUpdateSection.
|
* @brief Sets ControllerFirmwareUpdateSection.
|
||||||
* @note Only available with [3.0.0+].
|
* @note Only available with [3.0.0+].
|
||||||
@ -548,61 +629,39 @@ Result appletGetProgramTotalActiveTime(u64 *activeTime);
|
|||||||
*/
|
*/
|
||||||
Result appletSetApplicationAlbumUserData(const void* buffer, size_t size);
|
Result appletSetApplicationAlbumUserData(const void* buffer, size_t size);
|
||||||
|
|
||||||
/**
|
// ILibraryAppletSelfAccessor
|
||||||
* @brief Stops forwarding the input to the foreground app, works only in the Overlay applet context.
|
|
||||||
* @note You have to call this to receive inputs through the hid service when running as the overlay applet.
|
|
||||||
*/
|
|
||||||
Result appletBeginToWatchShortHomeButtonMessage(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Forwards input to the foreground app, works only in the Overlay applet context.
|
* @brief Gets the \ref AppletIdentityInfo for the MainApplet.
|
||||||
* @note After calling this the overlay applet won't receive any input until \ref appletBeginToWatchShortHomeButtonMessage is called again.
|
* @note Only available with AppletType_LibraryApplet.
|
||||||
|
* @param[out] \ref AppletIdentityInfo
|
||||||
*/
|
*/
|
||||||
Result appletEndToWatchShortHomeButtonMessage(void);
|
Result appletGetMainAppletIdentityInfo(AppletIdentityInfo *info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get an event that fires when the home button is pressed, doesn't interfere with home menu. This event does not auto clear.
|
* @brief Gets the \ref AppletIdentityInfo for the CallerApplet.
|
||||||
* @note Doesn't fire for long press.
|
* @note Only available with AppletType_LibraryApplet.
|
||||||
|
* @param[out] \ref AppletIdentityInfo
|
||||||
*/
|
*/
|
||||||
Result appletHomeButtonReaderLockAccessorGetEvent(Event *out_event);
|
Result appletGetCallerAppletIdentityInfo(AppletIdentityInfo *info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Pushes a storage to the general channel. Used for sending requests to qlaunch.
|
* @brief Gets an array of \ref AppletIdentityInfo for the CallerStack.
|
||||||
* @note This is not usable under an Application, however it is usable under a LibraryApplet.
|
* @note Only available with AppletType_LibraryApplet on [3.0.0+].
|
||||||
* @note This uses \ref appletStorageClose automatically.
|
* @param[out] stack Output array of \ref AppletIdentityInfo.
|
||||||
* @param s Storage object.
|
* @param[in] count Size of the stack array.
|
||||||
|
* @param[out] total_out Total output entries.
|
||||||
*/
|
*/
|
||||||
Result appletPushToGeneralChannel(AppletStorage *s);
|
Result appletGetCallerAppletIdentityInfoStack(AppletIdentityInfo *stack, s32 count, s32 *total_out);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets whether VrMode is enabled.
|
* @brief Gets the \ref AppletIdentityInfo for the NextReturnDestinationApplet.
|
||||||
* @note Only available with [3.0.0+].
|
* @note Only available with AppletType_LibraryApplet on [4.0.0+].
|
||||||
* @param out Output flag
|
* @param[out] \ref AppletIdentityInfo
|
||||||
*/
|
*/
|
||||||
Result appletIsVrModeEnabled(bool *out);
|
Result appletGetNextReturnDestinationAppletIdentityInfo(AppletIdentityInfo *info);
|
||||||
|
|
||||||
/**
|
// ILibraryAppletCreator
|
||||||
* @brief Sets whether VrMode is enabled.
|
|
||||||
* @note This is only fully usable system-side with [6.0.0+].
|
|
||||||
* @note For checking Parental Controls, see \ref pctlIsStereoVisionPermitted.
|
|
||||||
* @note On pre-7.0.0 this uses cmd SetVrModeEnabled internally, while on [7.0.0+] this uses cmds BeginVrModeEx/EndVrModeEx.
|
|
||||||
* @param flag Flag
|
|
||||||
*/
|
|
||||||
Result appletSetVrModeEnabled(bool flag);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets the \ref ApmCpuBoostMode.
|
|
||||||
* @note Only available with [7.0.0+] (not fully usable system-side with 6.x).
|
|
||||||
* @param mode \ref ApmCpuBoostMode.
|
|
||||||
*/
|
|
||||||
Result appletSetCpuBoostMode(ApmCpuBoostMode mode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Gets the current PerformanceConfiguration.
|
|
||||||
* @note Only available with [7.0.0+].
|
|
||||||
* @param PerformanceConfiguration Output PerformanceConfiguration.
|
|
||||||
*/
|
|
||||||
Result appletGetCurrentPerformanceConfiguration(u32 *PerformanceConfiguration);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates a LibraryApplet.
|
* @brief Creates a LibraryApplet.
|
||||||
|
@ -982,6 +982,41 @@ static Result _appletCmdNoInOutStorage(Service* srv, AppletStorage* s, u64 cmd_i
|
|||||||
return _appletGetSession(srv, &s->s, cmd_id);
|
return _appletGetSession(srv, &s->s, cmd_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Result _appletGetIdentityInfo(Service* srv, AppletIdentityInfo *info, u64 cmd_id) {
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
raw = serviceIpcPrepareHeader(srv, &c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = cmd_id;
|
||||||
|
|
||||||
|
Result rc = serviceIpcDispatch(srv);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcParsedCommand r;
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 result;
|
||||||
|
AppletIdentityInfo info;
|
||||||
|
} *resp;
|
||||||
|
|
||||||
|
serviceIpcParse(srv, &r, sizeof(*resp));
|
||||||
|
resp = r.Raw;
|
||||||
|
|
||||||
|
rc = resp->result;
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc) && info) memcpy(info, &resp->info, sizeof(AppletIdentityInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
// IWindowController
|
// IWindowController
|
||||||
|
|
||||||
static Result _appletGetAppletResourceUserId(u64 *out) {
|
static Result _appletGetAppletResourceUserId(u64 *out) {
|
||||||
@ -1000,7 +1035,7 @@ Result appletGetAppletResourceUserId(u64 *out) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IFunctions
|
// IApplicationFunctions
|
||||||
|
|
||||||
Result appletPopLaunchParameter(AppletStorage *s, AppletLaunchParameterKind kind) {
|
Result appletPopLaunchParameter(AppletStorage *s, AppletLaunchParameterKind kind) {
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
@ -2181,6 +2216,44 @@ Result appletSetRestartMessageEnabled(bool flag) {
|
|||||||
return _appletCmdInBool(&g_appletISelfController, flag, 14);
|
return _appletCmdInBool(&g_appletISelfController, flag, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result appletSetScreenShotAppletIdentityInfo(AppletIdentityInfo *info) {
|
||||||
|
if (hosversionBefore(3,0,0))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
AppletIdentityInfo info;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
raw = serviceIpcPrepareHeader(&g_appletISelfController, &c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 15;
|
||||||
|
memcpy(&raw->info, info, sizeof(AppletIdentityInfo));
|
||||||
|
|
||||||
|
Result rc = serviceIpcDispatch(&g_appletISelfController);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcParsedCommand r;
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 result;
|
||||||
|
AppletIdentityInfo info;
|
||||||
|
} *resp;
|
||||||
|
|
||||||
|
serviceIpcParse(&g_appletISelfController, &r, sizeof(*resp));
|
||||||
|
resp = r.Raw;
|
||||||
|
|
||||||
|
rc = resp->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static Result _appletSetOutOfFocusSuspendingEnabled(bool flag) {
|
static Result _appletSetOutOfFocusSuspendingEnabled(bool flag) {
|
||||||
return _appletCmdInBool(&g_appletISelfController, flag, 16);
|
return _appletCmdInBool(&g_appletISelfController, flag, 16);
|
||||||
}
|
}
|
||||||
@ -2470,9 +2543,78 @@ Result appletSetApplicationAlbumUserData(const void* buffer, size_t size) {
|
|||||||
// ILibraryAppletSelfAccessor
|
// ILibraryAppletSelfAccessor
|
||||||
|
|
||||||
static Result _appletExitProcessAndReturn(void) {
|
static Result _appletExitProcessAndReturn(void) {
|
||||||
|
if (__nx_applet_type != AppletType_LibraryApplet)
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
|
||||||
|
|
||||||
return _appletCmdNoIO(&g_appletILibraryAppletSelfAccessor, 10);
|
return _appletCmdNoIO(&g_appletILibraryAppletSelfAccessor, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result appletGetMainAppletIdentityInfo(AppletIdentityInfo *info) {
|
||||||
|
if (__nx_applet_type != AppletType_LibraryApplet)
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
|
||||||
|
|
||||||
|
return _appletGetIdentityInfo(&g_appletILibraryAppletSelfAccessor, info, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result appletGetCallerAppletIdentityInfo(AppletIdentityInfo *info) {
|
||||||
|
if (__nx_applet_type != AppletType_LibraryApplet)
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
|
||||||
|
|
||||||
|
return _appletGetIdentityInfo(&g_appletILibraryAppletSelfAccessor, info, 14);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result appletGetCallerAppletIdentityInfoStack(AppletIdentityInfo *stack, s32 count, s32 *total_out) {
|
||||||
|
if (__nx_applet_type != AppletType_LibraryApplet)
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
|
||||||
|
|
||||||
|
if (hosversionBefore(3,0,0))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
|
||||||
|
ipcAddRecvBuffer(&c, stack, count*sizeof(AppletIdentityInfo), BufferType_Normal);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
raw = serviceIpcPrepareHeader(&g_appletILibraryAppletSelfAccessor, &c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 17;
|
||||||
|
|
||||||
|
Result rc = serviceIpcDispatch(&g_appletILibraryAppletSelfAccessor);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcParsedCommand r;
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 result;
|
||||||
|
s32 total_out;
|
||||||
|
} *resp;
|
||||||
|
|
||||||
|
serviceIpcParse(&g_appletILibraryAppletSelfAccessor, &r, sizeof(*resp));
|
||||||
|
resp = r.Raw;
|
||||||
|
|
||||||
|
rc = resp->result;
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc) && total_out) *total_out = resp->total_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result appletGetNextReturnDestinationAppletIdentityInfo(AppletIdentityInfo *info) {
|
||||||
|
if (__nx_applet_type != AppletType_LibraryApplet)
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
|
||||||
|
if (hosversionBefore(4,0,0))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
|
return _appletGetIdentityInfo(&g_appletILibraryAppletSelfAccessor, info, 18);
|
||||||
|
}
|
||||||
|
|
||||||
// ILibraryAppletCreator
|
// ILibraryAppletCreator
|
||||||
|
|
||||||
static Result _appletCreateLibraryApplet(Service* srv_out, AppletId id, LibAppletMode mode) {
|
static Result _appletCreateLibraryApplet(Service* srv_out, AppletId id, LibAppletMode mode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user