From e47f3dd436b81489df5348f13581f38cf8f9008d Mon Sep 17 00:00:00 2001 From: Fangal-Airbag <77993079+Fangal-Airbag@users.noreply.github.com> Date: Fri, 21 Nov 2025 11:13:37 -0500 Subject: [PATCH 1/4] Change swkbd terminology and small updates to wut samples --- include/nn/swkbd/swkbd_cpp.h | 16 ++++++++-------- samples/cmake/erreula/main.cpp | 34 ++++++++++++++++++++++++++++++++-- samples/cmake/swkbd/main.cpp | 29 +++++++++++++++++++++++++---- 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/include/nn/swkbd/swkbd_cpp.h b/include/nn/swkbd/swkbd_cpp.h index c2b5f3026..9e4d7dbdc 100644 --- a/include/nn/swkbd/swkbd_cpp.h +++ b/include/nn/swkbd/swkbd_cpp.h @@ -98,10 +98,10 @@ enum class State enum class InputFormType { - //! Input form seen when adding an NNID on Friends List or creating a folder on the System Menu. (Individual square design with up to 40 characters) - InputForm0 = 0, - //! The default input layout that is usually used (Page design) - Default = 1, + //! Spaced boxes design with up to 40 characters + Boxes = 0, + //! The page design + Page = 1, }; enum class KeyboardLayout @@ -247,7 +247,7 @@ WUT_CHECK_SIZE(KeyboardArg, 0xC0); struct InputFormArg { //! The type of input form - InputFormType type = InputFormType::Default; + InputFormType type = InputFormType::Page; int32_t unk_0x04 = -1; //! Initial string to open the keyboard with const char16_t *initialText = nullptr; @@ -258,8 +258,8 @@ struct InputFormArg //! Which password inputting preset to use nn::swkbd::PasswordMode passwordMode = nn::swkbd::PasswordMode::Clear; uint32_t unk_0x18 = 0; - //! Whether or not to draw a cursor. Exclusive to the inputform0 input form type. - bool drawInput0Cursor = false; + //! Whether or not to draw a cursor. Exclusive to the boxes input form type. + bool drawCursorForBoxes = true; //! Whether or not to highlight the initial string. Exclusive to the Default input form type. bool higlightInitialText = false; //! Whether or not to show a copy and a paste button. @@ -273,7 +273,7 @@ WUT_CHECK_OFFSET(InputFormArg, 0x0C, hintText); WUT_CHECK_OFFSET(InputFormArg, 0x10, maxTextLength); WUT_CHECK_OFFSET(InputFormArg, 0x14, passwordMode); WUT_CHECK_OFFSET(InputFormArg, 0x18, unk_0x18); -WUT_CHECK_OFFSET(InputFormArg, 0x1C, drawInput0Cursor); +WUT_CHECK_OFFSET(InputFormArg, 0x1C, drawCursorForBoxes); WUT_CHECK_OFFSET(InputFormArg, 0x1D, higlightInitialText); WUT_CHECK_OFFSET(InputFormArg, 0x1E, showCopyPasteButtons); WUT_CHECK_SIZE(InputFormArg, 0x20); diff --git a/samples/cmake/erreula/main.cpp b/samples/cmake/erreula/main.cpp index 8003b1c17..2787edb40 100644 --- a/samples/cmake/erreula/main.cpp +++ b/samples/cmake/erreula/main.cpp @@ -1,6 +1,9 @@ #include #include +#include #include +#include +#include #include #include @@ -15,7 +18,7 @@ main(int argc, char **argv) WHBProcInit(); WHBGfxInit(); FSInit(); - VPADInit(); + AXInit(); // Create FSClient for erreula FSClient *fsClient = (FSClient *)MEMAllocFromDefaultHeap(sizeof(FSClient)); @@ -33,6 +36,9 @@ main(int argc, char **argv) return -1; } + // Play the sound effect that plays when erreula appears on screen + nn::erreula::PlayAppearSE(true); + // Show the error viewer nn::erreula::AppearArg appearArg; appearArg.errorArg.errorType = nn::erreula::ErrorType::Message2Button; @@ -44,6 +50,10 @@ main(int argc, char **argv) appearArg.errorArg.errorTitle = u"Title"; nn::erreula::AppearErrorViewer(appearArg); + // Get WHBGfx's colour buffers for proper erreula rendering + GX2ColorBuffer *cbTV = WHBGfxGetTVColourBuffer(); + GX2ColorBuffer *cbDRC = WHBGfxGetDRCColourBuffer(); + WHBLogPrintf("Begin rendering..."); while (WHBProcIsRunning()) { // Read vpad for erreula::Calc @@ -62,19 +72,39 @@ main(int argc, char **argv) if (nn::erreula::IsDecideSelectButtonError()) { nn::erreula::DisappearErrorViewer(); - break; + SYSLaunchMenu(); } WHBGfxBeginRender(); WHBGfxBeginRenderTV(); WHBGfxClearColor(0.0f, 0.0f, 1.0f, 1.0f); + // Set our colour buffer's surface format to SRGB for correct rendering of erreula + GX2SurfaceFormat fTV = cbTV->surface.format; + cbTV->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; + GX2InitColorBufferRegs(cbTV); + GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); + nn::erreula::DrawTV(); + + // Set our colour buffer's surface format back to what it was before. + cbTV->surface.format = fTV; + GX2InitColorBufferRegs(cbTV); + GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); WHBGfxFinishRenderTV(); WHBGfxBeginRenderDRC(); WHBGfxClearColor(1.0f, 0.0f, 1.0f, 1.0f); + GX2SurfaceFormat fDRC = cbDRC->surface.format; + cbDRC->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; + GX2InitColorBufferRegs(cbDRC); + GX2SetColorBuffer(cbDRC, GX2_RENDER_TARGET_0); + nn::erreula::DrawDRC(); + + cbDRC->surface.format = fDRC; + GX2InitColorBufferRegs(cbDRC); + GX2SetColorBuffer(cbDRC, GX2_RENDER_TARGET_0); WHBGfxFinishRenderDRC(); WHBGfxFinishRender(); diff --git a/samples/cmake/swkbd/main.cpp b/samples/cmake/swkbd/main.cpp index 2dab86681..9922665ee 100644 --- a/samples/cmake/swkbd/main.cpp +++ b/samples/cmake/swkbd/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -17,7 +18,6 @@ main(int argc, char **argv) WHBProcInit(); WHBGfxInit(); FSInit(); - VPADInit(); AXInit(); // Create FSClient for swkbd @@ -35,9 +35,6 @@ main(int argc, char **argv) return -1; } - // Enable sound - nn::swkbd::MuteAllSound(false); - // Show the keyboard nn::swkbd::AppearArg appearArg; appearArg.keyboardArg.configArg.languageType = nn::swkbd::LanguageType::English; @@ -48,6 +45,10 @@ main(int argc, char **argv) return -1; } + // Get WHBGfx's colour buffers for proper swkbd rendering + GX2ColorBuffer *cbTV = WHBGfxGetTVColourBuffer(); + GX2ColorBuffer *cbDRC = WHBGfxGetDRCColourBuffer(); + WHBLogPrintf("Begin rendering..."); while (WHBProcIsRunning()) { // Read vpad for swkbd::Calc @@ -82,12 +83,32 @@ main(int argc, char **argv) WHBGfxBeginRenderTV(); WHBGfxClearColor(0.0f, 0.0f, 1.0f, 1.0f); + // Set our colour buffer's surface format to SRGB for correct rendering of swkbd + GX2SurfaceFormat fTV = cbTV->surface.format; + cbTV->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; + GX2InitColorBufferRegs(cbTV); + GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); + nn::swkbd::DrawTV(); + + // Set our colour buffer's surface format back to what it was before. + cbTV->surface.format = fTV; + GX2InitColorBufferRegs(cbTV); + GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); WHBGfxFinishRenderTV(); WHBGfxBeginRenderDRC(); WHBGfxClearColor(1.0f, 0.0f, 1.0f, 1.0f); + GX2SurfaceFormat fDRC = cbDRC->surface.format; + cbDRC->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; + GX2InitColorBufferRegs(cbDRC); + GX2SetColorBuffer(cbDRC, GX2_RENDER_TARGET_0); + nn::swkbd::DrawDRC(); + + cbDRC->surface.format = fDRC; + GX2InitColorBufferRegs(cbDRC); + GX2SetColorBuffer(cbDRC, GX2_RENDER_TARGET_0); WHBGfxFinishRenderDRC(); WHBGfxFinishRender(); From ff4a119ba3d0aef2c9198b9d45e59b1f43d2841e Mon Sep 17 00:00:00 2001 From: Fangal-Airbag <77993079+Fangal-Airbag@users.noreply.github.com> Date: Fri, 21 Nov 2025 11:21:09 -0500 Subject: [PATCH 2/4] Quick comment clarification --- samples/cmake/erreula/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/cmake/erreula/main.cpp b/samples/cmake/erreula/main.cpp index 2787edb40..ebbbf77d4 100644 --- a/samples/cmake/erreula/main.cpp +++ b/samples/cmake/erreula/main.cpp @@ -36,7 +36,7 @@ main(int argc, char **argv) return -1; } - // Play the sound effect that plays when erreula appears on screen + // Play a sound effect that will play when erreula appears on screen nn::erreula::PlayAppearSE(true); // Show the error viewer From cfcb7a70498f6e5ccaaab43bacaebac4cd623e20 Mon Sep 17 00:00:00 2001 From: Fangal-Airbag <77993079+Fangal-Airbag@users.noreply.github.com> Date: Wed, 26 Nov 2025 20:40:27 -0500 Subject: [PATCH 3/4] Formatting fix --- include/nn/swkbd/swkbd_cpp.h | 2 +- samples/cmake/erreula/main.cpp | 6 +++--- samples/cmake/swkbd/main.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/nn/swkbd/swkbd_cpp.h b/include/nn/swkbd/swkbd_cpp.h index 9e4d7dbdc..42a05e6ff 100644 --- a/include/nn/swkbd/swkbd_cpp.h +++ b/include/nn/swkbd/swkbd_cpp.h @@ -101,7 +101,7 @@ enum class InputFormType //! Spaced boxes design with up to 40 characters Boxes = 0, //! The page design - Page = 1, + Page = 1, }; enum class KeyboardLayout diff --git a/samples/cmake/erreula/main.cpp b/samples/cmake/erreula/main.cpp index ebbbf77d4..260ff5c7a 100644 --- a/samples/cmake/erreula/main.cpp +++ b/samples/cmake/erreula/main.cpp @@ -51,8 +51,8 @@ main(int argc, char **argv) nn::erreula::AppearErrorViewer(appearArg); // Get WHBGfx's colour buffers for proper erreula rendering - GX2ColorBuffer *cbTV = WHBGfxGetTVColourBuffer(); - GX2ColorBuffer *cbDRC = WHBGfxGetDRCColourBuffer(); + GX2ColorBuffer *cbTV = WHBGfxGetTVColourBuffer(); + GX2ColorBuffer *cbDRC = WHBGfxGetDRCColourBuffer(); WHBLogPrintf("Begin rendering..."); while (WHBProcIsRunning()) { @@ -84,7 +84,7 @@ main(int argc, char **argv) cbTV->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; GX2InitColorBufferRegs(cbTV); GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); - + nn::erreula::DrawTV(); // Set our colour buffer's surface format back to what it was before. diff --git a/samples/cmake/swkbd/main.cpp b/samples/cmake/swkbd/main.cpp index 9922665ee..9f8cbaad0 100644 --- a/samples/cmake/swkbd/main.cpp +++ b/samples/cmake/swkbd/main.cpp @@ -46,8 +46,8 @@ main(int argc, char **argv) } // Get WHBGfx's colour buffers for proper swkbd rendering - GX2ColorBuffer *cbTV = WHBGfxGetTVColourBuffer(); - GX2ColorBuffer *cbDRC = WHBGfxGetDRCColourBuffer(); + GX2ColorBuffer *cbTV = WHBGfxGetTVColourBuffer(); + GX2ColorBuffer *cbDRC = WHBGfxGetDRCColourBuffer(); WHBLogPrintf("Begin rendering..."); while (WHBProcIsRunning()) { @@ -88,7 +88,7 @@ main(int argc, char **argv) cbTV->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; GX2InitColorBufferRegs(cbTV); GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); - + nn::swkbd::DrawTV(); // Set our colour buffer's surface format back to what it was before. From 4ce0c02f1690023e42d7816b8a01196e4a268fc1 Mon Sep 17 00:00:00 2001 From: Fangal-Airbag <77993079+Fangal-Airbag@users.noreply.github.com> Date: Tue, 17 Feb 2026 13:19:05 -0500 Subject: [PATCH 4/4] Samples update All this commit does is make the swkbd and erreula samples roughly equivalent in function For example when closing the error viewer, `SYSLaunchMenu()` will be called to cause ProcUI to exit, just like how it is in swkbd. Also this adds sound effects for the erreula sample, much like what swkbd has already had for some time now. --- samples/cmake/erreula/main.cpp | 26 +------------------------- samples/cmake/swkbd/main.cpp | 24 ------------------------ 2 files changed, 1 insertion(+), 49 deletions(-) diff --git a/samples/cmake/erreula/main.cpp b/samples/cmake/erreula/main.cpp index 260ff5c7a..2579bb58d 100644 --- a/samples/cmake/erreula/main.cpp +++ b/samples/cmake/erreula/main.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -50,10 +49,6 @@ main(int argc, char **argv) appearArg.errorArg.errorTitle = u"Title"; nn::erreula::AppearErrorViewer(appearArg); - // Get WHBGfx's colour buffers for proper erreula rendering - GX2ColorBuffer *cbTV = WHBGfxGetTVColourBuffer(); - GX2ColorBuffer *cbDRC = WHBGfxGetDRCColourBuffer(); - WHBLogPrintf("Begin rendering..."); while (WHBProcIsRunning()) { // Read vpad for erreula::Calc @@ -72,6 +67,7 @@ main(int argc, char **argv) if (nn::erreula::IsDecideSelectButtonError()) { nn::erreula::DisappearErrorViewer(); + // Cause ProcUI to exit. SYSLaunchMenu(); } @@ -79,32 +75,12 @@ main(int argc, char **argv) WHBGfxBeginRenderTV(); WHBGfxClearColor(0.0f, 0.0f, 1.0f, 1.0f); - // Set our colour buffer's surface format to SRGB for correct rendering of erreula - GX2SurfaceFormat fTV = cbTV->surface.format; - cbTV->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; - GX2InitColorBufferRegs(cbTV); - GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); - nn::erreula::DrawTV(); - - // Set our colour buffer's surface format back to what it was before. - cbTV->surface.format = fTV; - GX2InitColorBufferRegs(cbTV); - GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); WHBGfxFinishRenderTV(); WHBGfxBeginRenderDRC(); WHBGfxClearColor(1.0f, 0.0f, 1.0f, 1.0f); - GX2SurfaceFormat fDRC = cbDRC->surface.format; - cbDRC->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; - GX2InitColorBufferRegs(cbDRC); - GX2SetColorBuffer(cbDRC, GX2_RENDER_TARGET_0); - nn::erreula::DrawDRC(); - - cbDRC->surface.format = fDRC; - GX2InitColorBufferRegs(cbDRC); - GX2SetColorBuffer(cbDRC, GX2_RENDER_TARGET_0); WHBGfxFinishRenderDRC(); WHBGfxFinishRender(); diff --git a/samples/cmake/swkbd/main.cpp b/samples/cmake/swkbd/main.cpp index 9f8cbaad0..8dfc26b13 100644 --- a/samples/cmake/swkbd/main.cpp +++ b/samples/cmake/swkbd/main.cpp @@ -45,10 +45,6 @@ main(int argc, char **argv) return -1; } - // Get WHBGfx's colour buffers for proper swkbd rendering - GX2ColorBuffer *cbTV = WHBGfxGetTVColourBuffer(); - GX2ColorBuffer *cbDRC = WHBGfxGetDRCColourBuffer(); - WHBLogPrintf("Begin rendering..."); while (WHBProcIsRunning()) { // Read vpad for swkbd::Calc @@ -83,32 +79,12 @@ main(int argc, char **argv) WHBGfxBeginRenderTV(); WHBGfxClearColor(0.0f, 0.0f, 1.0f, 1.0f); - // Set our colour buffer's surface format to SRGB for correct rendering of swkbd - GX2SurfaceFormat fTV = cbTV->surface.format; - cbTV->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; - GX2InitColorBufferRegs(cbTV); - GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); - nn::swkbd::DrawTV(); - - // Set our colour buffer's surface format back to what it was before. - cbTV->surface.format = fTV; - GX2InitColorBufferRegs(cbTV); - GX2SetColorBuffer(cbTV, GX2_RENDER_TARGET_0); WHBGfxFinishRenderTV(); WHBGfxBeginRenderDRC(); WHBGfxClearColor(1.0f, 0.0f, 1.0f, 1.0f); - GX2SurfaceFormat fDRC = cbDRC->surface.format; - cbDRC->surface.format = GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8; - GX2InitColorBufferRegs(cbDRC); - GX2SetColorBuffer(cbDRC, GX2_RENDER_TARGET_0); - nn::swkbd::DrawDRC(); - - cbDRC->surface.format = fDRC; - GX2InitColorBufferRegs(cbDRC); - GX2SetColorBuffer(cbDRC, GX2_RENDER_TARGET_0); WHBGfxFinishRenderDRC(); WHBGfxFinishRender();