From 4c1ef01d5410ed3476643702e97db4037116263f Mon Sep 17 00:00:00 2001 From: p-sam Date: Wed, 18 Mar 2026 13:14:29 +0100 Subject: [PATCH 1/4] Add switch case in egl platform types --- include/SDL3/SDL_egl.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/SDL3/SDL_egl.h b/include/SDL3/SDL_egl.h index 65d4e967afd61..b3114e0984d2a 100644 --- a/include/SDL3/SDL_egl.h +++ b/include/SDL3/SDL_egl.h @@ -494,6 +494,12 @@ typedef void *EGLNativeDisplayType; typedef khronos_uintptr_t EGLNativePixmapType; typedef khronos_uintptr_t EGLNativeWindowType; +#elif defined(__SWITCH__) + +typedef int EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + #else #error "Platform not recognized" #endif From 5cf63e7e180abb9c69f4876e2c1ab4ffe1a48fcc Mon Sep 17 00:00:00 2001 From: p-sam Date: Wed, 18 Mar 2026 13:16:14 +0100 Subject: [PATCH 2/4] Add switch locale functions --- CMakeLists.txt | 3 + src/locale/switch/SDL_syslocale.c | 113 ++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 src/locale/switch/SDL_syslocale.c diff --git a/CMakeLists.txt b/CMakeLists.txt index c73371e30f8fd..4c080c204e065 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3454,6 +3454,9 @@ elseif(NINTENDO_SWITCH) set(HAVE_CLOCK_GETTIME 1) endif() + sdl_glob_sources("${SDL3_SOURCE_DIR}/src/locale/switch/*.c") + set(HAVE_SDL_LOCALE TRUE) + set(SDL_TIMER_SWITCH 1) sdl_glob_sources("${SDL3_SOURCE_DIR}/src/timer/switch/*.c") set(HAVE_SDL_TIMERS TRUE) diff --git a/src/locale/switch/SDL_syslocale.c b/src/locale/switch/SDL_syslocale.c new file mode 100644 index 0000000000000..18144679c7a11 --- /dev/null +++ b/src/locale/switch/SDL_syslocale.c @@ -0,0 +1,113 @@ +/* + Simple DirectMedia Layer + Copyright (C) 2026 p-sam + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" +#include "../SDL_syslocale.h" + +#include + +static SetLanguage getSwitchSystemLanguage(void) { + Result rc = setInitialize(); + + if(R_SUCCEEDED(rc)) { + + u64 code; + rc = setGetSystemLanguage(&code); + + SetLanguage language; + if(R_SUCCEEDED(rc)) { + rc = setMakeLanguage(code, &language); + } + + setExit(); + + if(R_SUCCEEDED(rc)) { + return language; + } + } + + return SetLanguage_Total; +} + +bool SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { + switch(getSwitchSystemLanguage()) { + case SetLanguage_JA: + SDL_strlcpy(buf, "ja_JP", buflen); + break; + case SetLanguage_FR: + SDL_strlcpy(buf, "fr_FR", buflen); + break; + case SetLanguage_DE: + SDL_strlcpy(buf, "de_DE", buflen); + break; + case SetLanguage_IT: + SDL_strlcpy(buf, "it_IT", buflen); + break; + case SetLanguage_ES: + SDL_strlcpy(buf, "es_ES", buflen); + break; + case SetLanguage_ZHCN: + SDL_strlcpy(buf, "zh_CN", buflen); + break; + case SetLanguage_KO: + SDL_strlcpy(buf, "ko_KR", buflen); + break; + case SetLanguage_NL: + SDL_strlcpy(buf, "nl_NL", buflen); + break; + case SetLanguage_PT: + SDL_strlcpy(buf, "pt_PT", buflen); + break; + case SetLanguage_RU: + SDL_strlcpy(buf, "ru_RU", buflen); + break; + case SetLanguage_ZHTW: + SDL_strlcpy(buf, "zh_TW", buflen); + break; + case SetLanguage_ENGB: + SDL_strlcpy(buf, "en_GB", buflen); + break; + case SetLanguage_FRCA: + SDL_strlcpy(buf, "fr_CA", buflen); + break; + case SetLanguage_ES419: + SDL_strlcpy(buf, "es_419", buflen); + break; + case SetLanguage_ZHHANS: + break; + SDL_strlcpy(buf, "zh_CN", buflen); + break; + case SetLanguage_ZHHANT: + SDL_strlcpy(buf, "zh_TW", buflen); + break; + case SetLanguage_PTBR: + SDL_strlcpy(buf, "pt_BR", buflen); + break; + case SetLanguage_ENUS: + default: + SDL_strlcpy(buf, "en_US", buflen); + break; + } + + return true; +} + +/* vi: set ts=4 sw=4 expandtab: */ From 2612e3b489496821b8fa445f860e50ddfcce5de4 Mon Sep 17 00:00:00 2001 From: p-sam Date: Sat, 25 Jul 2026 13:41:53 +0200 Subject: [PATCH 3/4] Fix comment typo --- src/power/SDL_power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index 34f2ddf6158e4..e798c569cf545 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -71,7 +71,7 @@ static SDL_GetPowerInfo_Impl implementations[] = { #ifdef SDL_POWER_N3DS // handles N3DS. SDL_GetPowerInfo_N3DS, #endif -#ifdef SDL_POWER_SWITCH // handles N3DS. +#ifdef SDL_POWER_SWITCH // handles Switch. SDL_GetPowerInfo_SWITCH, #endif #ifdef SDL_POWER_EMSCRIPTEN // handles Emscripten From f9c63f741219ce377ea23eaed645f622b683e855 Mon Sep 17 00:00:00 2001 From: p-sam Date: Sat, 25 Jul 2026 15:57:56 +0200 Subject: [PATCH 4/4] fix SDL_VIDEO_DRIVER_SWITCH not being set on certain occasions adding sdl3 as a meson subproject causes undefined references at link time --- src/video/switch/SDL_switchkeyboard.c | 3 +++ src/video/switch/SDL_switchmouse.c | 2 ++ src/video/switch/SDL_switchopengles.c | 2 ++ src/video/switch/SDL_switchtouch.c | 1 + src/video/switch/SDL_switchvideo.c | 2 ++ 5 files changed, 10 insertions(+) diff --git a/src/video/switch/SDL_switchkeyboard.c b/src/video/switch/SDL_switchkeyboard.c index 13032323fc78d..ae54171a001d3 100644 --- a/src/video/switch/SDL_switchkeyboard.c +++ b/src/video/switch/SDL_switchkeyboard.c @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ + +#include "SDL_internal.h" + #if SDL_VIDEO_DRIVER_SWITCH #include diff --git a/src/video/switch/SDL_switchmouse.c b/src/video/switch/SDL_switchmouse.c index 677deddb01093..c89158406a53c 100644 --- a/src/video/switch/SDL_switchmouse.c +++ b/src/video/switch/SDL_switchmouse.c @@ -19,6 +19,8 @@ 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_internal.h" + #if SDL_VIDEO_DRIVER_SWITCH #include diff --git a/src/video/switch/SDL_switchopengles.c b/src/video/switch/SDL_switchopengles.c index 523d89171d9ec..66fd2bd3d9f00 100644 --- a/src/video/switch/SDL_switchopengles.c +++ b/src/video/switch/SDL_switchopengles.c @@ -18,6 +18,8 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ + +#include "SDL_internal.h" #include "../../SDL_log_c.h" #if SDL_VIDEO_DRIVER_SWITCH diff --git a/src/video/switch/SDL_switchtouch.c b/src/video/switch/SDL_switchtouch.c index b4c67165af1ac..055c1e72d6751 100644 --- a/src/video/switch/SDL_switchtouch.c +++ b/src/video/switch/SDL_switchtouch.c @@ -18,6 +18,7 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ + #include "SDL_internal.h" #if SDL_VIDEO_DRIVER_SWITCH diff --git a/src/video/switch/SDL_switchvideo.c b/src/video/switch/SDL_switchvideo.c index 87428777bb734..c872c873dea1c 100644 --- a/src/video/switch/SDL_switchvideo.c +++ b/src/video/switch/SDL_switchvideo.c @@ -19,6 +19,8 @@ 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_internal.h" + #if SDL_VIDEO_DRIVER_SWITCH #include "../../events/SDL_keyboard_c.h"