mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 18:42:15 +02:00
Added support for error Application. Allow passing NULL to errorSystemCreate() for fullscreen_message, and minor other adjustments.
This commit is contained in:
parent
e20f843900
commit
bd467d3ccf
@ -43,11 +43,25 @@ typedef struct {
|
||||
ErrorContext ctx;
|
||||
} ErrorSystemConfig;
|
||||
|
||||
/// ApplicationErrorArg
|
||||
typedef struct {
|
||||
ErrorCommonHeader hdr;
|
||||
u32 errorNumber;
|
||||
u64 languageCode;
|
||||
char dialogMessage[0x800]; ///< UTF-8 Dialog message.
|
||||
char fullscreenMessage[0x800]; ///< UTF-8 Fullscreen message (displayed when the user clicks on "Details").
|
||||
} PACKED ErrorApplicationArg;
|
||||
|
||||
typedef struct {
|
||||
ErrorApplicationArg arg;
|
||||
ErrorContext ctx;
|
||||
} ErrorApplicationConfig;
|
||||
|
||||
/**
|
||||
* @brief Creates an ErrorSystemConfig struct.
|
||||
* @param c ErrorSystemConfig struct.
|
||||
* @param dialog_message UTF-8 dialog message.
|
||||
* @param fullscreen_message UTF-8 fullscreen message, displayed when the user clicks on "Details".
|
||||
* @param fullscreen_message UTF-8 fullscreen message, displayed when the user clicks on "Details". Optional, can be NULL (which disables displaying Details).
|
||||
* @note Sets the following fields: type=1 and {strings}. The rest are cleared.
|
||||
* @note On pre-5.0.0 this will initialize languageCode by using: setInitialize(), setMakeLanguageCode(SetLanguage_ENUS, ...), and setExit(). This is needed since an empty languageCode wasn't supported until [5.0.0+] (which would also use SetLanguage_ENUS).
|
||||
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
|
||||
@ -61,7 +75,7 @@ Result errorSystemCreate(ErrorSystemConfig* c, const char* dialog_message, const
|
||||
void errorSystemClose(ErrorSystemConfig* c);
|
||||
|
||||
/**
|
||||
* @brief Launches with the specified config.
|
||||
* @brief Launches the applet with the specified config.
|
||||
* @param c ErrorSystemConfig struct.
|
||||
*/
|
||||
Result errorSystemShow(ErrorSystemConfig* c);
|
||||
@ -96,3 +110,40 @@ void errorSystemSetLanguageCode(ErrorSystemConfig* c, u64 LanguageCode);
|
||||
*/
|
||||
void errorSystemSetContext(ErrorSystemConfig* c, ErrorContext* ctx);
|
||||
|
||||
/**
|
||||
* @brief Creates an ErrorApplicationConfig struct.
|
||||
* @param c ErrorApplicationConfig struct.
|
||||
* @param dialog_message UTF-8 dialog message.
|
||||
* @param fullscreen_message UTF-8 fullscreen message, displayed when the user clicks on "Details". Optional, can be NULL (which disables displaying Details).
|
||||
* @note Sets the following fields: type=2, unk_x1=1, and {strings}. The rest are cleared.
|
||||
* @note On pre-5.0.0 this will initialize languageCode by using: setInitialize(), setMakeLanguageCode(SetLanguage_ENUS, ...), and setExit(). This is needed since an empty languageCode wasn't supported until [5.0.0+] (which would also use SetLanguage_ENUS).
|
||||
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
|
||||
*/
|
||||
Result errorApplicationCreate(ErrorApplicationConfig* c, const char* dialog_message, const char* fullscreen_message);
|
||||
|
||||
/**
|
||||
* @brief Closes an ErrorApplicationConfig struct.
|
||||
* @param c ErrorApplicationConfig struct.
|
||||
*/
|
||||
void errorApplicationClose(ErrorApplicationConfig* c);
|
||||
|
||||
/**
|
||||
* @brief Launches the applet with the specified config.
|
||||
* @param c ErrorApplicationConfig struct.
|
||||
*/
|
||||
Result errorApplicationShow(ErrorApplicationConfig* c);
|
||||
|
||||
/**
|
||||
* @brief Sets the error code number.
|
||||
* @param c ErrorApplicationConfig struct.
|
||||
* @param errorNumber Error code number. Raw decimal error number which is displayed in the dialog.
|
||||
*/
|
||||
void errorApplicationSetNumber(ErrorApplicationConfig* c, u32 errorNumber);
|
||||
|
||||
/**
|
||||
* @brief Sets the LanguageCode.
|
||||
* @param c ErrorApplicationConfig struct.
|
||||
* @param LanguageCode LanguageCode, see set.h.
|
||||
*/
|
||||
void errorApplicationSetLanguageCode(ErrorApplicationConfig* c, u64 LanguageCode);
|
||||
|
||||
|
@ -76,14 +76,16 @@ static Result _errorShowContext(const void* indata, size_t insize, ErrorContext*
|
||||
return _errorShow(indata, insize, ctx_ptr, ctx_size);
|
||||
}
|
||||
|
||||
// System
|
||||
|
||||
Result errorSystemCreate(ErrorSystemConfig* c, const char* dialog_message, const char* fullscreen_message) {
|
||||
Result rc=0;
|
||||
|
||||
memset(c, 0, sizeof(ErrorSystemConfig));
|
||||
memset(c, 0, sizeof(*c));
|
||||
c->arg.hdr.type = 1;
|
||||
|
||||
strncpy(c->arg.dialogMessage, dialog_message, sizeof(c->arg.dialogMessage)-1);
|
||||
strncpy(c->arg.fullscreenMessage, fullscreen_message, sizeof(c->arg.fullscreenMessage)-1);
|
||||
if (fullscreen_message) strncpy(c->arg.fullscreenMessage, fullscreen_message, sizeof(c->arg.fullscreenMessage)-1);
|
||||
|
||||
if (hosversionBefore(5,0,0)) {
|
||||
rc = setInitialize();
|
||||
@ -95,7 +97,7 @@ Result errorSystemCreate(ErrorSystemConfig* c, const char* dialog_message, const
|
||||
}
|
||||
|
||||
void errorSystemClose(ErrorSystemConfig* c) {
|
||||
memset(c, 0, sizeof(ErrorSystemConfig));
|
||||
memset(c, 0, sizeof(*c));
|
||||
}
|
||||
|
||||
Result errorSystemShow(ErrorSystemConfig* c) {
|
||||
@ -120,3 +122,40 @@ void errorSystemSetContext(ErrorSystemConfig* c, ErrorContext* ctx) {
|
||||
if (ctx) memcpy(&c->ctx, ctx, sizeof(ErrorContext));
|
||||
}
|
||||
|
||||
// Application
|
||||
|
||||
Result errorApplicationCreate(ErrorApplicationConfig* c, const char* dialog_message, const char* fullscreen_message) {
|
||||
Result rc=0;
|
||||
|
||||
memset(c, 0, sizeof(*c));
|
||||
c->arg.hdr.type = 2;
|
||||
c->arg.hdr.unk_x1 = 1;
|
||||
|
||||
strncpy(c->arg.dialogMessage, dialog_message, sizeof(c->arg.dialogMessage)-1);
|
||||
if (fullscreen_message) strncpy(c->arg.fullscreenMessage, fullscreen_message, sizeof(c->arg.fullscreenMessage)-1);
|
||||
|
||||
if (hosversionBefore(5,0,0)) {
|
||||
rc = setInitialize();
|
||||
if (R_SUCCEEDED(rc)) rc = setMakeLanguageCode(SetLanguage_ENUS, &c->arg.languageCode);
|
||||
setExit();
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void errorApplicationClose(ErrorApplicationConfig* c) {
|
||||
memset(c, 0, sizeof(*c));
|
||||
}
|
||||
|
||||
Result errorApplicationShow(ErrorApplicationConfig* c) {
|
||||
return _errorShow(&c->arg, sizeof(c->arg), NULL, 0);
|
||||
}
|
||||
|
||||
void errorApplicationSetNumber(ErrorApplicationConfig* c, u32 errorNumber) {
|
||||
c->arg.errorNumber = errorNumber;
|
||||
}
|
||||
|
||||
void errorApplicationSetLanguageCode(ErrorApplicationConfig* c, u64 LanguageCode) {
|
||||
c->arg.languageCode = LanguageCode;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user