SYSGetArguments

Syntax

#include <cafe/sysapp.h>

s32     SYSGetArguments( SysArgSlot * ap_SysArgSlot, SysCallerData * p_Caller );

Parameters

ap_SysArgSlot Specifies a pointer to the SysArgSlot union array. Zero cannot be passed as an argument.
p_Caller Specifies a pointer to the SysCallerData structure. Zero cannot be passed as an argument.

Return Values

SYS_ERROR_NONEThe function completed successfully.
SYS_ERROR_NO_ARGSThe function completed successfully, but the calling application passed no arguments.
SYS_ERROR_FATALZero was passed in the arguments. Set a value other than zero for both ap_SysArgSlot and p_Caller.

Description

Gets the arguments passed by immediately preceding application. To use this feature in development environments, Wii U Menu Changer must be installed.

How to Use

  1. Prepare an array of SysArgSlot types that has several elements equal to the number of arguments that can be retrieved plus one.
  2. Specify the SysArgID for the type of argument to retrieve in each of the array elements.
  3. Specify SYS_ARG_ID_TERMINATOR for the last array element.
  4. Call the SYSGetArguments function with this array and the SysCallerData type as arguments.
  5. If the function completes normally, the SysCallerData type passed in arguments in the previous step stores information about the calling application.
  6. If the calling application has information to pass, the data is stored in the elements of the array of SysArgSlot types (which was passed when the function was called) that have a SysArgID corresponding to the information.

Types of Calling Applications

SysCallerTypeValueCalling Application
SYS_CALLER_TYPE_INVALID-1There is no caller. This value is returned when the caller itself returns after jumping to another application.
SYS_CALLER_TYPE_LAUNCHER2A reserved value. No arguments are passed if the calling application is started from the Wii U Menu, so the return value of the function is SYS_ERROR_NO_ARGS.
SYS_CALLER_TYPE_TVII3A reserved value.
SYS_CALLER_TYPE_HBM5A reserved value.
SYS_CALLER_TYPE_MINI_MIIVERSE7A reserved value.
SYS_CALLER_TYPE_MIIVERSE9Miiverse.
SYS_CALLER_TYPE_FRIEND_LIST11Friend list.
SYS_CALLER_TYPE_GAME15A reserved value.
SYS_CALLER_TYPE_END-The last enum value.

Arguments Corresponding to the Calling Application Types

SysCallerTypeSysArgIDSysArgTypeDescription
SYS_CALLER_TYPE_FRIEND_LISTSYS_ARG_ID_JOIN_PIDSYS_ARG_TYPE_U32The join ID.
SYS_CALLER_TYPE_MIIVERSESYS_ARG_ID_MIIVERSE_DATASYS_ARG_TYPE_DATA_BLOCKData passed when starting from Miiverse.
SYS_CALLER_TYPE_INVALIDSYS_ARG_ID_ANCHORSYS_ARG_TYPE_CONST_DATA_BLOCKIf this data is set before switching to another application, it can be retrieved after control returns to this application. This is not an issue if the application being switched to is a co-resident application, because the application being switched from remains in memory. However, if the application being switched to is a main application, the original application does not remain in memory and is restarted after returning from the other application. In such cases, this value can be used to determine where in the sequence the switch took place and proceed to the next sequence.
SYS_ARG_ID_RESULTSYS_ARG_TYPE_DATA_BLOCKData that is passed back to the original process after switching to a different process such as the Internet browser.

Sample Pseudocode

#include <cafe/sysapp.h>

SysCallerData   f_Caller;

enum
{
    e_ArgMiiverseData,
    e_ArgJoinPID,
    e_ArgAnchor,
    e_ArgResult,
};

SysArgSlot      fa_Args[] =
{
    { SYS_ARG_ID_MIIVERSE_DATA, },
    { SYS_ARG_ID_JOIN_PID, },
    { SYS_ARG_ID_ANCHOR, },
    { SYS_ARG_ID_RESULT, },
    { SYS_ARG_ID_TERMINATOR }
};

s32 ret = SYSGetArguments( fa_Args, &f_Caller );

if ( ret == SYS_ERROR_NONE )
{
    switch ( f_Caller.type )
    {
    case SYS_CALLER_TYPE_MIIVERSE:
        if ( fa_Args[ e_ArgMiiverseData ]._base.type == SYS_ARG_TYPE_DATA_BLOCK )
        {
            //  do something
            //  memcpy( p_Dst, fa_Args[ e_ArgMiiverseData ]._blk.p_Data, fa_Args[ e_ArgMiiverseData ]._blk.dataSize );
        }
        break;
    case SYS_CALLER_TYPE_JOIN_PID:
        if ( fa_Args[ e_ArgJoinPID ]._base.type == SYS_ARG_TYPE_U32 )
        {
            //  do something
            //  u32 joinID = fa_Args[ e_ArgJoinPID ]._u32.value;
        }
        break;
    case SYS_CALLER_TYPE_INVALID:
        if ( fa_Args[ e_ArgAnchor ]._base.type == SYS_ARG_TYPE_CONST_DATA_BLOCK )
        {
            //  do something
            //  memcpy( p_Dst, fa_Args[ e_ArgAnchor ]._cblk.cp_Data, fa_Args[ e_ArgAnchor ]._cblk.dataSize );
        }

        if ( fa_Args[ e_ArgResult ]._base.type == SYS_ARG_TYPE_DATA_BLOCK )
        {
            //  do something
            //  memcpy( p_Dst, fa_Args[ e_ArgResult ]._blk.p_Data, fa_Args[ e_ArgResult ]._blk.dataSize );
        }
        break;
    default:
        break;
    }
}

Do Not Call From

None.

Revision History

2014/09/18 Removed duplicate and incorrect SysCallerType.
2014/03/03 Added arguments corresponding to the calling application types.
2013/08/07 Initial version.


CONFIDENTIAL