Browse Source
Reflect latest devkitpro libctru / 3ds-sdl-1.2 changes - Controls now use SDL_JOYSTICK with circlepad enabled - Shutdown / suspend / sleep are functionalpull/1032/head
18 changed files with 242 additions and 143 deletions
@ -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") |
||||
@ -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) |
||||
@ -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) |
||||
@ -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) |
||||
@ -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) |
||||
|
||||
@ -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(); }); |
||||
} |
||||
Loading…
Reference in new issue