mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 10:31:16 +00:00
Switch Port
Todo: Fix: Misc crashes when interacting on island. Todo: Fix: Joystick pointer is slow to move. Todo: Fix: Touch doesn't behave.
This commit is contained in:
parent
f2226e65cb
commit
2897078032
@ -18,6 +18,12 @@ if (EMSCRIPTEN)
|
||||
set(SDL_PTHREADS ON CACHE BOOL "Enable SDL pthreads" FORCE)
|
||||
endif()
|
||||
|
||||
if (NINTENDO_SWITCH)
|
||||
set(CMAKE_TOOLCHAIN_FILE "${DEVKITPRO}/cmake/Switch.cmake" CACHE PATH "toolchain file")
|
||||
add_compile_definitions(__SWITCH__)
|
||||
add_compile_definitions(SDL_VIDEO_DRIVER_SWITCH)
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
@ -50,7 +56,7 @@ cmake_dependent_option(ISLE_DEBUG "Enable imgui debug" ON "NOT VITA" OFF)
|
||||
cmake_dependent_option(ISLE_USE_DX5 "Build with internal DirectX 5 SDK" "${NOT_MINGW}" "WIN32;CMAKE_SIZEOF_VOID_P EQUAL 4" OFF)
|
||||
cmake_dependent_option(ISLE_MINIWIN "Use miniwin" ON "NOT ISLE_USE_DX5" OFF)
|
||||
cmake_dependent_option(ISLE_EXTENSIONS "Use extensions" ON "NOT ISLE_USE_DX5;NOT WINDOWS_STORE" OFF)
|
||||
cmake_dependent_option(ISLE_BUILD_CONFIG "Build CONFIG.EXE application" ON "MSVC OR ISLE_MINIWIN;NOT NINTENDO_3DS;NOT WINDOWS_STORE;NOT VITA" OFF)
|
||||
cmake_dependent_option(ISLE_BUILD_CONFIG "Build CONFIG.EXE application" ON "MSVC OR ISLE_MINIWIN;NOT NINTENDO_3DS;NOT NINTENDO_SWITCH;NOT WINDOWS_STORE;NOT VITA" OFF)
|
||||
cmake_dependent_option(ISLE_COMPILE_SHADERS "Compile shaders" ON "SDL_SHADERCROSS_BIN;TARGET Python3::Interpreter" OFF)
|
||||
cmake_dependent_option(CMAKE_POSITION_INDEPENDENT_CODE "Build with -fPIC" ON "NOT VITA" OFF)
|
||||
option(ENABLE_CLANG_TIDY "Enable clang-tidy")
|
||||
@ -85,6 +91,18 @@ if (DOWNLOAD_DEPENDENCIES)
|
||||
GIT_TAG "main"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
elseif (NINTENDO_SWITCH)
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
# Official repo missing Threads support?
|
||||
#GIT_REPOSITORY "https://github.com/devkitPro/SDL.git"
|
||||
#GIT_TAG "switch-sdl-3.2"
|
||||
GIT_REPOSITORY "https://github.com/vs49688/SDL.git"
|
||||
GIT_TAG "switch-sdl-3.2.14"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON CACHE BOOL "Disable PCH globally" FORCE)
|
||||
#set(SDL_PLATFORM_SWITCH ON CACHE BOOL "Enable Switch platform backend" FORCE)
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
@ -178,7 +196,8 @@ target_include_directories(Vec::Vec INTERFACE "${CMAKE_SOURCE_DIR}/3rdparty/vec"
|
||||
add_library(lego1
|
||||
LEGO1/main.cpp
|
||||
)
|
||||
target_precompile_headers(lego1 PRIVATE "LEGO1/lego1_pch.h")
|
||||
target_include_directories(lego1 PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1")
|
||||
target_precompile_headers(lego1 PRIVATE "<lego1_pch.h>")
|
||||
set_property(TARGET lego1 PROPERTY DEFINE_SYMBOL "LEGO1_DLL")
|
||||
target_include_directories(lego1 PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/util>")
|
||||
target_include_directories(lego1 PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/extensions/include>")
|
||||
@ -585,6 +604,12 @@ if (ISLE_BUILD_APP)
|
||||
ISLE/3ds/config.cpp
|
||||
)
|
||||
endif()
|
||||
if(NINTENDO_SWITCH)
|
||||
target_sources(isle PRIVATE
|
||||
ISLE/switch/filesys.cpp
|
||||
ISLE/switch/config.cpp
|
||||
)
|
||||
endif()
|
||||
if(WINDOWS_STORE)
|
||||
target_sources(isle PRIVATE
|
||||
ISLE/xbox_one_series/config.cpp
|
||||
|
||||
@ -65,6 +65,12 @@
|
||||
#include "3ds/config.h"
|
||||
#endif
|
||||
|
||||
#ifdef __SWITCH__
|
||||
#include <switch.h>
|
||||
#include "switch/filesys.h"
|
||||
#include "switch/config.h"
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS_STORE
|
||||
#include "xbox_one_series/config.h"
|
||||
#endif
|
||||
@ -1142,6 +1148,9 @@ bool IsleApp::LoadConfig()
|
||||
#ifdef __3DS__
|
||||
N3DS_SetupDefaultConfigOverrides(dict);
|
||||
#endif
|
||||
#ifdef __SWITCH__
|
||||
NX_SetupDefaultConfigOverrides(dict);
|
||||
#endif
|
||||
#ifdef WINDOWS_STORE
|
||||
XBONE_SetupDefaultConfigOverrides(dict);
|
||||
#endif
|
||||
|
||||
11
ISLE/switch/config.cpp
Normal file
11
ISLE/switch/config.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <SDL3/SDL_log.h>
|
||||
#include <iniparser.h>
|
||||
|
||||
void NX_SetupDefaultConfigOverrides(dictionary* p_dictionary)
|
||||
{
|
||||
iniparser_set(p_dictionary, "isle:diskpath", "sdmc:/switch/isle/LEGO/");
|
||||
iniparser_set(p_dictionary, "isle:cdpath", "sdmc:/switch/isle/");
|
||||
iniparser_set(p_dictionary, "isle:savepath", "sdmc:/switch/isle/");
|
||||
}
|
||||
8
ISLE/switch/config.h
Normal file
8
ISLE/switch/config.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef NX_CONFIG_H
|
||||
#define NX_CONFIG_H
|
||||
|
||||
#include "dictionary.h"
|
||||
|
||||
void NX_SetupDefaultConfigOverrides(dictionary* p_dictionary);
|
||||
|
||||
#endif // NX_CONFIG_H
|
||||
30
ISLE/switch/filesys.cpp
Normal file
30
ISLE/switch/filesys.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <cstdio>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "filesys.h"
|
||||
|
||||
bool NX_GetPathInfo(const char *path, SDL_PathInfo *info)
|
||||
{
|
||||
struct stat st_info;
|
||||
if (stat(path, &st_info) != 0)
|
||||
{
|
||||
if (info) info->type = SDL_PATHTYPE_NONE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (st_info.st_mode & S_IFDIR)
|
||||
{
|
||||
if (info)info->type = SDL_PATHTYPE_DIRECTORY;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (info) info->type = SDL_PATHTYPE_FILE;
|
||||
if (!info) return true;
|
||||
|
||||
auto *fp = fopen(path, "r");
|
||||
fseek(fp, 0, SEEK_END);
|
||||
if (info) info->size = ftell(fp);
|
||||
fclose(fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
10
ISLE/switch/filesys.h
Normal file
10
ISLE/switch/filesys.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef NX_FILESYS_H
|
||||
#define NX_FILESYS_H
|
||||
|
||||
#include <SDL3/SDL_filesystem.h>
|
||||
|
||||
#define SDL_GetPathInfo NX_GetPathInfo // Override broken SDL_GetPathInfo
|
||||
|
||||
bool NX_GetPathInfo(const char *path, SDL_PathInfo *info);
|
||||
|
||||
#endif // NX_FILESYS_H
|
||||
@ -69,6 +69,12 @@ if(NOT (VITA OR WINDOWS_STORE))
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NINTENDO_SWITCH)
|
||||
# Remove USE_OPENGL1 as incompatible.
|
||||
# Remove everything else as not needed.
|
||||
list(REMOVE_ITEM GRAPHICS_BACKENDS USE_SOFTWARE_RENDER USE_OPENGL1 USE_OPENGLES2) #USE_SDL_GPU
|
||||
endif()
|
||||
|
||||
if(VITA)
|
||||
add_subdirectory(src/d3drm/backends/gxm/shaders)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user