VERY experimental Nintendo Switch 2 emulator
C++
Add default hotkey to swap primary screens.
James Rowe72786d410e2b
diff --git a/src/citra/config.cpp b/src/citra/config.cppindex 305e3ba535..fd30bfc852 100644--- a/src/citra/config.cpp+++ b/src/citra/config.cpp@@ -73,7 +73,8 @@ void Config::ReadValues() {Settings::values.bg_blue = (float)sdl2_config->GetReal("Renderer", "bg_blue", 1.0);// Layout- Settings::values.layout_option = static_cast<Settings::LayoutOption>(sdl2_config->GetInteger("Layout", "layout_option", 0));+ Settings::values.layout_option =+ static_cast<Settings::LayoutOption>(sdl2_config->GetInteger("Layout", "layout_option", 0));Settings::values.swap_screen = sdl2_config->GetBoolean("Layout", "swap_screen", false);// Audiodiff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cppindex f4f1a354d3..3d23126196 100644--- a/src/citra_qt/config.cpp+++ b/src/citra_qt/config.cpp@@ -55,7 +55,8 @@ void Config::ReadValues() {qt_config->endGroup();qt_config->beginGroup("Layout");- Settings::values.layout_option = static_cast<Settings::LayoutOption>(qt_config->value("layout_option").toInt());+ Settings::values.layout_option =+ static_cast<Settings::LayoutOption>(qt_config->value("layout_option").toInt());Settings::values.swap_screen = qt_config->value("swap_screen", false).toBool();qt_config->endGroup();diff --git a/src/citra_qt/configure_graphics.cpp b/src/citra_qt/configure_graphics.cppindex c6c28197ec..29834e11ba 100644--- a/src/citra_qt/configure_graphics.cpp+++ b/src/citra_qt/configure_graphics.cpp@@ -32,7 +32,8 @@ void ConfigureGraphics::applyConfiguration() {Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked();Settings::values.use_scaled_resolution = ui->toggle_scaled_resolution->isChecked();Settings::values.use_vsync = ui->toggle_vsync->isChecked();- Settings::values.layout_option = static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex());+ Settings::values.layout_option =+ static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex());Settings::values.swap_screen = ui->swap_screen->isChecked();Settings::Apply();}diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cppindex 8322e23052..c1589424e3 100644--- a/src/citra_qt/main.cpp+++ b/src/citra_qt/main.cpp@@ -196,6 +196,7 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {// Setup hotkeysRegisterHotkey("Main Window", "Load File", QKeySequence::Open);+ RegisterHotkey("Main Window", "Swap Screens", QKeySequence::NextChild);RegisterHotkey("Main Window", "Start Emulation");LoadHotkeys();@@ -203,6 +204,8 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {SLOT(OnMenuLoadFile()));connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this,SLOT(OnStartGame()));+ connect(GetHotkey("Main Window", "Swap Screens", this), SIGNAL(activated()), this,+ SLOT(OnSwapScreens()));std::string window_title =Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);@@ -550,6 +553,11 @@ void GMainWindow::OnConfigure() {}}+void GMainWindow::OnSwapScreens() {+ Settings::values.swap_screen = !Settings::values.swap_screen;+ Settings::Apply();+}+void GMainWindow::OnCreateGraphicsSurfaceViewer() {auto graphicsSurfaceViewerWidget = new GraphicsSurfaceWidget(Pica::g_debug_context, this);addDockWidget(Qt::RightDockWidgetArea, graphicsSurfaceViewerWidget);diff --git a/src/citra_qt/main.h b/src/citra_qt/main.hindex 2cf308d80f..82eb90aae7 100644--- a/src/citra_qt/main.h+++ b/src/citra_qt/main.h@@ -105,6 +105,7 @@ private slots:/// Called whenever a user selects the "File->Select Game List Root" menu itemvoid OnMenuSelectGameListRoot();void OnMenuRecentFile();+ void OnSwapScreens();void OnConfigure();void OnDisplayTitleBars(bool);void ToggleWindowMode();diff --git a/src/common/emu_window.h b/src/common/emu_window.hindex 6fac572f55..835c4d5003 100644--- a/src/common/emu_window.h+++ b/src/common/emu_window.h@@ -200,7 +200,7 @@ public:}/**- * Convenience method to update the VideoCore EmuWindow+ * Convenience method to update the current frame layout* Read from the current settings to determine which layout to use.*/void UpdateCurrentFramebufferLayout(unsigned width, unsigned height);diff --git a/src/common/framebuffer_layout.cpp b/src/common/framebuffer_layout.cppindex d50c141bb0..e8538dcfd5 100644--- a/src/common/framebuffer_layout.cpp+++ b/src/common/framebuffer_layout.cpp@@ -51,11 +51,15 @@ FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool swappbot_screen.TranslateX((screen_window_area.GetWidth() - bot_screen.GetWidth()) / 2);} else {// Window is narrower than the emulation content => apply borders to the top and bottom- top_screen = top_screen.TranslateY(height / 2 - top_screen.GetHeight());// Recalculate the bottom screen to account for the width difference between top and bottomscreen_window_area = {0, 0, width, top_screen.GetHeight()};bot_screen = maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);bot_screen = bot_screen.TranslateX((top_screen.GetWidth() - bot_screen.GetWidth()) / 2);+ if (swapped) {+ bot_screen = bot_screen.TranslateY(height / 2 - bot_screen.GetHeight());+ } else {+ top_screen = top_screen.TranslateY(height / 2 - top_screen.GetHeight());+ }}// Move the top screen to the bottom if we are swapped.res.top_screen = swapped ? top_screen.TranslateY(height / 2) : top_screen;diff --git a/src/common/framebuffer_layout.h b/src/common/framebuffer_layout.hindex c69a80732d..7f88c94630 100644--- a/src/common/framebuffer_layout.h+++ b/src/common/framebuffer_layout.h@@ -33,7 +33,8 @@ FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool is_swFramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swapped);/**- * Factory method for constructing a Frame with the a 4x size Top screen with a 1x size bottom screen on the right+ * Factory method for constructing a Frame with the a 4x size Top screen with a 1x size bottom+ * screen on the right* This is useful in particular because it matches well with a 1920x1080 resolution monitor* @param width Window framebuffer width in pixels* @param height Window framebuffer height in pixelsdiff --git a/src/common/math_util.h b/src/common/math_util.hindex 570ec8e56e..9e630d93df 100644--- a/src/common/math_util.h+++ b/src/common/math_util.h@@ -45,10 +45,8 @@ struct Rectangle {return Rectangle{left, top + y, right, bottom + y};}Rectangle<T> Scale(const float s) const {- ASSERT(s > 0);- return Rectangle {- left, top, static_cast<T>((right + left) * s), static_cast<T>((top + bottom) * s)- };+ return Rectangle{left, top, static_cast<T>((right + left) * s),+ static_cast<T>((top + bottom) * s)};}};diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cppindex fd0d74ace7..93f0ac1052 100644--- a/src/video_core/renderer_opengl/renderer_opengl.cpp+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp@@ -406,9 +406,8 @@ void RendererOpenGL::DrawScreens() {glUniform1i(uniform_color_texture, 0);if (layout.top_screen_enabled) {- DrawSingleScreenRotated(screen_infos[0], (float)top_screen.left,- (float)top_screen.top, (float)top_screen.GetWidth(),- (float)top_screen.GetHeight());+ DrawSingleScreenRotated(screen_infos[0], (float)top_screen.left, (float)top_screen.top,+ (float)top_screen.GetWidth(), (float)top_screen.GetHeight());}if (layout.bottom_screen_enabled) {DrawSingleScreenRotated(screen_infos[1], (float)bottom_screen.left,