Browse Source

[3DS] CMake re-visited

Reflect latest devkitpro libctru / 3ds-sdl-1.2 changes
 - Controls now use SDL_JOYSTICK with circlepad enabled
 - Shutdown / suspend / sleep are functional
pull/1032/head
MrHuu 6 years ago committed by Anders Jenbo
parent
commit
7e35651b2f
  1. 25
      CMake/ctr/Tools3DS.cmake
  2. 52
      CMake/ctr/devkitarm-libctru.cmake
  3. 65
      CMake/ctr/modules/FindBZIP2.cmake
  4. 7
      CMake/ctr/modules/FindCITRO3D.cmake
  5. 0
      CMake/ctr/modules/FindCTRULIB.cmake
  6. 59
      CMake/ctr/modules/FindFREETYPE.cmake
  7. 54
      CMake/ctr/modules/FindFreetype.cmake
  8. 7
      CMake/ctr/modules/FindMAD.cmake
  9. 7
      CMake/ctr/modules/FindMIKMOD.cmake
  10. 7
      CMake/ctr/modules/FindOGG.cmake
  11. 7
      CMake/ctr/modules/FindPNG.cmake
  12. 7
      CMake/ctr/modules/FindZLIB.cmake
  13. 55
      CMake/ctr/n3ds_defs.cmake
  14. 2
      CMake/switch/devkita64-libnx.cmake
  15. 2
      Packaging/ctr/build.sh
  16. 10
      SourceX/dx.cpp
  17. 15
      SourceX/platform/ctr/system.cpp
  18. 4
      SourceX/platform/ctr/system.h

25
CMake/ctr/Tools3DS.cmake

@ -89,7 +89,7 @@
#
############################################################################
if(NOT 3DS)
if(NOT N3DS)
message(WARNING "Those tools can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
@ -287,20 +287,21 @@ function(add_3dsx_target target)
if( NOT ${target_we}.smdh)
__add_smdh(${target_we}.smdh ${APP_TITLE} ${APP_DESCRIPTION} ${APP_AUTHOR} ${APP_ICON})
endif()
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.3dsx
COMMAND ${_3DSXTOOL} $<TARGET_FILE:${target}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.3dsx --romfs=${PROJECT_SOURCE_DIR}/res/romfs --smdh=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.smdh
DEPENDS ${target} ${ROMFS_FILES} ${SHADER_OUTPUT} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.smdh
VERBATIM
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.3dsx
COMMAND ${_3DSXTOOL} $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.3dsx --smdh=${CMAKE_CURRENT_BINARY_DIR}/${target_we}.smdh --romfs=${CMAKE_CURRENT_BINARY_DIR}/romfs
DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.smdh
VERBATIM
)
else()
message(STATUS "No smdh file will be generated")
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.3dsx
COMMAND ${_3DSXTOOL} $<TARGET_FILE:${target}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.3dsx
DEPENDS ${target}
VERBATIM
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.3dsx
COMMAND ${_3DSXTOOL} $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.3dsx --romfs=${CMAKE_CURRENT_BINARY_DIR}/romfs
DEPENDS ${target}
VERBATIM
)
endif()
add_custom_target(${target_we}.3dsx ALL SOURCES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.3dsx)
add_custom_target(${target_we}_3dsx ALL SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.3dsx)
#set_target_properties(${target} PROPERTIES LINK_FLAGS "-specs=3dsx.specs")
endfunction()
function(__add_ncch_banner target IMAGE SOUND)
@ -322,7 +323,7 @@ function(__add_ncch_banner target IMAGE SOUND)
)
endfunction()
function(add_cia_target target RSF IMAGE SOUND )
function(add_cia_target target RSF IMAGE SOUND)
get_filename_component(target_we ${target} NAME_WE)
if(${ARGC} GREATER 6)
set(APP_TITLE ${ARGV4})
@ -372,7 +373,7 @@ function(add_cia_target target RSF IMAGE SOUND )
)
add_custom_target(${target_we}_cia ALL SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.cia)
set_target_properties(${target} PROPERTIES LINK_FLAGS "-specs=3dsx.specs")
#set_target_properties(${target} PROPERTIES LINK_FLAGS "-specs=3dsx.specs")
endfunction()
macro(add_netload_target name target)

52
CMake/ctr/devkitarm-libctru.cmake

@ -1,52 +0,0 @@
# devkitPro paths are broken on Windows. We need to use this macro to fix those.
# from https://github.com/switchpy/libnx-template/blob/7037982c77e1767410143103d5963d0ddc77fb64/devkita64-libnx.cmake
macro(msys_to_cmake_path msys_path resulting_path)
if (WIN32)
string(REGEX REPLACE "^/([a-zA-Z])/" "\\1:/" ${resulting_path} ${msys_path})
else ()
set(${resulting_path} ${msys_path})
endif ()
endmacro()
msys_to_cmake_path($ENV{DEVKITPRO} DEVKITPRO)
if(NOT IS_DIRECTORY ${DEVKITPRO})
message(FATAL_ERROR "Please set DEVKITPRO in your environment")
endif()
# Default devkitpro cmake
include(${DEVKITPRO}/3ds.cmake)
# Hack: -specs=3dsx.specs is defined both by `3ds.cmake` and `sdl-config --libs`.
# Remove the `3ds.cmake` one.
string(REGEX REPLACE " -specs=3dsx\\.specs$" "" CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
# Set root paths:
set(DEVKITARM ${DEVKITPRO}/devkitARM)
set(PORTLIBS_PATH ${DEVKITPRO}/portlibs)
set(PORTLIBS ${PORTLIBS_PATH}/3ds)
set(CMAKE_FIND_ROOT_PATH ${DEVKITARM} ${DEVKITPRO} ${PORTLIBS})
# Set absolute tool paths:
set(TOOLCHAIN_PREFIX ${DEVKITARM}/bin/arm-none-eabi-)
if(WIN32)
set(TOOLCHAIN_SUFFIX ".exe")
else()
set(TOOLCHAIN_SUFFIX "")
endif()
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc${TOOLCHAIN_SUFFIX})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++${TOOLCHAIN_SUFFIX})
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}as${TOOLCHAIN_SUFFIX})
set(PKG_CONFIG_EXECUTABLE ${TOOLCHAIN_PREFIX}pkg-config${TOOLCHAIN_SUFFIX})
set(CMAKE_AR ${TOOLCHAIN_PREFIX}gcc-ar${TOOLCHAIN_SUFFIX} CACHE STRING "")
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}gcc-ranlib${TOOLCHAIN_SUFFIX} CACHE STRING "")
set(CMAKE_LD "/${TOOLCHAIN_PREFIX}ld${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "")
set(CMAKE_OBJCOPY "${TOOLCHAIN_PREFIX}objcopy${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "")
set(CMAKE_SIZE_UTIL "${TOOLCHAIN_PREFIX}size${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "")
set(3DS ON)
add_definitions(-D__3DS__ -D_3DS) # _3DS is used and expected by the devkit SDL headers.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mword-relocations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
set(CMAKE_INSTALL_PREFIX ${PORTLIBS} CACHE PATH "Install libraries in the portlibs dir")

65
CMake/ctr/modules/FindBZIP2.cmake

@ -0,0 +1,65 @@
# - Try to find BZip2
# You can set BZIP2_ROOT to specify a certain directory to look in first.
# Once done this will define
# BZIP2_FOUND - System has BZip2
# BZIP2_INCLUDE_DIRS - The BZip2 include directories
# BZIP2_LIBRARIES - The libraries needed to use BZip2
# Unless we are unable to find ZLIB
# It also adds an imported target named `3ds::bzip2`, Linking against it is
# equivalent to:
# target_link_libraries(mytarget ${BZIP2_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${BZIP2_INCLUDE_DIRS})
if(NOT N3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(BZIP2_INCLUDE_DIR)
# Already in cache, be silent
set(BZIP2_FIND_QUIETLY TRUE)
endif(BZIP2_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)
#libfind_package(BZIP2)
set(_BZIP2_SEARCHES)
# Search BZIP2_ROOT first if it is set.
if(BZIP2_ROOT)
set(_BZIP2_SEARCH_ROOT
PATHS ${BZIP2_ROOT}
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH)
list(APPEND _BZIP2_SEARCHES _BZIP2_SEARCH_ROOT)
endif()
# Search below ${DEVKITPRO}, ${DEVKITARM}, portlibs (if enabled) etc.
set(_BZIP2_SEARCH_NORMAL
PATHS /
NO_DEFAULT_PATH
ONLY_CMAKE_FIND_ROOT_PATH)
list(APPEND _BZIP2_SEARCHES _BZIP2_SEARCH_NORMAL)
foreach(search ${_BZIP2_SEARCHES})
find_path(BZIP2_INCLUDE_DIR NAMES bzlib.h
${${search}}
PATH_SUFFIXES include)
find_library(BZIP2_LIBRARY NAMES bzip2 libbz2.a
${${search}}
PATH_SUFFIXES lib)
endforeach()
#find_library(LIBM_LIBRARY NAMES m libm.a
# PATHS / /arm-none-eabi
# PATH_SUFFIXES lib/armv6k/fpu)
set(LIBM_LIBRARY m)
set(BZIP2_PROCESS_INCLUDES BZIP2_INCLUDE_DIR)
set(BZIP2_PROCESS_LIBS BZIP2_LIBRARY LIBM_LIBRARY)
libfind_process(BZIP2)
try_add_imported_target(BZIP2 m)

7
CMake/ctr/modules/FindCITRO3D.cmake

@ -10,10 +10,15 @@
# target_link_libraries(mytarget ${CITRO3D_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${CITRO3D_INCLUDE_DIRS})
if(NOT 3DS)
if(NOT N3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(CITRO3D_INCLUDE_DIR)
# Already in cache, be silent
set(CITRO3D_FIND_QUIETLY TRUE)
endif(CITRO3D_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)

0
CMake/ctr/FindCTRULIB.cmake → CMake/ctr/modules/FindCTRULIB.cmake

59
CMake/ctr/modules/FindFREETYPE.cmake

@ -0,0 +1,59 @@
# - Try to find freetype
# You can set FREETYPE_ROOT to specify a certain directory to look in first.
# Once done this will define
# FREETYPE_FOUND - System has freetype
# FREETYPE_INCLUDE_DIRS - The freetype include directories
# FREETYPE_LIBRARIES - The libraries needed to use freetype
# Unless we are unable to find ZLIB
# It also adds an imported target named `3ds::freetype`, Linking against it is
# equivalent to:
# target_link_libraries(mytarget ${FREETYPE_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${FREETYPE_INCLUDE_DIRS})
if(NOT N3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(FREETYPE_INCLUDE_DIR)
# Already in cache, be silent
set(FREETYPE_FIND_QUIETLY TRUE)
endif(FREETYPE_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)
libfind_package(FREETYPE ZLIB)
set(_FREETYPE_SEARCHES)
# Search FREETYPE_ROOT first if it is set.
if(FREETYPE_ROOT)
set(_FREETYPE_SEARCH_ROOT
PATHS ${FREETYPE_ROOT}
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH)
list(APPEND _FREETYPE_SEARCHES _FREETYPE_SEARCH_ROOT)
endif()
# Search below ${DEVKITPRO}, ${DEVKITARM}, portlibs (if enabled) etc.
set(_FREETYPE_SEARCH_NORMAL
PATHS /
NO_DEFAULT_PATH
ONLY_CMAKE_FIND_ROOT_PATH)
list(APPEND _FREETYPE_SEARCHES _FREETYPE_SEARCH_NORMAL)
foreach(search ${_FREETYPE_SEARCHES})
find_path(FREETYPE_INCLUDE_DIR NAMES freetype/config/ftheader.h config/ftheader.h
${${search}}
PATH_SUFFIXES include/freetype2 include freetype2)
find_library(FREETYPE_LIBRARY NAMES freetype libfreetype.a
${${search}}
PATH_SUFFIXES lib)
endforeach()
set(FREETYPE_PROCESS_INCLUDES FREETYPE_INCLUDE_DIR)
set(FREETYPE_PROCESS_LIBS FREETYPE_LIBRARY)
libfind_process(FREETYPE)
try_add_imported_target(FREETYPE 3ds::zlib)

54
CMake/ctr/modules/FindFreetype.cmake

@ -1,54 +0,0 @@
# - Try to find freetype
# You can set Freetype_ROOT to specify a certain directory to look in first.
# Once done this will define
# Freetype_FOUND - System has freetype
# Freetype_INCLUDE_DIRS - The freetype include directories
# Freetype_LIBRARIES - The libraries needed to use freetype
# Unless we are unable to find ZLIB
# It also adds an imported target named `3ds::freetype`, Linking against it is
# equivalent to:
# target_link_libraries(mytarget ${Freetype_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${Freetype_INCLUDE_DIRS})
if(NOT 3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
include(LibFindMacros)
include(try_add_imported_target)
libfind_package(Freetype ZLIB)
set(_Freetype_SEARCHES)
# Search Freetype_ROOT first if it is set.
if(Freetype_ROOT)
set(_Freetype_SEARCH_ROOT
PATHS ${Freetype_ROOT}
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH)
list(APPEND _Freetype_SEARCHES _Freetype_SEARCH_ROOT)
endif()
# Search below ${DEVKITPRO}, ${DEVKITARM}, portlibs (if enabled) etc.
set(_Freetype_SEARCH_NORMAL
PATHS /
NO_DEFAULT_PATH
ONLY_CMAKE_FIND_ROOT_PATH)
list(APPEND _Freetype_SEARCHES _Freetype_SEARCH_NORMAL)
foreach(search ${_Freetype_SEARCHES})
find_path(Freetype_INCLUDE_DIR NAMES freetype/config/ftheader.h config/ftheader.h
${${search}}
PATH_SUFFIXES include/freetype2 include freetype2)
find_library(Freetype_LIBRARY NAMES freetype libfreetype.a
${${search}}
PATH_SUFFIXES lib)
endforeach()
set(Freetype_PROCESS_INCLUDES Freetype_INCLUDE_DIR)
set(Freetype_PROCESS_LIBS Freetype_LIBRARY)
libfind_process(Freetype)
try_add_imported_target(Freetype 3ds::zlib)

7
CMake/ctr/modules/FindMAD.cmake

@ -10,10 +10,15 @@
# target_link_libraries(mytarget ${MAD_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${MAD_INCLUDE_DIRS})
if(NOT 3DS)
if(NOT N3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(MAD_INCLUDE_DIR)
# Already in cache, be silent
set(MAD_FIND_QUIETLY TRUE)
endif(MAD_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)

7
CMake/ctr/modules/FindMikMod.cmake → CMake/ctr/modules/FindMIKMOD.cmake

@ -10,10 +10,15 @@
# target_link_libraries(mytarget ${MIKMOD_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${MIKMOD_INCLUDE_DIRS})
if(NOT 3DS)
if(NOT N3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(MIKMOD_INCLUDE_DIR)
# Already in cache, be silent
set(MIKMOD_FIND_QUIETLY TRUE)
endif(MIKMOD_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)

7
CMake/ctr/modules/FindOgg.cmake → CMake/ctr/modules/FindOGG.cmake

@ -10,10 +10,15 @@
# target_link_libraries(mytarget ${OGG_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${OGG_INCLUDE_DIRS})
if(NOT 3DS)
if(NOT N3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(OGG_INCLUDE_DIR)
# Already in cache, be silent
set(OGG_FIND_QUIETLY TRUE)
endif(OGG_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)

7
CMake/ctr/modules/FindPNG.cmake

@ -10,10 +10,15 @@
# target_link_libraries(mytarget ${PNG_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${PNG_INCLUDE_DIRS})
if(NOT 3DS)
if(NOT N3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(PNG_INCLUDE_DIR)
# Already in cache, be silent
set(PNG_FIND_QUIETLY TRUE)
endif(PNG_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)

7
CMake/ctr/modules/FindZLIB.cmake

@ -9,10 +9,15 @@
# target_link_libraries(mytarget ${ZLIB_LIBRARY})
# target_include_directories(mytarget PRIVATE ${ZLIB_INCLUDE_DIRS})
if(NOT 3DS)
if(NOT N3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(ZLIB_INCLUDE_DIR)
# Already in cache, be silent
set(ZLIB_FIND_QUIETLY TRUE)
endif(ZLIB_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)

55
CMake/ctr/n3ds_defs.cmake

@ -1,18 +1,41 @@
#General compilation options
set(NONET ON)
set(USE_SDL1 ON)
set(SDL1_VIDEO_MODE_FLAGS SDL_SWSURFACE|SDL_CONSOLEBOTTOM)
set(PREFILL_PLAYER_NAME ON)
set(HAS_KBCTRL 1)
set(KBCTRL_BUTTON_DPAD_LEFT SDLK_LEFT)
set(KBCTRL_BUTTON_DPAD_RIGHT SDLK_RIGHT)
set(KBCTRL_BUTTON_DPAD_UP SDLK_UP)
set(KBCTRL_BUTTON_DPAD_DOWN SDLK_DOWN)
set(KBCTRL_BUTTON_B SDLK_a)
set(KBCTRL_BUTTON_A SDLK_b)
set(KBCTRL_BUTTON_Y SDLK_y)
set(KBCTRL_BUTTON_X SDLK_x)
set(KBCTRL_BUTTON_RIGHTSHOULDER SDLK_r)
set(KBCTRL_BUTTON_LEFTSHOULDER SDLK_l)
set(KBCTRL_BUTTON_START SDLK_RETURN)
set(KBCTRL_BUTTON_BACK SDLK_ESCAPE)
set(KBCTRL_MODIFIER_KEY SDLK_END)
#3DS libraries
list(APPEND CMAKE_MODULE_PATH "${DevilutionX_SOURCE_DIR}/CMake/ctr/modules")
find_package(CITRO3D REQUIRED)
find_package(FREETYPE REQUIRED)
find_package(BZIP2 REQUIRED)
find_package(Tremor REQUIRED)
find_package(OGG REQUIRED)
find_package(MIKMOD REQUIRED)
find_package(MAD REQUIRED)
find_package(PNG REQUIRED)
#additional compilation definitions
add_definitions(-D__3DS__)
#Force scaling, for now..
set(SDL1_VIDEO_MODE_FLAGS SDL_FULLSCREEN)
set(SDL1_VIDEO_MODE_WIDTH 800)
set(SDL1_VIDEO_MODE_HEIGHT 480)
#SDL Joystick axis mapping (circle-pad)
set(JOY_AXIS_LEFTX 0)
set(JOY_AXIS_LEFTY 1)
#SDL Joystick button mapping (A / B inverted)
set(JOY_BUTTON_A 2)
set(JOY_BUTTON_B 1)
set(JOY_BUTTON_X 3)
set(JOY_BUTTON_Y 4)
set(JOY_BUTTON_LEFTSHOULDER 5)
set(JOY_BUTTON_RIGHTSHOULDER 6)
set(JOY_BUTTON_BACK 7)
set(JOY_BUTTON_START 0)
set(JOY_BUTTON_DPAD_DOWN 8)
set(JOY_BUTTON_DPAD_LEFT 9)
set(JOY_BUTTON_DPAD_UP 10)
set(JOY_BUTTON_DPAD_RIGHT 11)
set(JOY_BUTTON_TRIGGERLEFT 12)
set(JOY_BUTTON_TRIGGERRIGHT 13)

2
CMake/switch/devkita64-libnx.cmake

@ -47,5 +47,7 @@ set(CMAKE_LD "/${TOOLCHAIN_PREFIX}ld${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "")
set(CMAKE_OBJCOPY "${TOOLCHAIN_PREFIX}objcopy${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "")
set(CMAKE_SIZE_UTIL "${TOOLCHAIN_PREFIX}size${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "")
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available")
set(SWITCH ON)
add_definitions(-D__SWITCH__ -DSWITCH)

2
Packaging/ctr/build.sh

@ -19,7 +19,7 @@ build() {
cd ../../build
rm -f CMakeCache.txt
DEVKITPRO="$DEVKITPRO" cmake .. -DBINARY_RELEASE=ON \
-DCMAKE_TOOLCHAIN_FILE=../CMake/ctr/devkitarm-libctru.cmake
-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/3ds.cmake
DEVKITPRO="$DEVKITPRO" make -j "$(nproc)"
cd -
}

10
SourceX/dx.cpp

@ -8,6 +8,10 @@
#include "display.h"
#include <SDL.h>
#ifdef __3DS__
#include <3ds.h>
#endif
namespace dvl {
int sgdwLockCount;
@ -252,9 +256,8 @@ void LimitFrameRate()
void RenderPresent()
{
SDL_Surface *surface = GetOutputSurface();
#if !defined(__3DS__)
assert(!SDL_MUSTLOCK(surface));
#endif
if (!gbActive) {
LimitFrameRate();
return;
@ -290,6 +293,9 @@ void RenderPresent()
LimitFrameRate();
}
#else
#ifdef __3DS__
gspWaitForVBlank();
#endif
if (SDL_Flip(surface) <= -1) {
ErrSdl();
}

15
SourceX/platform/ctr/system.cpp

@ -0,0 +1,15 @@
#include <stdlib.h>
#include <3ds.h>
#include "platform/ctr/system.h"
void ctr_sys_init()
{
bool isN3DS;
APT_CheckNew3DS(&isN3DS);
if(isN3DS)
osSetSpeedupEnable(true);
romfsInit();
atexit([]() { romfsExit(); });
}

4
SourceX/platform/ctr/system.h

@ -0,0 +1,4 @@
#pragma once
void ctr_sys_init();
Loading…
Cancel
Save