From 7ec019cd45798753637f7e938f80a4e96dc40638 Mon Sep 17 00:00:00 2001 From: camthehaxman Date: Wed, 17 Jan 2024 14:15:08 -0600 Subject: [PATCH 1/2] make the UI actually legible on 3DS --- .gitignore | 3 +++ src/LBackend.c | 10 ++++++++-- src/LWidgets.c | 10 ++++++++-- src/Launcher.c | 2 +- src/Window_3DS.c | 12 ++++++------ 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 38a20ef08..5c2e96054 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ android/app/.externalNativeBuild/ android/local.properties *.iml +# 3DS build results +build-3ds/ + # Build results [Dd]ebug/ [Dd]ebugPublic/ diff --git a/src/LBackend.c b/src/LBackend.c index d9e84c7bd..66d9dfb53 100644 --- a/src/LBackend.c +++ b/src/LBackend.c @@ -47,8 +47,14 @@ static int flagXOffset, flagYOffset; static void HookEvents(void); void LBackend_Init(void) { - xBorder = Display_ScaleX(1); xBorder2 = xBorder * 2; xBorder3 = xBorder * 3; xBorder4 = xBorder * 4; - yBorder = Display_ScaleY(1); yBorder2 = yBorder * 2; yBorder3 = yBorder * 3; yBorder4 = yBorder * 4; + xBorder = Display_ScaleX(1); + yBorder = Display_ScaleY(1); + + if (xBorder < 1) { xBorder = 1; } + if (yBorder < 1) { yBorder = 1; } + + xBorder2 = xBorder * 2; xBorder3 = xBorder * 3; xBorder4 = xBorder * 4; + yBorder2 = yBorder * 2; yBorder3 = yBorder * 3; yBorder4 = yBorder * 4; xInputOffset = Display_ScaleX(5); yInputOffset = Display_ScaleY(2); diff --git a/src/LWidgets.c b/src/LWidgets.c index 8b7ca47ae..3893bf907 100644 --- a/src/LWidgets.c +++ b/src/LWidgets.c @@ -19,8 +19,14 @@ static int oneX, twoX, fourX; static int oneY, twoY, fourY; void LWidget_CalcOffsets(void) { - oneX = Display_ScaleX(1); twoX = oneX * 2; fourX = oneX * 4; - oneY = Display_ScaleY(1); twoY = oneY * 2; fourY = oneY * 4; + oneX = Display_ScaleX(1); + oneY = Display_ScaleY(1); + + if (oneX < 1) { oneX = 1; } + if (oneY < 1) { oneY = 1; } + + twoX = oneX * 2; fourX = oneX * 4; + twoY = oneY * 2; fourY = oneY * 4; flagXOffset = Display_ScaleX(2); flagYOffset = Display_ScaleY(6); diff --git a/src/Launcher.c b/src/Launcher.c index 36d9c6bae..fa90ab531 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -529,7 +529,7 @@ void Launcher_DrawTitle(struct FontDesc* font, const char* text, struct Context2 int x; /* Skip dragging logo when very small window to save space */ - if (WindowInfo.Height < 300) return; + if (WindowInfo.Height < 240) return; DrawTextArgs_Make(&args, &title, font, false); x = ctx->width / 2 - Drawer2D_TextWidth(&args) / 2; diff --git a/src/Window_3DS.c b/src/Window_3DS.c index 977667faf..5652e1992 100644 --- a/src/Window_3DS.c +++ b/src/Window_3DS.c @@ -18,9 +18,9 @@ static Result irrst_result; struct _DisplayData DisplayInfo; struct _WinData WindowInfo; -// no DPI scaling on 3DS -int Display_ScaleX(int x) { return x; } -int Display_ScaleY(int y) { return y; } +// Render everything at half size due to the small resolution +int Display_ScaleX(int x) { return x / 2; } +int Display_ScaleY(int y) { return y / 2; } // Note from https://github.com/devkitPro/libctru/blob/master/libctru/include/3ds/gfx.h @@ -42,8 +42,8 @@ void Window_Init(void) { DisplayInfo.Width = height; // deliberately swapped DisplayInfo.Height = width; // deliberately swapped DisplayInfo.Depth = 4; // 32 bit - DisplayInfo.ScaleX = 1; - DisplayInfo.ScaleY = 1; + DisplayInfo.ScaleX = 0.5; + DisplayInfo.ScaleY = 0.5; WindowInfo.Width = height; // deliberately swapped WindowInfo.Height = width; // deliberately swapped @@ -277,4 +277,4 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) { cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) { return ERR_NOT_SUPPORTED; } -#endif \ No newline at end of file +#endif From 4d2de70f45ed63c9ec2e9f300b53e8f399e55a41 Mon Sep 17 00:00:00 2001 From: camthehaxman Date: Thu, 18 Jan 2024 19:13:52 -0600 Subject: [PATCH 2/2] increase stick deadzone to 16 --- src/Window_3DS.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Window_3DS.c b/src/Window_3DS.c index 5652e1992..3ff477d13 100644 --- a/src/Window_3DS.c +++ b/src/Window_3DS.c @@ -101,10 +101,10 @@ static void HandleButtons(u32 mods) { static void ProcessJoystickInput(circlePosition* pos, double delta) { float scale = (delta * 60.0) / 8.0f; - + // May not be exactly 0 on actual hardware - if (Math_AbsI(pos->dx) <= 8) pos->dx = 0; - if (Math_AbsI(pos->dy) <= 8) pos->dy = 0; + if (Math_AbsI(pos->dx) <= 16) pos->dx = 0; + if (Math_AbsI(pos->dy) <= 16) pos->dy = 0; Event_RaiseRawMove(&PointerEvents.RawMoved, pos->dx * scale, -pos->dy * scale); } @@ -148,7 +148,6 @@ void Window_ProcessEvents(double delta) { hidCircleRead(&pos); ProcessJoystickInput(&pos, delta); } - if (Input.RawMode && irrst_result == 0) { circlePosition pos; irrstScanInput();