switch: use native screen resolution
This commit is contained in:
parent
668cdaea44
commit
fda783ed2c
4 changed files with 44 additions and 1 deletions
|
@ -26,6 +26,9 @@ static nxAtExitFn g_nxAtExitFn = NULL;
|
|||
static char g_programDir[FS_MAX_PATH] = {0};
|
||||
static AppletHookCookie g_hookCookie;
|
||||
|
||||
static s32 g_initialScreenWidth = 1920;
|
||||
static s32 g_initialScreenHeight = 1080;
|
||||
|
||||
static void onAppletHook(AppletHookType hook, void *param) {
|
||||
switch (hook) {
|
||||
case AppletHookType_OnExitRequest:
|
||||
|
@ -51,6 +54,7 @@ void userAppInit(void) {
|
|||
NX_LOG("nxlink enabled");
|
||||
#endif
|
||||
|
||||
appletGetDefaultDisplayResolution(&g_initialScreenWidth, &g_initialScreenHeight);
|
||||
appletInitializeGamePlayRecording();
|
||||
appletSetGamePlayRecordingState(1);
|
||||
|
||||
|
@ -112,3 +116,11 @@ void noreturn nxAbort(void) {
|
|||
const char* nxGetProgramDir(void) {
|
||||
return g_programDir;
|
||||
}
|
||||
|
||||
int nxGetInitialScreenWidth(void) {
|
||||
return g_initialScreenWidth;
|
||||
}
|
||||
|
||||
int nxGetInitialScreenHeight(void) {
|
||||
return g_initialScreenHeight;
|
||||
}
|
||||
|
|
|
@ -16,3 +16,6 @@ int nxAtExit(nxAtExitFn fn);
|
|||
void noreturn nxExit(int rc);
|
||||
void noreturn nxAbort(void);
|
||||
const char* nxGetProgramDir(void);
|
||||
|
||||
int nxGetInitialScreenWidth(void);
|
||||
int nxGetInitialScreenHeight(void);
|
||||
|
|
|
@ -499,6 +499,8 @@ void config_load(void) {
|
|||
#ifdef __SWITCH__
|
||||
config_set_int(CONFIG_GAMEPAD_ENABLED, true);
|
||||
config_set_str(CONFIG_GAMEPAD_DEVICE, "any");
|
||||
config_set_int(CONFIG_VID_WIDTH, nxGetInitialScreenWidth());
|
||||
config_set_int(CONFIG_VID_HEIGHT, nxGetInitialScreenHeight());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
28
src/video.c
28
src/video.c
|
@ -140,6 +140,26 @@ static VideoCapabilityState video_query_capability_alwaysfullscreen(VideoCapabil
|
|||
UNREACHABLE;
|
||||
}
|
||||
|
||||
static VideoCapabilityState video_query_capability_switch(VideoCapability cap) {
|
||||
switch(cap) {
|
||||
// We want the window to be resizable and resized internally by SDL
|
||||
// when the Switch gets docked/undocked
|
||||
case VIDEO_CAP_FULLSCREEN:
|
||||
return VIDEO_NEVER_AVAILABLE;
|
||||
|
||||
case VIDEO_CAP_EXTERNAL_RESIZE:
|
||||
return VIDEO_AVAILABLE;
|
||||
|
||||
case VIDEO_CAP_CHANGE_RESOLUTION:
|
||||
return VIDEO_NEVER_AVAILABLE;
|
||||
|
||||
case VIDEO_CAP_VSYNC_ADAPTIVE:
|
||||
return VIDEO_NEVER_AVAILABLE;
|
||||
}
|
||||
|
||||
UNREACHABLE;
|
||||
}
|
||||
|
||||
static VideoCapabilityState video_query_capability_webcanvas(VideoCapability cap) {
|
||||
switch(cap) {
|
||||
case VIDEO_CAP_EXTERNAL_RESIZE:
|
||||
|
@ -757,6 +777,12 @@ static bool video_handle_window_event(SDL_Event *event, void *arg) {
|
|||
// It's followed by SDL_WINDOWEVENT_RESIZED for external resizes (from the WM or the
|
||||
// user). We only need to handle external resizes.
|
||||
log_debug("SDL_WINDOWEVENT_SIZE_CHANGED: %ix%i", event->window.data1, event->window.data2);
|
||||
|
||||
// Catch resizes by the SDL portlib itself, when the console is docked/undocked
|
||||
// https://github.com/devkitPro/SDL/issues/31
|
||||
if(video_get_backend() == VIDEO_BACKEND_SWITCH) {
|
||||
video_handle_resize(event->window.data1, event->window.data2);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
|
@ -862,7 +888,7 @@ void video_init(void) {
|
|||
video_query_capability = video_query_capability_alwaysfullscreen;
|
||||
} else if(!strcmp(driver, "Switch")) {
|
||||
video.backend = VIDEO_BACKEND_SWITCH;
|
||||
video_query_capability = video_query_capability_alwaysfullscreen;
|
||||
video_query_capability = video_query_capability_switch;
|
||||
} else {
|
||||
video.backend = VIDEO_BACKEND_OTHER;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue