From b965ce4ef4f77c35ff07d7c066a73ae9df09a251 Mon Sep 17 00:00:00 2001 From: XProger Date: Sat, 5 Jan 2019 05:38:59 +0300 Subject: [PATCH] #15 NX add 1080p docked mode support --- src/platform/nx/main.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/platform/nx/main.cpp b/src/platform/nx/main.cpp index 012ed71..147ffff 100644 --- a/src/platform/nx/main.cpp +++ b/src/platform/nx/main.cpp @@ -93,6 +93,7 @@ void sndFree() { EGLDisplay display; EGLSurface surface; EGLContext context; +NWindow *window; bool eglInit() { display = eglGetDisplay(EGL_DEFAULT_DISPLAY); @@ -125,7 +126,10 @@ bool eglInit() { if (eglChooseConfig(display, eglAttr, &config, 1, &configCount) == EGL_FALSE) return false; - surface = eglCreateWindowSurface(display, config, (char*)"", NULL); + window = nwindowGetDefault(); + nwindowSetDimensions(window, 1920, 1080); + + surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)window, NULL); if (surface == EGL_NO_SURFACE) return false; @@ -151,6 +155,19 @@ void eglFree() { eglReleaseThread(); } +void configureResolution() { + if (appletGetOperationMode() == AppletOperationMode_Docked) { + Core::width = 1920; + Core::height = 1080; + } else { + Core::width = 1280; + Core::height = 720; + } + + nwindowSetCrop(window, 0, 0, Core::width, Core::height); + Core::y = 1080 - Core::height; +} + // Input bool osJoyReady(int index) { return index == 0; @@ -176,7 +193,7 @@ void joySplit(bool split) { hidSetNpadJoyAssignmentModeDual(CONTROLLER_PLAYER_2); hidMergeSingleJoyAsDualJoy(CONTROLLER_PLAYER_1, CONTROLLER_PLAYER_2); - if (Game::level && Game::level.players[1]) { + if (Game::level && Game::level->players[1]) { Game::level->addPlayer(1); // add existing player == remove player } } @@ -291,6 +308,7 @@ int main(int argc, char* argv[]) { touchUpdate(); if (Game::update()) { + configureResolution(); Game::render(); Core::waitVBlank(); eglSwapBuffers(display, surface);