Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions include/nn/swkbd/swkbd_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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);
Expand Down
34 changes: 32 additions & 2 deletions samples/cmake/erreula/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include <coreinit/filesystem.h>
#include <coreinit/memdefaultheap.h>
#include <gx2/surface.h>
#include <nn/erreula.h>
#include <sndcore2/core.h>
#include <sysapp/launch.h>
#include <vpad/input.h>

#include <whb/gfx.h>
Expand All @@ -15,7 +18,7 @@ main(int argc, char **argv)
WHBProcInit();
WHBGfxInit();
FSInit();
VPADInit();
AXInit();

// Create FSClient for erreula
FSClient *fsClient = (FSClient *)MEMAllocFromDefaultHeap(sizeof(FSClient));
Expand All @@ -33,6 +36,9 @@ main(int argc, char **argv)
return -1;
}

// Play a sound effect that will play when erreula appears on screen
nn::erreula::PlayAppearSE(true);

// Show the error viewer
nn::erreula::AppearArg appearArg;
appearArg.errorArg.errorType = nn::erreula::ErrorType::Message2Button;
Expand All @@ -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
Expand All @@ -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();
Expand Down
29 changes: 25 additions & 4 deletions samples/cmake/swkbd/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <coreinit/filesystem.h>
#include <coreinit/memdefaultheap.h>
#include <gx2/surface.h>
#include <nn/swkbd.h>
#include <sndcore2/core.h>
#include <sysapp/launch.h>
Expand All @@ -17,7 +18,6 @@ main(int argc, char **argv)
WHBProcInit();
WHBGfxInit();
FSInit();
VPADInit();
AXInit();

// Create FSClient for swkbd
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down