forked from taisei-project/taisei
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch homebrew port (taisei-project#173)
* Initial port * Switch specific video modes * Handle clean exit * Hide option to disable gamepads, force it enabled * Match buttons layout with Switch controllers * Hide player name setting (to avoid getting stuck) * Switch specific VFS setup instead of env bootstrap * Clean up, get rid of warnings and a few ifdefs * Add Switch specific build script and assets * Make vfs setup mount packages * Re-enable packaging on Switch * Transpile shaders to es and install them * Add applet warning and shader deps to README * Remove script; instead using meson build scripts * Strict prototypes * Build script compat with project minimum meson ver Refactor of pack.py exclude option * Uniformise header inclusion on arch_switch.c * Allow input for any dev; hide the option on Switch * Silence unsused function warnings
- Loading branch information
Showing
24 changed files
with
477 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* This software is licensed under the terms of the MIT-License | ||
* See COPYING for further information. | ||
* --- | ||
* Copyright (c) 2019, p-sam <p-sam@d3vs.net>. | ||
*/ | ||
|
||
#include "taisei.h" | ||
|
||
#include "arch_switch.h" | ||
|
||
#include <switch/runtime/devices/socket.h> | ||
#include <switch/runtime/nxlink.h> | ||
#include <switch/services/applet.h> | ||
#include <switch/services/fs.h> | ||
|
||
#define NX_LOG_FMT(fmt, ...) tsfprintf(stdout, "[NX] " fmt "\n", ##__VA_ARGS__) | ||
#define NX_LOG(str) NX_LOG_FMT("%s", str) | ||
#define NX_SETENV(name, val) NX_LOG_FMT("Setting env var %s to %s", name, val);env_set_string(name, val, true) | ||
|
||
static nxAtExitFn g_nxAtExitFn = NULL; | ||
static char g_programDir[FS_MAX_PATH] = {0}; | ||
static AppletHookCookie g_hookCookie; | ||
|
||
static void onAppletHook(AppletHookType hook, void *param) { | ||
switch (hook) { | ||
case AppletHookType_OnExitRequest: | ||
NX_LOG("Got AppletHook OnExitRequest, exiting.\n"); | ||
taisei_quit(); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
attr_used | ||
void userAppInit(void) { | ||
socketInitializeDefault(); | ||
appletLockExit(); | ||
appletHook(&g_hookCookie, onAppletHook, NULL); | ||
|
||
#ifdef DEBUG | ||
dup2(1, 2); | ||
NX_LOG("stderr -> stdout"); | ||
nxlinkStdio(); | ||
NX_LOG("nxlink enabled"); | ||
NX_SETENV("TAISEI_NOASYNC", "1"); | ||
#endif | ||
|
||
appletInitializeGamePlayRecording(); | ||
appletSetGamePlayRecordingState(1); | ||
|
||
getcwd(g_programDir, FS_MAX_PATH); | ||
|
||
#if defined(DEBUG) && defined(TAISEI_BUILDCONF_DEBUG_OPENGL) | ||
// enable Mesa logging: | ||
NX_SETENV("EGL_LOG_LEVEL", "debug"); | ||
NX_SETENV("MESA_VERBOSE", "all"); | ||
NX_SETENV("MESA_DEBUG", "1"); | ||
NX_SETENV("NOUVEAU_MESA_DEBUG", "1"); | ||
|
||
// enable shader debugging in Nouveau: | ||
NX_SETENV("NV50_PROG_OPTIMIZE", "0"); | ||
NX_SETENV("NV50_PROG_DEBUG", "1"); | ||
NX_SETENV("NV50_PROG_CHIPSET", "0x120"); | ||
#else | ||
// disable error checking and save CPU time | ||
NX_SETENV("MESA_NO_ERROR", "1"); | ||
#endif | ||
} | ||
|
||
attr_used | ||
void userAppExit(void) { | ||
if(g_nxAtExitFn != NULL) { | ||
NX_LOG("calling exit callback"); | ||
g_nxAtExitFn(); | ||
g_nxAtExitFn = NULL; | ||
} | ||
socketExit(); | ||
appletUnlockExit(); | ||
} | ||
|
||
int nxAtExit(nxAtExitFn fn) { | ||
if(g_nxAtExitFn == NULL) { | ||
NX_LOG("got exit callback"); | ||
g_nxAtExitFn = fn; | ||
return 0; | ||
} | ||
return -1; | ||
} | ||
|
||
void __attribute__((weak)) noreturn __libnx_exit(int rc); | ||
|
||
void noreturn nxExit(int rc) { | ||
__libnx_exit(rc); | ||
} | ||
|
||
void noreturn nxAbort(void) { | ||
/* Using abort would not give us correct offsets in crash reports, | ||
* nor code region name, so we use __builtin_trap instead */ | ||
__builtin_trap(); | ||
} | ||
|
||
const char* nxGetProgramDir(void) { | ||
return g_programDir; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* This software is licensed under the terms of the MIT-License | ||
* See COPYING for further information. | ||
* --- | ||
* Copyright (c) 2019, p-sam <p-sam@d3vs.net>. | ||
*/ | ||
|
||
#ifndef IGUARD_arch_switch_h | ||
#define IGUARD_arch_switch_h | ||
|
||
#include "taisei.h" | ||
|
||
typedef void (*nxAtExitFn)(void); | ||
|
||
void userAppInit(void); | ||
void userAppExit(void); | ||
int nxAtExit(nxAtExitFn fn); | ||
void noreturn nxExit(int rc); | ||
void noreturn nxAbort(void); | ||
const char* nxGetProgramDir(void); | ||
|
||
#endif // IGUARD_arch_switch_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.