From f1da102193ff1f4e13203d7f9da259b704327f98 Mon Sep 17 00:00:00 2001 From: Kartik Date: Thu, 2 Mar 2017 11:10:40 +0530 Subject: [PATCH] Implement error applet --- libctru/source/applets/error.c | 74 ++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 libctru/source/applets/error.c diff --git a/libctru/source/applets/error.c b/libctru/source/applets/error.c new file mode 100644 index 0000000..295c468 --- /dev/null +++ b/libctru/source/applets/error.c @@ -0,0 +1,74 @@ +#include <3ds.h> +#include +#include +#include +#include <3ds/types.h> +#include <3ds/result.h> +#include <3ds/svc.h> +#include <3ds/synchronization.h> +#include <3ds/services/apt.h> +#include <3ds/ipc.h> +#include <3ds/env.h> +#include <3ds/util/utf.h> +#include <3ds/applets/error.h> + +void error_Init(ErrConf* err, ErrorType type, err_lang lang) +{ + memset(err, 0, sizeof(*err)); + err->errorType= type; + err->useLanguage= lang; + err->upperScreenFlag= NORMAL; + err->eulaVersion = 0; + err->homeButton = true; + err->softwareReset = false; + err->appJump = false; + err-> returnCode = UNKNOWN; +} + +static void errorConvertToUTF16(u16* out, const char* in, int max) +{ + if (!in || !*in) + { + out[0] = 0; + return; + } + + ssize_t units = utf8_to_utf16(out, (const uint8_t*)in, max); + if (units < 0) + { + out[0] = 0; + return; + } + + out[units] = 0; +} +char k[1900]; +char *c_shift(char text[]) +{ + int i=strlen(text); + char tex[i]; + tex[0]=text[0]; + int j=1; + for(int a=0;a<=i;a++) + { + tex[j]=text[a]; + j++; + } + strncpy(k, tex, i+1); + return k; +} +void error_code(ErrConf* err,int error) +{ + err->errorCode = error; +} + +void error_text(ErrConf *err, char* text) +{ + char *tex=c_shift(text); + errorConvertToUTF16(err->Text, tex,1900); +} + +void error_disp(ErrConf* err) +{ + aptLaunchLibraryApplet(APPID_ERROR , err, sizeof(*err), 0); +}