Skip to content

Commit c39beb0

Browse files
committed
add specializations for 3ds specific behavior in some places
1 parent 2c3d840 commit c39beb0

File tree

9 files changed

+21
-15
lines changed

9 files changed

+21
-15
lines changed

src/application.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include <stdexcept>
1111

1212
#if defined(__SWITCH__)
13-
#include "switch.h"
13+
#include <switch.h>
14+
#elif defined(__3DS__)
15+
#include <3ds.h>
1416
#endif
1517

1618
namespace {
@@ -63,10 +65,15 @@ void Application::run() {
6365
auto start_execution_time = std::chrono::steady_clock::now();
6466

6567
while (m_is_running
68+
//TODO factor out
6669
#if defined(__SWITCH__)
6770
// see https://switchbrew.github.io/libnx/applet_8h.html#a7ed640e5f4a81ed3960c763fdc1521c5
6871
// this checks for some other reasons why this app should quit, its switch specific
6972
and appletMainLoop()
73+
#elif defined(__3DS__)
74+
// see https://libctru.devkitpro.org/apt_8h.html#a84808c36d9a8c389896ecf241c7f89cb
75+
// this checks for some other reasons why this app should quit, its 3ds specific
76+
and aptMainLoop()
7077
#endif
7178

7279
) {

src/game/input_creator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "platform/replay_input.hpp"
88
#include <stdexcept>
99

10+
//TODO: support 3ds
1011
#if defined(__ANDROID__)
1112
#include "platform/android_input.hpp"
1213
#elif defined(__SWITCH__)

src/graphics/sdl_context.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#include <fmt/format.h>
77

88
#if defined(__SWITCH__)
9-
#include "switch.h"
9+
#include <switch.h>
10+
#elif defined(__3DS__)
11+
#include <3ds.h>
1012
#endif
1113

1214
#if defined(_HAVE_FILE_DIALOGS)
@@ -24,18 +26,18 @@ SdlContext::SdlContext() {
2426
throw helper::InitializationError{ fmt::format("Failed in initializing sdl ttf: {}", TTF_GetError()) };
2527
}
2628

27-
#if defined(__SWITCH__)
29+
#if defined(__SWITCH__) or defined(__3DS__)
2830
// based on: https://github.com/carstene1ns/switch-sdl2-demo
2931

3032
// mount the romfs in the executable as "romfs:/" (this is fine since only one app can run at the time on the switch)
3133
romfsInit();
3234

33-
// init joystick and other nintendo switch specific things
35+
// init joystick and other nintendo switch / 3ds specific things
3436
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
3537
SDL_JoystickEventState(SDL_ENABLE);
3638
// only use the first joystick!
3739

38-
//TODO, since local multiplayer on a switch is possible, test here if there are more then one joysticks available (e.g. left and right controller) then ask the user if he wants to play local multiplayer, implement that in JoystickInput (in the SDL event the joystick index is present)
40+
//TODO, since local multiplayer on a switch / 3ds is possible, test here if there are more then one joysticks available (e.g. left and right controller) then ask the user if he wants to play local multiplayer, implement that in JoystickInput (in the SDL event the joystick index is present)
3941
SDL_JoystickOpen(0);
4042

4143
#endif

src/helper/graphic_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ std::vector<std::string> utils::supported_features() {
5555
[[nodiscard]] std::filesystem::path utils::get_assets_folder() {
5656
#if defined(__ANDROID__)
5757
return std::filesystem::path{ "" };
58-
#elif defined(__SWITCH__)
58+
#elif defined(__SWITCH__) or defined(__3DS__)
5959
// this is in the internal storage of the nintendo switch, it ios mounted by libnx (runtime switch support library) and filled at compile time with assets (its called ROMFS there)
6060
return std::filesystem::path{ "romfs:/assets" };
6161
#elif defined(BUILD_INSTALLER)

src/main.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
#include <spdlog/sinks/rotating_file_sink.h>
1616
#include <spdlog/sinks/stdout_sinks.h>
1717

18-
#if defined(__SWITCH__)
19-
#include "switch.h"
20-
#include <string.h>
21-
#endif
22-
2318

2419
int main(int argc, char** argv) {
2520
const auto logs_path = utils::get_root_folder() / "logs";
@@ -60,7 +55,7 @@ int main(int argc, char** argv) {
6055
std::unique_ptr<Window> window{ nullptr };
6156

6257
try {
63-
#if defined(__ANDROID__) or defined(__SWITCH__)
58+
#if defined(__ANDROID__) or defined(__SWITCH__) or defined(__3DS__)
6459
window = std::make_unique<Window>(window_name, WindowPosition::Centered);
6560
#else
6661
static constexpr int width = 1280;

src/platform/capabilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "helper/utils.hpp"
66
#include "platform/capabilities.hpp"
77

8-
8+
//TODO: support 3ds too
99
#if defined(__SWITCH__)
1010
#include "platform/switch_buttons.hpp"
1111
#endif

src/platform/platform.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace utils {
2323

2424
#if defined(__ANDROID__)
2525
return "android";
26-
#elif defined(__SWITCH__)
26+
#elif defined(__SWITCH__) or defined(__3DS__)
2727
return "console";
2828
#else
2929
return "pc";

src/platform/switch_buttons.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#if defined(__SWITCH__)
66

77

8-
#include "switch.h"
8+
#include <switch.h>
99

1010
// some switch buttons, from libnx, but since SDL doesn't handle inputs as flags, like libnx, the have to be reversed and reversing 1 << x = log_2(x), this is done constexpr
1111

src/scenes/pause/pause.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#if defined(__SWITCH__)
99
#include "platform/switch_buttons.hpp"
1010
#endif
11+
1112
namespace scenes {
1213

1314
Pause::Pause(ServiceProvider* service_provider, const ui::Layout& layout) : Scene{ service_provider, layout }, m_heading {

0 commit comments

Comments
 (0)