Skip to content

Commit 9b11378

Browse files
committed
Switch: Some QOL changes
- hack: make the menu accessible with "+" - Invert Controller buttons A/B X/Y - Enable network log only for debug builds - Enable touchscreen mouse emulation Also add myself to the credits in README
1 parent 4ef3903 commit 9b11378

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ CMakeSettings.json
179179
tic_mruby_build_config.rb.lock
180180
tic_mruby_wasm_build_config.rb.lock
181181
build/mruby_vendor-prefix/
182+
# switch
183+
build/*.nro
184+
build/*.nacp
185+
build/*.lst
186+
build/*.map
182187
**/.zig-cache
183188
**/zig-out
184189
.cache

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,4 @@ You can find the compiled version ready download and install [on F-Droid](https:
424424
* NuSan — [Github @TheNuSan](https://github.com/thenusan)
425425
* Li Jin — [Github @pigpigyyy](https://github.com/pigpigyyy)
426426
* Dania Rifki — [Github @Kaleidosium](https://github.com/Kaleidosium)
427+
* Carsten Teibes — [GitHub @carstene1ns](https://github.com/carstene1ns)

src/system/nswitch/runtime.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
#include <stdio.h>
2525
#include <unistd.h>
2626

27+
#ifdef DEBUG
2728
static int nxlink_sock = -1;
2829

2930
static void nxlink_init() {
31+
socketInitializeDefault();
3032
nxlink_sock = nxlinkStdio();
3133
if (nxlink_sock >= 0)
3234
printf("nxlink activated...\n");
@@ -37,18 +39,21 @@ static void nxlink_exit() {
3739
close(nxlink_sock);
3840
nxlink_sock = -1;
3941
}
42+
socketExit();
4043
}
44+
#else
45+
static void nxlink_init() {}
46+
static void nxlink_exit() {}
47+
#endif
4148

4249
// these hooks are called by libnx
4350

4451
void userAppInit() {
45-
socketInitializeDefault(); // enable network
46-
nxlink_init(); // enable debug log
47-
romfsInit(); // to find some engine data
52+
nxlink_init(); // enable debug log over network
53+
romfsInit(); // can be used for engine data or a shipped game
4854
}
4955

5056
void userAppExit() {
5157
romfsExit();
5258
nxlink_exit();
53-
socketExit();
5459
}

src/system/sdl/main.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#include <string.h>
3030
#include <time.h>
3131

32+
#ifdef __SWITCH__
33+
// from studio/studio.h
34+
extern void gotoMenu(Studio* studio);
35+
#endif
36+
3237
#if defined(__TIC_LINUX__)
3338
#include <signal.h>
3439
#endif
@@ -982,11 +987,26 @@ static void processGamepad()
982987
|| getAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX, +1)
983988
|| getButton(controller, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
984989

990+
#ifdef __SWITCH__
991+
// nintendo layout
992+
gamepad->a = getButton(controller, SDL_CONTROLLER_BUTTON_B);
993+
gamepad->b = getButton(controller, SDL_CONTROLLER_BUTTON_A);
994+
gamepad->x = getButton(controller, SDL_CONTROLLER_BUTTON_Y);
995+
gamepad->y = getButton(controller, SDL_CONTROLLER_BUTTON_X);
996+
997+
// "+" is a common way to quit homebrew, let's show the menu
998+
if(getButton(controller, SDL_CONTROLLER_BUTTON_START))
999+
{
1000+
//studio_exit(platform.studio);
1001+
gotoMenu(platform.studio);
1002+
}
1003+
#else
1004+
// xbox layout
9851005
gamepad->a = getButton(controller, SDL_CONTROLLER_BUTTON_A);
9861006
gamepad->b = getButton(controller, SDL_CONTROLLER_BUTTON_B);
9871007
gamepad->x = getButton(controller, SDL_CONTROLLER_BUTTON_X);
9881008
gamepad->y = getButton(controller, SDL_CONTROLLER_BUTTON_Y);
989-
1009+
#endif
9901010
// !TODO: We have to find a better way to handle gamepad MENU button
9911011
// atm we show game menu for only Pause Menu button on XBox one controller
9921012
// issue #1220
@@ -1899,6 +1919,11 @@ static s32 start(s32 argc, char **argv, const char* folder)
18991919
#if defined(__MACOSX__)
19001920
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
19011921
#endif
1922+
1923+
#ifdef __SWITCH__
1924+
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "1");
1925+
#endif
1926+
19021927
int result = SDL_Init(SDL_INIT_VIDEO);
19031928
if (result != 0)
19041929
{

0 commit comments

Comments
 (0)