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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions include/SDL3/SDL_egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
113 changes: 113 additions & 0 deletions src/locale/switch/SDL_syslocale.c
Original file line number Diff line number Diff line change
@@ -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 <switch.h>

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: */
2 changes: 1 addition & 1 deletion src/power/SDL_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/video/switch/SDL_switchkeyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <switch.h>
Expand Down
2 changes: 2 additions & 0 deletions src/video/switch/SDL_switchmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <switch.h>
Expand Down
2 changes: 2 additions & 0 deletions src/video/switch/SDL_switchopengles.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/video/switch/SDL_switchtouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/video/switch/SDL_switchvideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down