mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 04:52:39 +02:00
parent
b7fe92f3a2
commit
ecfc8f8966
@ -106,6 +106,7 @@ extern "C" {
|
||||
#include "switch/audio/driver.h"
|
||||
|
||||
#include "switch/applets/libapplet.h"
|
||||
#include "switch/applets/error.h"
|
||||
#include "switch/applets/swkbd.h"
|
||||
#include "switch/applets/web.h"
|
||||
|
||||
|
77
nx/include/switch/applets/error.h
Normal file
77
nx/include/switch/applets/error.h
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @file error.h
|
||||
* @brief Wrapper for using the error LibraryApplet.
|
||||
* @author StuntHacks
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "../services/applet.h"
|
||||
|
||||
/// Error configuration struct
|
||||
typedef struct {
|
||||
u8 custom_text; ///< Whether to show a custom error message. If this is false, a default message will be shown.
|
||||
u8 unk[7];
|
||||
u32 module; ///< Module code.
|
||||
u32 description; ///< Description code.
|
||||
u8 unk2[8];
|
||||
char short_description[0x800]; ///< Short description.
|
||||
char detailed_description[0x800]; ///< Detailed description (displayed when the user clicks, on "Details").
|
||||
} ErrorConfig;
|
||||
|
||||
/**
|
||||
* @brief Creates an ErrorConfg struct.
|
||||
* @param c ErrorConfg struct.
|
||||
* @note Sets the following fields: majorCode = 2000, minorCode = 0, customText = false, shortDescription = "", detailedDescription = "".
|
||||
* @warning This applet creates an error report that is logged in the system. Proceed at your own risk!
|
||||
*/
|
||||
void errorCreate(ErrorConfig* c);
|
||||
|
||||
/**
|
||||
* @brief Closes an ErrorConfig struct.
|
||||
* @param c ErrorConfig struct.
|
||||
*/
|
||||
void errorClose(ErrorConfig* c);
|
||||
|
||||
/**
|
||||
* @brief Launches with the specified config.
|
||||
* @param c ErrorConfig struct.
|
||||
*/
|
||||
void errorShow(ErrorConfig* c);
|
||||
|
||||
/**
|
||||
* @brief Sets the error module.
|
||||
* @param c ErrorConfig struct.
|
||||
* @param code Code.
|
||||
*/
|
||||
void errorConfigSetModule(ErrorConfig* c, u32 code);
|
||||
|
||||
/**
|
||||
* @brief Sets the error description.
|
||||
* @param c ErrorConfig struct.
|
||||
* @param code Code.
|
||||
*/
|
||||
void errorConfigSetDescription(ErrorConfig* c, u32 code);
|
||||
|
||||
/**
|
||||
* @brief Sets whether to use a custom error message.
|
||||
* @param c ErrorConfig struct.
|
||||
* @param custom_text Whether to use a custom message.
|
||||
*/
|
||||
void errorConfigSetCustomText(ErrorConfig* c, bool custom_text);
|
||||
|
||||
/**
|
||||
* @brief Sets the short description.
|
||||
* @param c ErrorConfig struct.
|
||||
* @param str Description.
|
||||
*/
|
||||
void errorConfigSetShortDescription(ErrorConfig* c, const char* str);
|
||||
|
||||
/**
|
||||
* @brief Sets the detailed description.
|
||||
* @param c ErrorConfig struct.
|
||||
* @param str Description.
|
||||
*
|
||||
* This gets displayed when the user clicks on "Details".
|
||||
*/
|
||||
void errorConfigSetDetailedDescription(ErrorConfig* c, const char* str);
|
51
nx/source/applets/error.c
Normal file
51
nx/source/applets/error.c
Normal file
@ -0,0 +1,51 @@
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include "types.h"
|
||||
#include "result.h"
|
||||
#include "services/applet.h"
|
||||
#include "applets/libapplet.h"
|
||||
#include "applets/error.h"
|
||||
|
||||
void errorCreate(ErrorConfig* c) {
|
||||
memset(c, 0, sizeof(ErrorConfig));
|
||||
c->custom_text = false;
|
||||
c->module = 2000;
|
||||
}
|
||||
|
||||
void errorClose(ErrorConfig* c) {
|
||||
memset(c, 0, sizeof(ErrorConfig));
|
||||
}
|
||||
|
||||
void errorShow(ErrorConfig* c) {
|
||||
AppletHolder err;
|
||||
LibAppletArgs errArgs;
|
||||
|
||||
appletCreateLibraryApplet(&err, AppletId_error, LibAppletMode_AllForeground);
|
||||
libappletArgsCreate(&errArgs, 1);
|
||||
libappletArgsPush(&errArgs, &err);
|
||||
libappletPushInData(&err, c, sizeof(ErrorConfig));
|
||||
|
||||
appletHolderStart(&err);
|
||||
appletHolderJoin(&err);
|
||||
appletHolderClose(&err);
|
||||
}
|
||||
|
||||
void errorConfigSetModule(ErrorConfig* c, u32 code) {
|
||||
c->module = code;
|
||||
}
|
||||
|
||||
void errorConfigSetDescription(ErrorConfig* c, u32 code) {
|
||||
c->description = code;
|
||||
}
|
||||
|
||||
void errorConfigSetCustomText(ErrorConfig* c, bool custom_text) {
|
||||
c->custom_text = custom_text;
|
||||
}
|
||||
|
||||
void errorConfigSetShortDescription(ErrorConfig* c, const char* str) {
|
||||
strncpy(c->short_description, str, sizeof(c->short_description) - 1);
|
||||
}
|
||||
|
||||
void errorConfigSetDetailedDescription(ErrorConfig* c, const char* str) {
|
||||
strncpy(c->detailed_description, str, sizeof(c->detailed_description) - 1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user