mirror of
https://github.com/citra-emu/citra-canary.git
synced 2024-12-23 08:15:38 +00:00
Add "Separate Windows" LayoutOption (#6177)
This commit is contained in:
parent
4f715b6718
commit
f44c95d638
|
@ -35,6 +35,7 @@
|
|||
#include "core/loader/loader.h"
|
||||
#include "core/movie.h"
|
||||
#include "core/settings.h"
|
||||
#include "input_common/main.h"
|
||||
#include "network/network.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
|
||||
|
@ -359,11 +360,23 @@ int main(int argc, char** argv) {
|
|||
// Register generic image interface
|
||||
Core::System::GetInstance().RegisterImageInterface(std::make_shared<LodePNGImageInterface>());
|
||||
|
||||
std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>(fullscreen)};
|
||||
Frontend::ScopeAcquireContext scope(*emu_window);
|
||||
Core::System& system = Core::System::GetInstance();
|
||||
EmuWindow_SDL2::InitializeSDL2();
|
||||
|
||||
const Core::System::ResultStatus load_result{system.Load(*emu_window, filepath)};
|
||||
const auto emu_window{std::make_unique<EmuWindow_SDL2>(fullscreen, false)};
|
||||
const bool use_secondary_window{Settings::values.layout_option ==
|
||||
Settings::LayoutOption::SeparateWindows};
|
||||
const auto secondary_window =
|
||||
use_secondary_window ? std::make_unique<EmuWindow_SDL2>(false, true) : nullptr;
|
||||
|
||||
Frontend::ScopeAcquireContext scope(*emu_window);
|
||||
|
||||
LOG_INFO(Frontend, "Citra Version: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch,
|
||||
Common::g_scm_desc);
|
||||
Settings::LogSettings();
|
||||
|
||||
Core::System& system = Core::System::GetInstance();
|
||||
const Core::System::ResultStatus load_result{
|
||||
system.Load(*emu_window, filepath, secondary_window.get())};
|
||||
|
||||
switch (load_result) {
|
||||
case Core::System::ResultStatus::ErrorGetLoader:
|
||||
|
@ -431,7 +444,12 @@ int main(int argc, char** argv) {
|
|||
system.VideoDumper().StartDumping(dump_video, layout);
|
||||
}
|
||||
|
||||
std::thread render_thread([&emu_window] { emu_window->Present(); });
|
||||
std::thread main_render_thread([&emu_window] { emu_window->Present(); });
|
||||
std::thread secondary_render_thread([&secondary_window] {
|
||||
if (secondary_window) {
|
||||
secondary_window->Present();
|
||||
}
|
||||
});
|
||||
|
||||
std::atomic_bool stop_run;
|
||||
system.Renderer().Rasterizer()->LoadDiskResources(
|
||||
|
@ -440,7 +458,11 @@ int main(int argc, char** argv) {
|
|||
total);
|
||||
});
|
||||
|
||||
while (emu_window->IsOpen()) {
|
||||
const auto secondary_is_open = [&secondary_window] {
|
||||
// if the secondary window isn't created, it shouldn't affect the main loop
|
||||
return secondary_window ? secondary_window->IsOpen() : true;
|
||||
};
|
||||
while (emu_window->IsOpen() && secondary_is_open()) {
|
||||
const auto result = system.RunLoop();
|
||||
|
||||
switch (result) {
|
||||
|
@ -454,13 +476,21 @@ int main(int argc, char** argv) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
render_thread.join();
|
||||
emu_window->RequestClose();
|
||||
if (secondary_window) {
|
||||
secondary_window->RequestClose();
|
||||
}
|
||||
main_render_thread.join();
|
||||
secondary_render_thread.join();
|
||||
|
||||
Core::Movie::GetInstance().Shutdown();
|
||||
if (system.VideoDumper().IsDumping()) {
|
||||
system.VideoDumper().StopDumping();
|
||||
}
|
||||
|
||||
Network::Shutdown();
|
||||
InputCommon::Shutdown();
|
||||
|
||||
system.Shutdown();
|
||||
|
||||
detached_tasks.WaitForAllTasks();
|
||||
|
|
|
@ -182,7 +182,11 @@ filter_mode =
|
|||
|
||||
[Layout]
|
||||
# Layout for the screen inside the render window.
|
||||
# 0 (default): Default Top Bottom Screen, 1: Single Screen Only, 2: Large Screen Small Screen, 3: Side by Side
|
||||
# 0 (default): Default Top Bottom Screen
|
||||
# 1: Single Screen Only
|
||||
# 2: Large Screen Small Screen
|
||||
# 3: Side by Side
|
||||
# 4: Separate Windows
|
||||
layout_option =
|
||||
|
||||
# Toggle custom layout (using the settings below) on or off.
|
||||
|
|
|
@ -135,18 +135,8 @@ void EmuWindow_SDL2::Fullscreen() {
|
|||
SDL_MaximizeWindow(render_window);
|
||||
}
|
||||
|
||||
EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
|
||||
EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen, bool is_secondary) : EmuWindow(is_secondary) {
|
||||
// Initialize the window
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0) {
|
||||
LOG_CRITICAL(Frontend, "Failed to initialize SDL2: {}! Exiting...", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
InputCommon::Init();
|
||||
Network::Init();
|
||||
|
||||
SDL_SetMainReady();
|
||||
|
||||
if (Settings::values.use_gles) {
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
|
@ -201,6 +191,7 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
render_window_id = SDL_GetWindowID(render_window);
|
||||
auto gl_load_func = Settings::values.use_gles ? gladLoadGLES2Loader : gladLoadGLLoader;
|
||||
|
||||
if (!gl_load_func(static_cast<GLADloadproc>(SDL_GL_GetProcAddress))) {
|
||||
|
@ -211,19 +202,26 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
|
|||
OnResize();
|
||||
OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
|
||||
SDL_PumpEvents();
|
||||
LOG_INFO(Frontend, "Citra Version: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch,
|
||||
Common::g_scm_desc);
|
||||
Settings::LogSettings();
|
||||
}
|
||||
|
||||
EmuWindow_SDL2::~EmuWindow_SDL2() {
|
||||
core_context.reset();
|
||||
Network::Shutdown();
|
||||
InputCommon::Shutdown();
|
||||
SDL_GL_DeleteContext(window_context);
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
void EmuWindow_SDL2::InitializeSDL2() {
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0) {
|
||||
LOG_CRITICAL(Frontend, "Failed to initialize SDL2: {}! Exiting...", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
InputCommon::Init();
|
||||
Network::Init();
|
||||
|
||||
SDL_SetMainReady();
|
||||
}
|
||||
|
||||
std::unique_ptr<Frontend::GraphicsContext> EmuWindow_SDL2::CreateSharedContext() const {
|
||||
return std::make_unique<SharedContext_SDL2>();
|
||||
}
|
||||
|
@ -240,7 +238,7 @@ void EmuWindow_SDL2::Present() {
|
|||
SDL_GL_MakeCurrent(render_window, window_context);
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
while (IsOpen()) {
|
||||
VideoCore::g_renderer->TryPresent(100);
|
||||
VideoCore::g_renderer->TryPresent(100, is_secondary);
|
||||
SDL_GL_SwapWindow(render_window);
|
||||
}
|
||||
SDL_GL_MakeCurrent(render_window, nullptr);
|
||||
|
@ -248,9 +246,14 @@ void EmuWindow_SDL2::Present() {
|
|||
|
||||
void EmuWindow_SDL2::PollEvents() {
|
||||
SDL_Event event;
|
||||
std::vector<SDL_Event> other_window_events;
|
||||
|
||||
// SDL_PollEvent returns 0 when there are no more events in the event queue
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.window.windowID != render_window_id) {
|
||||
other_window_events.push_back(event);
|
||||
continue;
|
||||
}
|
||||
switch (event.type) {
|
||||
case SDL_WINDOWEVENT:
|
||||
switch (event.window.event) {
|
||||
|
@ -299,16 +302,13 @@ void EmuWindow_SDL2::PollEvents() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const u32 current_time = SDL_GetTicks();
|
||||
if (current_time > last_time + 2000) {
|
||||
const auto results = Core::System::GetInstance().GetAndResetPerfStats();
|
||||
const auto title =
|
||||
fmt::format("Citra {} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname,
|
||||
Common::g_scm_branch, Common::g_scm_desc, results.game_fps,
|
||||
results.emulation_speed * 100.0f);
|
||||
SDL_SetWindowTitle(render_window, title.c_str());
|
||||
last_time = current_time;
|
||||
for (auto& e : other_window_events) {
|
||||
// This is a somewhat hacky workaround to re-emit window events meant for another window
|
||||
// since SDL_PollEvent() is global but we poll events per window.
|
||||
SDL_PushEvent(&e);
|
||||
}
|
||||
if (!is_secondary) {
|
||||
UpdateFramerateCounter();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,3 +323,16 @@ void EmuWindow_SDL2::DoneCurrent() {
|
|||
void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) {
|
||||
SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second);
|
||||
}
|
||||
|
||||
void EmuWindow_SDL2::UpdateFramerateCounter() {
|
||||
const u32 current_time = SDL_GetTicks();
|
||||
if (current_time > last_time + 2000) {
|
||||
const auto results = Core::System::GetInstance().GetAndResetPerfStats();
|
||||
const auto title =
|
||||
fmt::format("Citra {} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname,
|
||||
Common::g_scm_branch, Common::g_scm_desc, results.game_fps,
|
||||
results.emulation_speed * 100.0f);
|
||||
SDL_SetWindowTitle(render_window, title.c_str());
|
||||
last_time = current_time;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,11 @@ private:
|
|||
|
||||
class EmuWindow_SDL2 : public Frontend::EmuWindow {
|
||||
public:
|
||||
explicit EmuWindow_SDL2(bool fullscreen);
|
||||
explicit EmuWindow_SDL2(bool fullscreen, bool is_secondary);
|
||||
~EmuWindow_SDL2();
|
||||
|
||||
static void InitializeSDL2();
|
||||
|
||||
void Present();
|
||||
|
||||
/// Polls window events
|
||||
|
@ -88,12 +90,18 @@ private:
|
|||
/// Called when a configuration change affects the minimal size of the window
|
||||
void OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) override;
|
||||
|
||||
/// Called when polling to update framerate
|
||||
void UpdateFramerateCounter();
|
||||
|
||||
/// Is the window still open?
|
||||
bool is_open = true;
|
||||
|
||||
/// Internal SDL2 render window
|
||||
SDL_Window* render_window;
|
||||
|
||||
/// Internal SDL2 window ID
|
||||
int render_window_id{};
|
||||
|
||||
/// Fake hidden window for the core context
|
||||
SDL_Window* dummy_window;
|
||||
|
||||
|
|
|
@ -113,9 +113,10 @@ void EmuThread::run() {
|
|||
#endif
|
||||
}
|
||||
|
||||
OpenGLWindow::OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context)
|
||||
OpenGLWindow::OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context,
|
||||
bool is_secondary)
|
||||
: QWindow(parent), context(std::make_unique<QOpenGLContext>(shared_context->parent())),
|
||||
event_handler(event_handler) {
|
||||
event_handler(event_handler), is_secondary{is_secondary} {
|
||||
|
||||
// disable vsync for any shared contexts
|
||||
auto format = shared_context->format();
|
||||
|
@ -143,7 +144,7 @@ void OpenGLWindow::Present() {
|
|||
|
||||
context->makeCurrent(this);
|
||||
if (VideoCore::g_renderer) {
|
||||
VideoCore::g_renderer->TryPresent(100);
|
||||
VideoCore::g_renderer->TryPresent(100, is_secondary);
|
||||
}
|
||||
context->swapBuffers(this);
|
||||
auto f = context->versionFunctions<QOpenGLFunctions_4_3_Core>();
|
||||
|
@ -196,8 +197,8 @@ void OpenGLWindow::exposeEvent(QExposeEvent* event) {
|
|||
QWindow::exposeEvent(event);
|
||||
}
|
||||
|
||||
GRenderWindow::GRenderWindow(QWidget* parent_, EmuThread* emu_thread)
|
||||
: QWidget(parent_), emu_thread(emu_thread) {
|
||||
GRenderWindow::GRenderWindow(QWidget* parent_, EmuThread* emu_thread, bool is_secondary_)
|
||||
: QWidget(parent_), EmuWindow(is_secondary_), emu_thread(emu_thread) {
|
||||
|
||||
setWindowTitle(QStringLiteral("Citra %1 | %2-%3")
|
||||
.arg(QString::fromUtf8(Common::g_build_name),
|
||||
|
@ -207,7 +208,6 @@ GRenderWindow::GRenderWindow(QWidget* parent_, EmuThread* emu_thread)
|
|||
auto layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(layout);
|
||||
InputCommon::Init();
|
||||
|
||||
this->setMouseTracking(true);
|
||||
|
||||
|
@ -215,9 +215,7 @@ GRenderWindow::GRenderWindow(QWidget* parent_, EmuThread* emu_thread)
|
|||
connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete);
|
||||
}
|
||||
|
||||
GRenderWindow::~GRenderWindow() {
|
||||
InputCommon::Shutdown();
|
||||
}
|
||||
GRenderWindow::~GRenderWindow() = default;
|
||||
|
||||
void GRenderWindow::MakeCurrent() {
|
||||
core_context->MakeCurrent();
|
||||
|
@ -382,6 +380,12 @@ bool GRenderWindow::event(QEvent* event) {
|
|||
void GRenderWindow::focusOutEvent(QFocusEvent* event) {
|
||||
QWidget::focusOutEvent(event);
|
||||
InputCommon::GetKeyboard()->ReleaseAllKeys();
|
||||
has_focus = false;
|
||||
}
|
||||
|
||||
void GRenderWindow::focusInEvent(QFocusEvent* event) {
|
||||
QWidget::focusInEvent(event);
|
||||
has_focus = true;
|
||||
}
|
||||
|
||||
void GRenderWindow::resizeEvent(QResizeEvent* event) {
|
||||
|
@ -396,7 +400,8 @@ void GRenderWindow::InitRenderTarget() {
|
|||
|
||||
GMainWindow* parent = GetMainWindow();
|
||||
QWindow* parent_win_handle = parent ? parent->windowHandle() : nullptr;
|
||||
child_window = new OpenGLWindow(parent_win_handle, this, QOpenGLContext::globalShareContext());
|
||||
child_window = new OpenGLWindow(parent_win_handle, this, QOpenGLContext::globalShareContext(),
|
||||
is_secondary);
|
||||
child_window->create();
|
||||
child_widget = createWindowContainer(child_window, this);
|
||||
child_widget->resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight);
|
||||
|
@ -421,7 +426,7 @@ void GRenderWindow::ReleaseRenderTarget() {
|
|||
void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_path) {
|
||||
if (res_scale == 0)
|
||||
res_scale = VideoCore::GetResolutionScaleFactor();
|
||||
const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)};
|
||||
const auto layout{Layout::FrameLayoutFromResolutionScale(res_scale, is_secondary)};
|
||||
screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32);
|
||||
VideoCore::RequestScreenshot(
|
||||
screenshot_image.bits(),
|
||||
|
|
|
@ -129,7 +129,8 @@ signals:
|
|||
class OpenGLWindow : public QWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context);
|
||||
explicit OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context,
|
||||
bool is_secondary = false);
|
||||
|
||||
~OpenGLWindow();
|
||||
|
||||
|
@ -142,13 +143,14 @@ protected:
|
|||
private:
|
||||
std::unique_ptr<QOpenGLContext> context;
|
||||
QWidget* event_handler;
|
||||
bool is_secondary;
|
||||
};
|
||||
|
||||
class GRenderWindow : public QWidget, public Frontend::EmuWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GRenderWindow(QWidget* parent, EmuThread* emu_thread);
|
||||
GRenderWindow(QWidget* parent, EmuThread* emu_thread, bool is_secondary);
|
||||
~GRenderWindow() override;
|
||||
|
||||
// EmuWindow implementation.
|
||||
|
@ -178,6 +180,10 @@ public:
|
|||
bool event(QEvent* event) override;
|
||||
|
||||
void focusOutEvent(QFocusEvent* event) override;
|
||||
void focusInEvent(QFocusEvent* event) override;
|
||||
bool HasFocus() const {
|
||||
return has_focus;
|
||||
}
|
||||
|
||||
void InitRenderTarget();
|
||||
|
||||
|
@ -229,6 +235,7 @@ private:
|
|||
/// Temporary storage of the screenshot taken
|
||||
QImage screenshot_image;
|
||||
bool first_frame = false;
|
||||
bool has_focus = false;
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
|
|
@ -261,6 +261,11 @@
|
|||
<string>Side by Side</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Separate Windows</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
#include "core/savestate.h"
|
||||
#include "core/settings.h"
|
||||
#include "game_list_p.h"
|
||||
#include "input_common/main.h"
|
||||
#include "network/network_settings.h"
|
||||
#include "ui_main.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
|
@ -256,8 +257,11 @@ void GMainWindow::InitializeWidgets() {
|
|||
#ifdef CITRA_ENABLE_COMPATIBILITY_REPORTING
|
||||
ui->action_Report_Compatibility->setVisible(true);
|
||||
#endif
|
||||
render_window = new GRenderWindow(this, emu_thread.get());
|
||||
render_window = new GRenderWindow(this, emu_thread.get(), false);
|
||||
secondary_window = new GRenderWindow(this, emu_thread.get(), true);
|
||||
render_window->hide();
|
||||
secondary_window->hide();
|
||||
secondary_window->setParent(nullptr);
|
||||
|
||||
game_list = new GameList(this);
|
||||
ui->horizontalLayout->addWidget(game_list);
|
||||
|
@ -277,6 +281,7 @@ void GMainWindow::InitializeWidgets() {
|
|||
}
|
||||
});
|
||||
|
||||
InputCommon::Init();
|
||||
multiplayer_state = new MultiplayerState(this, game_list->GetModel(), ui->action_Leave_Room,
|
||||
ui->action_Show_Room);
|
||||
multiplayer_state->setVisible(false);
|
||||
|
@ -327,6 +332,7 @@ void GMainWindow::InitializeWidgets() {
|
|||
actionGroup_ScreenLayouts->addAction(ui->action_Screen_Layout_Single_Screen);
|
||||
actionGroup_ScreenLayouts->addAction(ui->action_Screen_Layout_Large_Screen);
|
||||
actionGroup_ScreenLayouts->addAction(ui->action_Screen_Layout_Side_by_Side);
|
||||
actionGroup_ScreenLayouts->addAction(ui->action_Screen_Layout_Separate_Windows);
|
||||
}
|
||||
|
||||
void GMainWindow::InitializeDebugWidgets() {
|
||||
|
@ -516,6 +522,17 @@ void GMainWindow::InitializeHotkeys() {
|
|||
&QShortcut::activated, ui->action_Fullscreen, &QAction::trigger);
|
||||
connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window),
|
||||
&QShortcut::activatedAmbiguously, ui->action_Fullscreen, &QAction::trigger);
|
||||
|
||||
// This action will fire specifically when secondary_window is in focus
|
||||
QAction* secondary_fullscreen_action = new QAction(secondary_window);
|
||||
// Use the same fullscreen hotkey as the main window
|
||||
const auto fullscreen_hotkey = hotkey_registry.GetKeySequence(main_window, fullscreen);
|
||||
secondary_fullscreen_action->setShortcut(fullscreen_hotkey);
|
||||
|
||||
connect(secondary_fullscreen_action, SIGNAL(triggered()), this,
|
||||
SLOT(ToggleSecondaryFullscreen()));
|
||||
secondary_window->addAction(secondary_fullscreen_action);
|
||||
|
||||
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Exit Fullscreen"), this),
|
||||
&QShortcut::activated, this, [&] {
|
||||
if (emulation_running) {
|
||||
|
@ -690,6 +707,10 @@ void GMainWindow::ConnectWidgetEvents() {
|
|||
&GRenderWindow::OnEmulationStarting);
|
||||
connect(this, &GMainWindow::EmulationStopping, render_window,
|
||||
&GRenderWindow::OnEmulationStopping);
|
||||
connect(this, &GMainWindow::EmulationStarting, secondary_window,
|
||||
&GRenderWindow::OnEmulationStarting);
|
||||
connect(this, &GMainWindow::EmulationStopping, secondary_window,
|
||||
&GRenderWindow::OnEmulationStopping);
|
||||
|
||||
connect(&status_bar_update_timer, &QTimer::timeout, this, &GMainWindow::UpdateStatusBar);
|
||||
|
||||
|
@ -763,6 +784,8 @@ void GMainWindow::ConnectMenuEvents() {
|
|||
&GMainWindow::ChangeScreenLayout);
|
||||
connect(ui->action_Screen_Layout_Side_by_Side, &QAction::triggered, this,
|
||||
&GMainWindow::ChangeScreenLayout);
|
||||
connect(ui->action_Screen_Layout_Separate_Windows, &QAction::triggered, this,
|
||||
&GMainWindow::ChangeScreenLayout);
|
||||
connect(ui->action_Screen_Layout_Swap_Screens, &QAction::triggered, this,
|
||||
&GMainWindow::OnSwapScreens);
|
||||
connect(ui->action_Screen_Layout_Upright_Screens, &QAction::triggered, this,
|
||||
|
@ -922,6 +945,7 @@ bool GMainWindow::LoadROM(const QString& filename) {
|
|||
ShutdownGame();
|
||||
|
||||
render_window->InitRenderTarget();
|
||||
secondary_window->InitRenderTarget();
|
||||
|
||||
Frontend::ScopeAcquireContext scope(*render_window);
|
||||
|
||||
|
@ -936,7 +960,8 @@ bool GMainWindow::LoadROM(const QString& filename) {
|
|||
|
||||
Core::System& system{Core::System::GetInstance()};
|
||||
|
||||
const Core::System::ResultStatus result{system.Load(*render_window, filename.toStdString())};
|
||||
const Core::System::ResultStatus result{
|
||||
system.Load(*render_window, filename.toStdString(), secondary_window)};
|
||||
|
||||
if (result != Core::System::ResultStatus::Success) {
|
||||
switch (result) {
|
||||
|
@ -1098,6 +1123,8 @@ void GMainWindow::BootGame(const QString& filename) {
|
|||
|
||||
connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
|
||||
connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity);
|
||||
connect(secondary_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
|
||||
connect(secondary_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity);
|
||||
|
||||
// BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views
|
||||
// before the CPU continues
|
||||
|
@ -1189,6 +1216,7 @@ void GMainWindow::ShutdownGame() {
|
|||
|
||||
// The emulation is stopped, so closing the window or not does not matter anymore
|
||||
disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
|
||||
disconnect(secondary_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
|
||||
|
||||
// Update the GUI
|
||||
ui->action_Start->setEnabled(false);
|
||||
|
@ -1203,6 +1231,7 @@ void GMainWindow::ShutdownGame() {
|
|||
ui->action_Advance_Frame->setEnabled(false);
|
||||
ui->action_Capture_Screenshot->setEnabled(false);
|
||||
render_window->hide();
|
||||
secondary_window->hide();
|
||||
loading_screen->hide();
|
||||
loading_screen->Clear();
|
||||
if (game_list->IsEmpty())
|
||||
|
@ -1236,6 +1265,7 @@ void GMainWindow::ShutdownGame() {
|
|||
|
||||
// When closing the game, destroy the GLWindow to clear the context after the game is closed
|
||||
render_window->ReleaseRenderTarget();
|
||||
secondary_window->ReleaseRenderTarget();
|
||||
}
|
||||
|
||||
void GMainWindow::StoreRecentFile(const QString& filename) {
|
||||
|
@ -1636,6 +1666,7 @@ void GMainWindow::OnStopGame() {
|
|||
|
||||
void GMainWindow::OnLoadComplete() {
|
||||
loading_screen->OnLoadComplete();
|
||||
UpdateSecondaryWindowVisibility();
|
||||
}
|
||||
|
||||
void GMainWindow::OnMenuReportCompatibility() {
|
||||
|
@ -1660,6 +1691,17 @@ void GMainWindow::ToggleFullscreen() {
|
|||
}
|
||||
}
|
||||
|
||||
void GMainWindow::ToggleSecondaryFullscreen() {
|
||||
if (!emulation_running) {
|
||||
return;
|
||||
}
|
||||
if (secondary_window->isFullScreen()) {
|
||||
secondary_window->showNormal();
|
||||
} else {
|
||||
secondary_window->showFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void GMainWindow::ShowFullscreen() {
|
||||
if (ui->action_Single_Window_Mode->isChecked()) {
|
||||
UISettings::values.geometry = saveGeometry();
|
||||
|
@ -1709,6 +1751,19 @@ void GMainWindow::ToggleWindowMode() {
|
|||
}
|
||||
}
|
||||
|
||||
void GMainWindow::UpdateSecondaryWindowVisibility() {
|
||||
if (!emulation_running) {
|
||||
return;
|
||||
}
|
||||
if (Settings::values.layout_option == Settings::LayoutOption::SeparateWindows) {
|
||||
secondary_window->RestoreGeometry();
|
||||
secondary_window->show();
|
||||
} else {
|
||||
secondary_window->BackupGeometry();
|
||||
secondary_window->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void GMainWindow::ChangeScreenLayout() {
|
||||
Settings::LayoutOption new_layout = Settings::LayoutOption::Default;
|
||||
|
||||
|
@ -1720,35 +1775,38 @@ void GMainWindow::ChangeScreenLayout() {
|
|||
new_layout = Settings::LayoutOption::LargeScreen;
|
||||
} else if (ui->action_Screen_Layout_Side_by_Side->isChecked()) {
|
||||
new_layout = Settings::LayoutOption::SideScreen;
|
||||
} else if (ui->action_Screen_Layout_Separate_Windows->isChecked()) {
|
||||
new_layout = Settings::LayoutOption::SeparateWindows;
|
||||
}
|
||||
|
||||
Settings::values.layout_option = new_layout;
|
||||
Settings::Apply();
|
||||
UpdateSecondaryWindowVisibility();
|
||||
}
|
||||
|
||||
void GMainWindow::ToggleScreenLayout() {
|
||||
Settings::LayoutOption new_layout = Settings::LayoutOption::Default;
|
||||
|
||||
const Settings::LayoutOption new_layout = []() {
|
||||
switch (Settings::values.layout_option) {
|
||||
case Settings::LayoutOption::Default:
|
||||
new_layout = Settings::LayoutOption::SingleScreen;
|
||||
break;
|
||||
return Settings::LayoutOption::SingleScreen;
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
new_layout = Settings::LayoutOption::LargeScreen;
|
||||
break;
|
||||
return Settings::LayoutOption::LargeScreen;
|
||||
case Settings::LayoutOption::LargeScreen:
|
||||
new_layout = Settings::LayoutOption::SideScreen;
|
||||
break;
|
||||
return Settings::LayoutOption::SideScreen;
|
||||
case Settings::LayoutOption::SideScreen:
|
||||
new_layout = Settings::LayoutOption::Default;
|
||||
break;
|
||||
return Settings::LayoutOption::SeparateWindows;
|
||||
case Settings::LayoutOption::SeparateWindows:
|
||||
return Settings::LayoutOption::Default;
|
||||
default:
|
||||
LOG_ERROR(Frontend, "Unknown layout option {}", Settings::values.layout_option);
|
||||
return Settings::LayoutOption::Default;
|
||||
}
|
||||
}();
|
||||
|
||||
Settings::values.layout_option = new_layout;
|
||||
SyncMenuUISettings();
|
||||
Settings::Apply();
|
||||
UpdateSecondaryWindowVisibility();
|
||||
}
|
||||
|
||||
void GMainWindow::OnSwapScreens() {
|
||||
|
@ -1813,6 +1871,7 @@ void GMainWindow::OnConfigure() {
|
|||
} else {
|
||||
setMouseTracking(false);
|
||||
}
|
||||
UpdateSecondaryWindowVisibility();
|
||||
} else {
|
||||
Settings::values.input_profiles = old_input_profiles;
|
||||
Settings::values.touch_from_button_maps = old_touch_from_button_maps;
|
||||
|
@ -1991,7 +2050,9 @@ void GMainWindow::OnCaptureScreenshot() {
|
|||
const QString timestamp =
|
||||
QDateTime::currentDateTime().toString(QStringLiteral("dd.MM.yy_hh.mm.ss.z"));
|
||||
path.append(QStringLiteral("/%1_%2.png").arg(filename, timestamp));
|
||||
render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor, path);
|
||||
|
||||
auto* const screenshot_window = secondary_window->HasFocus() ? secondary_window : render_window;
|
||||
screenshot_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor, path);
|
||||
OnStartGame();
|
||||
}
|
||||
|
||||
|
@ -2227,7 +2288,9 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
|
|||
ShutdownGame();
|
||||
|
||||
render_window->close();
|
||||
secondary_window->close();
|
||||
multiplayer_state->Close();
|
||||
InputCommon::Shutdown();
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
|
@ -2412,6 +2475,8 @@ void GMainWindow::SyncMenuUISettings() {
|
|||
Settings::LayoutOption::LargeScreen);
|
||||
ui->action_Screen_Layout_Side_by_Side->setChecked(Settings::values.layout_option ==
|
||||
Settings::LayoutOption::SideScreen);
|
||||
ui->action_Screen_Layout_Separate_Windows->setChecked(Settings::values.layout_option ==
|
||||
Settings::LayoutOption::SeparateWindows);
|
||||
ui->action_Screen_Layout_Swap_Screens->setChecked(Settings::values.swap_screen);
|
||||
ui->action_Screen_Layout_Upright_Screens->setChecked(Settings::values.upright_screen);
|
||||
}
|
||||
|
|
|
@ -197,7 +197,9 @@ private slots:
|
|||
void OnDisplayTitleBars(bool);
|
||||
void InitializeHotkeys();
|
||||
void ToggleFullscreen();
|
||||
void ToggleSecondaryFullscreen();
|
||||
void ChangeScreenLayout();
|
||||
void UpdateSecondaryWindowVisibility();
|
||||
void ToggleScreenLayout();
|
||||
void OnSwapScreens();
|
||||
void OnRotateScreens();
|
||||
|
@ -238,6 +240,7 @@ private:
|
|||
std::unique_ptr<Ui::MainWindow> ui;
|
||||
|
||||
GRenderWindow* render_window;
|
||||
GRenderWindow* secondary_window;
|
||||
|
||||
GameListPlaceholder* game_list_placeholder;
|
||||
LoadingScreen* loading_screen;
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
<addaction name="action_Screen_Layout_Single_Screen"/>
|
||||
<addaction name="action_Screen_Layout_Large_Screen"/>
|
||||
<addaction name="action_Screen_Layout_Side_by_Side"/>
|
||||
<addaction name="action_Screen_Layout_Separate_Windows"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_Screen_Layout_Upright_Screens"/>
|
||||
<addaction name="action_Screen_Layout_Swap_Screens"/>
|
||||
|
@ -471,6 +472,14 @@
|
|||
<string>Side by Side</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Screen_Layout_Separate_Windows">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Separate Windows</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Screen_Layout_Swap_Screens">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
|
|
|
@ -247,7 +247,8 @@ System::ResultStatus System::SingleStep() {
|
|||
return RunLoop(false);
|
||||
}
|
||||
|
||||
System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) {
|
||||
System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath,
|
||||
Frontend::EmuWindow* secondary_window) {
|
||||
FileUtil::SetCurrentRomPath(filepath);
|
||||
app_loader = Loader::GetLoader(filepath);
|
||||
if (!app_loader) {
|
||||
|
@ -278,7 +279,8 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st
|
|||
if (Settings::values.is_new_3ds) {
|
||||
num_cores = 4;
|
||||
}
|
||||
ResultStatus init_result{Init(emu_window, *system_mode.first, *n3ds_mode.first, num_cores)};
|
||||
ResultStatus init_result{
|
||||
Init(emu_window, secondary_window, *system_mode.first, *n3ds_mode.first, num_cores)};
|
||||
if (init_result != ResultStatus::Success) {
|
||||
LOG_CRITICAL(Core, "Failed to initialize system (Error {})!",
|
||||
static_cast<u32>(init_result));
|
||||
|
@ -324,6 +326,7 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st
|
|||
|
||||
status = ResultStatus::Success;
|
||||
m_emu_window = &emu_window;
|
||||
m_secondary_window = secondary_window;
|
||||
m_filepath = filepath;
|
||||
self_delete_pending = false;
|
||||
|
||||
|
@ -355,8 +358,9 @@ void System::Reschedule() {
|
|||
}
|
||||
}
|
||||
|
||||
System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mode, u8 n3ds_mode,
|
||||
u32 num_cores) {
|
||||
System::ResultStatus System::Init(Frontend::EmuWindow& emu_window,
|
||||
Frontend::EmuWindow* secondary_window, u32 system_mode,
|
||||
u8 n3ds_mode, u32 num_cores) {
|
||||
LOG_DEBUG(HW_Memory, "initialized OK");
|
||||
|
||||
memory = std::make_unique<Memory::MemorySystem>();
|
||||
|
@ -420,7 +424,7 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mo
|
|||
video_dumper = std::make_unique<VideoDumper::NullBackend>();
|
||||
#endif
|
||||
|
||||
VideoCore::ResultStatus result = VideoCore::Init(emu_window, *memory);
|
||||
VideoCore::ResultStatus result = VideoCore::Init(emu_window, secondary_window, *memory);
|
||||
if (result != VideoCore::ResultStatus::Success) {
|
||||
switch (result) {
|
||||
case VideoCore::ResultStatus::ErrorGenericDrivers:
|
||||
|
@ -586,7 +590,8 @@ void System::Reset() {
|
|||
}
|
||||
|
||||
// Reload the system with the same setting
|
||||
[[maybe_unused]] const System::ResultStatus result = Load(*m_emu_window, m_filepath);
|
||||
[[maybe_unused]] const System::ResultStatus result =
|
||||
Load(*m_emu_window, m_filepath, m_secondary_window);
|
||||
|
||||
// Restore the deliver arg.
|
||||
if (auto apt = Service::APT::GetModule(*this)) {
|
||||
|
@ -611,8 +616,8 @@ void System::serialize(Archive& ar, const unsigned int file_version) {
|
|||
// Re-initialize everything like it was before
|
||||
auto system_mode = this->app_loader->LoadKernelSystemMode();
|
||||
auto n3ds_mode = this->app_loader->LoadKernelN3dsMode();
|
||||
[[maybe_unused]] const System::ResultStatus result =
|
||||
Init(*m_emu_window, *system_mode.first, *n3ds_mode.first, num_cores);
|
||||
[[maybe_unused]] const System::ResultStatus result = Init(
|
||||
*m_emu_window, m_secondary_window, *system_mode.first, *n3ds_mode.first, num_cores);
|
||||
}
|
||||
|
||||
// flush on save, don't flush on load
|
||||
|
|
|
@ -143,7 +143,8 @@ public:
|
|||
* @param filepath String path to the executable application to load on the host file system.
|
||||
* @returns ResultStatus code, indicating if the operation succeeded.
|
||||
*/
|
||||
[[nodiscard]] ResultStatus Load(Frontend::EmuWindow& emu_window, const std::string& filepath);
|
||||
[[nodiscard]] ResultStatus Load(Frontend::EmuWindow& emu_window, const std::string& filepath,
|
||||
Frontend::EmuWindow* secondary_window = {});
|
||||
|
||||
/**
|
||||
* Indicates if the emulated system is powered on (all subsystems initialized and able to run an
|
||||
|
@ -324,8 +325,9 @@ private:
|
|||
* @param system_mode The system mode.
|
||||
* @return ResultStatus code, indicating if the operation succeeded.
|
||||
*/
|
||||
[[nodiscard]] ResultStatus Init(Frontend::EmuWindow& emu_window, u32 system_mode, u8 n3ds_mode,
|
||||
u32 num_cores);
|
||||
[[nodiscard]] ResultStatus Init(Frontend::EmuWindow& emu_window,
|
||||
Frontend::EmuWindow* secondary_window, u32 system_mode,
|
||||
u8 n3ds_mode, u32 num_cores);
|
||||
|
||||
/// Reschedule the core emulation
|
||||
void Reschedule();
|
||||
|
@ -385,6 +387,7 @@ private:
|
|||
std::string status_details = "";
|
||||
/// Saved variables for reset
|
||||
Frontend::EmuWindow* m_emu_window;
|
||||
Frontend::EmuWindow* m_secondary_window;
|
||||
std::string m_filepath;
|
||||
std::string m_chainloadpath;
|
||||
u64 title_id;
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <mutex>
|
||||
#include "core/3ds.h"
|
||||
#include "core/frontend/emu_window.h"
|
||||
#include "core/frontend/input.h"
|
||||
#include "core/settings.h"
|
||||
|
||||
namespace Frontend {
|
||||
/// We need a global touch state that is shared across the different window instances
|
||||
static std::weak_ptr<EmuWindow::TouchState> global_touch_state;
|
||||
|
||||
GraphicsContext::~GraphicsContext() = default;
|
||||
|
||||
|
@ -45,18 +46,14 @@ private:
|
|||
};
|
||||
|
||||
EmuWindow::EmuWindow() {
|
||||
// TODO: Find a better place to set this.
|
||||
config.min_client_area_size =
|
||||
std::make_pair(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight);
|
||||
active_config = config;
|
||||
touch_state = std::make_shared<TouchState>();
|
||||
Input::RegisterFactory<Input::TouchDevice>("emu_window", touch_state);
|
||||
}
|
||||
|
||||
EmuWindow::~EmuWindow() {
|
||||
Input::UnregisterFactory<Input::TouchDevice>("emu_window");
|
||||
CreateTouchState();
|
||||
};
|
||||
|
||||
EmuWindow::EmuWindow(bool is_secondary_) : is_secondary{is_secondary_} {
|
||||
CreateTouchState();
|
||||
}
|
||||
|
||||
EmuWindow::~EmuWindow() = default;
|
||||
/**
|
||||
* Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout
|
||||
* @param layout FramebufferLayout object describing the framebuffer size and screen positions
|
||||
|
@ -111,6 +108,15 @@ std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsi
|
|||
return std::make_tuple(new_x, new_y);
|
||||
}
|
||||
|
||||
void EmuWindow::CreateTouchState() {
|
||||
if (touch_state = global_touch_state.lock()) {
|
||||
return;
|
||||
}
|
||||
touch_state = std::make_shared<TouchState>();
|
||||
Input::RegisterFactory<Input::TouchDevice>("emu_window", touch_state);
|
||||
global_touch_state = touch_state;
|
||||
}
|
||||
|
||||
bool EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) {
|
||||
if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y))
|
||||
return false;
|
||||
|
@ -194,6 +200,12 @@ void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height,
|
|||
layout = Layout::SideFrameLayout(width, height, Settings::values.swap_screen,
|
||||
Settings::values.upright_screen);
|
||||
break;
|
||||
#ifndef ANDROID
|
||||
case Settings::LayoutOption::SeparateWindows:
|
||||
layout = Layout::SeparateWindowsLayout(width, height, is_secondary,
|
||||
Settings::values.upright_screen);
|
||||
break;
|
||||
#endif
|
||||
case Settings::LayoutOption::MobilePortrait:
|
||||
layout = Layout::MobilePortraitFrameLayout(width, height, Settings::values.swap_screen);
|
||||
break;
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/3ds.h"
|
||||
#include "core/frontend/framebuffer_layout.h"
|
||||
|
||||
namespace Frontend {
|
||||
|
@ -87,12 +89,15 @@ public:
|
|||
*/
|
||||
class EmuWindow : public GraphicsContext {
|
||||
public:
|
||||
class TouchState;
|
||||
|
||||
/// Data structure to store emuwindow configuration
|
||||
struct WindowConfig {
|
||||
bool fullscreen = false;
|
||||
int res_width = 0;
|
||||
int res_height = 0;
|
||||
std::pair<unsigned, unsigned> min_client_area_size;
|
||||
std::pair<unsigned, unsigned> min_client_area_size{
|
||||
Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight};
|
||||
};
|
||||
|
||||
/// Polls window events
|
||||
|
@ -177,6 +182,7 @@ public:
|
|||
|
||||
protected:
|
||||
EmuWindow();
|
||||
EmuWindow(bool is_secondary);
|
||||
virtual ~EmuWindow();
|
||||
|
||||
/**
|
||||
|
@ -204,6 +210,8 @@ protected:
|
|||
framebuffer_layout = layout;
|
||||
}
|
||||
|
||||
bool is_secondary{};
|
||||
|
||||
private:
|
||||
/**
|
||||
* Handler called when the minimal client area was requested to be changed via SetConfig.
|
||||
|
@ -214,13 +222,14 @@ private:
|
|||
// By default, ignore this request and do nothing.
|
||||
}
|
||||
|
||||
void CreateTouchState();
|
||||
|
||||
Layout::FramebufferLayout framebuffer_layout; ///< Current framebuffer layout
|
||||
|
||||
WindowConfig config; ///< Internal configuration (changes pending for being applied in
|
||||
WindowConfig config{}; ///< Internal configuration (changes pending for being applied in
|
||||
/// ProcessConfigurationChanges)
|
||||
WindowConfig active_config; ///< Internal active configuration
|
||||
WindowConfig active_config{}; ///< Internal active configuration
|
||||
|
||||
class TouchState;
|
||||
std::shared_ptr<TouchState> touch_state;
|
||||
|
||||
/**
|
||||
|
|
|
@ -342,6 +342,13 @@ FramebufferLayout SideFrameLayout(u32 width, u32 height, bool swapped, bool upri
|
|||
return res;
|
||||
}
|
||||
|
||||
FramebufferLayout SeparateWindowsLayout(u32 width, u32 height, bool is_secondary, bool upright) {
|
||||
// When is_secondary is true, we disable the top screen, and enable the bottom screen.
|
||||
// The same logic is found in the SingleFrameLayout using the is_swapped bool.
|
||||
is_secondary = Settings::values.swap_screen ? !is_secondary : is_secondary;
|
||||
return SingleFrameLayout(width, height, is_secondary, upright);
|
||||
}
|
||||
|
||||
FramebufferLayout CustomFrameLayout(u32 width, u32 height) {
|
||||
ASSERT(width > 0);
|
||||
ASSERT(height > 0);
|
||||
|
@ -360,7 +367,7 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height) {
|
|||
return res;
|
||||
}
|
||||
|
||||
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) {
|
||||
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondary) {
|
||||
FramebufferLayout layout;
|
||||
if (Settings::values.custom_layout == true) {
|
||||
layout = CustomFrameLayout(
|
||||
|
@ -370,8 +377,13 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) {
|
|||
int width, height;
|
||||
switch (Settings::values.layout_option) {
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
#ifndef ANDROID
|
||||
case Settings::LayoutOption::SeparateWindows:
|
||||
#endif
|
||||
{
|
||||
const bool swap_screens = is_secondary || Settings::values.swap_screen;
|
||||
if (Settings::values.upright_screen) {
|
||||
if (Settings::values.swap_screen) {
|
||||
if (swap_screens) {
|
||||
width = Core::kScreenBottomHeight * res_scale;
|
||||
height = Core::kScreenBottomWidth * res_scale;
|
||||
} else {
|
||||
|
@ -379,7 +391,7 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) {
|
|||
height = Core::kScreenTopWidth * res_scale;
|
||||
}
|
||||
} else {
|
||||
if (Settings::values.swap_screen) {
|
||||
if (swap_screens) {
|
||||
width = Core::kScreenBottomWidth * res_scale;
|
||||
height = Core::kScreenBottomHeight * res_scale;
|
||||
} else {
|
||||
|
@ -387,9 +399,10 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) {
|
|||
height = Core::kScreenTopHeight * res_scale;
|
||||
}
|
||||
}
|
||||
layout = SingleFrameLayout(width, height, Settings::values.swap_screen,
|
||||
Settings::values.upright_screen);
|
||||
layout =
|
||||
SingleFrameLayout(width, height, swap_screens, Settings::values.upright_screen);
|
||||
break;
|
||||
}
|
||||
case Settings::LayoutOption::LargeScreen:
|
||||
if (Settings::values.upright_screen) {
|
||||
if (Settings::values.swap_screen) {
|
||||
|
@ -544,6 +557,9 @@ std::pair<unsigned, unsigned> GetMinimumSizeFromLayout(Settings::LayoutOption la
|
|||
|
||||
switch (layout) {
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
#ifndef ANDROID
|
||||
case Settings::LayoutOption::SeparateWindows:
|
||||
#endif
|
||||
min_width = Settings::values.swap_screen ? Core::kScreenBottomWidth : Core::kScreenTopWidth;
|
||||
min_height = Core::kScreenBottomHeight;
|
||||
break;
|
||||
|
|
|
@ -98,6 +98,16 @@ FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool is_swapped, bool
|
|||
*/
|
||||
FramebufferLayout SideFrameLayout(u32 width, u32 height, bool is_swapped, bool upright);
|
||||
|
||||
/**
|
||||
* Factory method for constructing a Frame with the Top screen and bottom
|
||||
* screen on separate windows
|
||||
* @param width Window framebuffer width in pixels
|
||||
* @param height Window framebuffer height in pixels
|
||||
* @param is_secondary if true, the bottom screen will be enabled instead of the top screen
|
||||
* @return Newly created FramebufferLayout object with default screen regions initialized
|
||||
*/
|
||||
FramebufferLayout SeparateWindowsLayout(u32 width, u32 height, bool is_secondary, bool upright);
|
||||
|
||||
/**
|
||||
* Factory method for constructing a custom FramebufferLayout
|
||||
* @param width Window framebuffer width in pixels
|
||||
|
@ -111,7 +121,7 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height);
|
|||
* Read from the current settings to determine which layout to use.
|
||||
* @param res_scale resolution scale factor
|
||||
*/
|
||||
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale);
|
||||
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondary = false);
|
||||
|
||||
/**
|
||||
* Convenience method for transforming a frame layout when using Cardboard VR
|
||||
|
|
|
@ -24,7 +24,9 @@ enum class LayoutOption {
|
|||
SingleScreen,
|
||||
LargeScreen,
|
||||
SideScreen,
|
||||
|
||||
#ifndef ANDROID
|
||||
SeparateWindows,
|
||||
#endif
|
||||
// Similiar to default, but better for mobile devices in portrait mode. Top screen in clamped to
|
||||
// the top of the frame, and the bottom screen is enlarged to match the top screen.
|
||||
MobilePortrait,
|
||||
|
|
|
@ -56,6 +56,7 @@ void Shutdown() {
|
|||
Input::UnregisterFactory<Input::AnalogDevice>("analog_from_button");
|
||||
Input::UnregisterFactory<Input::MotionDevice>("motion_emu");
|
||||
motion_emu.reset();
|
||||
Input::UnregisterFactory<Input::TouchDevice>("emu_window");
|
||||
Input::UnregisterFactory<Input::TouchDevice>("touch_from_button");
|
||||
sdl.reset();
|
||||
udp.reset();
|
||||
|
|
|
@ -9,11 +9,20 @@
|
|||
#include "video_core/swrasterizer/swrasterizer.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
RendererBase::RendererBase(Frontend::EmuWindow& window) : render_window{window} {}
|
||||
RendererBase::RendererBase(Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window_)
|
||||
: render_window{window}, secondary_window{secondary_window_} {}
|
||||
|
||||
RendererBase::~RendererBase() = default;
|
||||
|
||||
void RendererBase::UpdateCurrentFramebufferLayout(bool is_portrait_mode) {
|
||||
const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout();
|
||||
render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height, is_portrait_mode);
|
||||
const auto update_layout = [is_portrait_mode](Frontend::EmuWindow& window) {
|
||||
const Layout::FramebufferLayout& layout = window.GetFramebufferLayout();
|
||||
window.UpdateCurrentFramebufferLayout(layout.width, layout.height, is_portrait_mode);
|
||||
};
|
||||
update_layout(render_window);
|
||||
if (secondary_window) {
|
||||
update_layout(*secondary_window);
|
||||
}
|
||||
}
|
||||
|
||||
void RendererBase::RefreshRasterizerSetting() {
|
||||
|
|
|
@ -15,7 +15,7 @@ class EmuWindow;
|
|||
|
||||
class RendererBase : NonCopyable {
|
||||
public:
|
||||
explicit RendererBase(Frontend::EmuWindow& window);
|
||||
explicit RendererBase(Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window);
|
||||
virtual ~RendererBase();
|
||||
|
||||
/// Initialize the renderer
|
||||
|
@ -29,7 +29,10 @@ public:
|
|||
|
||||
/// Draws the latest frame to the window waiting timeout_ms for a frame to arrive (Renderer
|
||||
/// specific implementation)
|
||||
virtual void TryPresent(int timeout_ms) = 0;
|
||||
virtual void TryPresent(int timeout_ms, bool is_secondary) = 0;
|
||||
virtual void TryPresent(int timeout_ms) {
|
||||
TryPresent(timeout_ms, false);
|
||||
}
|
||||
|
||||
/// Prepares for video dumping (e.g. create necessary buffers, etc)
|
||||
virtual void PrepareVideoDumping() = 0;
|
||||
|
@ -68,6 +71,7 @@ public:
|
|||
|
||||
protected:
|
||||
Frontend::EmuWindow& render_window; ///< Reference to the render window handle.
|
||||
Frontend::EmuWindow* secondary_window; ///< Reference to the secondary render window handle.
|
||||
std::unique_ptr<VideoCore::RasterizerInterface> rasterizer;
|
||||
f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer
|
||||
int m_current_frame = 0; ///< Current frame, should be set by the renderer
|
||||
|
|
|
@ -352,10 +352,13 @@ static std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(const float width, cons
|
|||
return matrix;
|
||||
}
|
||||
|
||||
RendererOpenGL::RendererOpenGL(Frontend::EmuWindow& window)
|
||||
: RendererBase{window}, frame_dumper(Core::System::GetInstance().VideoDumper(), window) {
|
||||
|
||||
RendererOpenGL::RendererOpenGL(Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window)
|
||||
: RendererBase{window, secondary_window},
|
||||
frame_dumper(Core::System::GetInstance().VideoDumper(), window) {
|
||||
window.mailbox = std::make_unique<OGLTextureMailbox>();
|
||||
if (secondary_window) {
|
||||
secondary_window->mailbox = std::make_unique<OGLTextureMailbox>();
|
||||
}
|
||||
frame_dumper.mailbox = std::make_unique<OGLVideoDumpingMailbox>();
|
||||
}
|
||||
|
||||
|
@ -374,9 +377,17 @@ void RendererOpenGL::SwapBuffers() {
|
|||
|
||||
RenderScreenshot();
|
||||
|
||||
const auto& layout = render_window.GetFramebufferLayout();
|
||||
RenderToMailbox(layout, render_window.mailbox, false);
|
||||
const auto& main_layout = render_window.GetFramebufferLayout();
|
||||
RenderToMailbox(main_layout, render_window.mailbox, false);
|
||||
|
||||
#ifndef ANDROID
|
||||
if (Settings::values.layout_option == Settings::LayoutOption::SeparateWindows) {
|
||||
ASSERT(secondary_window);
|
||||
const auto& secondary_layout = secondary_window->GetFramebufferLayout();
|
||||
RenderToMailbox(secondary_layout, secondary_window->mailbox, false);
|
||||
secondary_window->PollEvents();
|
||||
}
|
||||
#endif
|
||||
if (frame_dumper.IsDumping()) {
|
||||
try {
|
||||
RenderToMailbox(frame_dumper.GetLayout(), frame_dumper.mailbox, true);
|
||||
|
@ -1112,9 +1123,10 @@ void RendererOpenGL::DrawScreens(const Layout::FramebufferLayout& layout, bool f
|
|||
}
|
||||
}
|
||||
|
||||
void RendererOpenGL::TryPresent(int timeout_ms) {
|
||||
const auto& layout = render_window.GetFramebufferLayout();
|
||||
auto frame = render_window.mailbox->TryGetPresentFrame(timeout_ms);
|
||||
void RendererOpenGL::TryPresent(int timeout_ms, bool is_secondary) {
|
||||
const auto& window = is_secondary ? *secondary_window : render_window;
|
||||
const auto& layout = window.GetFramebufferLayout();
|
||||
auto frame = window.mailbox->TryGetPresentFrame(timeout_ms);
|
||||
if (!frame) {
|
||||
LOG_DEBUG(Render_OpenGL, "TryGetPresentFrame returned no frame to present");
|
||||
return;
|
||||
|
@ -1127,7 +1139,7 @@ void RendererOpenGL::TryPresent(int timeout_ms) {
|
|||
// Recreate the presentation FBO if the color attachment was changed
|
||||
if (frame->color_reloaded) {
|
||||
LOG_DEBUG(Render_OpenGL, "Reloading present frame");
|
||||
render_window.mailbox->ReloadPresentFrame(frame, layout.width, layout.height);
|
||||
window.mailbox->ReloadPresentFrame(frame, layout.width, layout.height);
|
||||
}
|
||||
glWaitSync(frame->render_fence, 0, GL_TIMEOUT_IGNORED);
|
||||
// INTEL workaround.
|
||||
|
|
|
@ -56,7 +56,7 @@ struct PresentationTexture {
|
|||
|
||||
class RendererOpenGL : public RendererBase {
|
||||
public:
|
||||
explicit RendererOpenGL(Frontend::EmuWindow& window);
|
||||
explicit RendererOpenGL(Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window);
|
||||
~RendererOpenGL() override;
|
||||
|
||||
/// Initialize the renderer
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
/// Draws the latest frame from texture mailbox to the currently bound draw framebuffer in this
|
||||
/// context
|
||||
void TryPresent(int timeout_ms) override;
|
||||
void TryPresent(int timeout_ms, bool is_secondary) override;
|
||||
|
||||
/// Prepares for video dumping (e.g. create necessary buffers, etc)
|
||||
void PrepareVideoDumping() override;
|
||||
|
|
|
@ -39,13 +39,14 @@ Layout::FramebufferLayout g_screenshot_framebuffer_layout;
|
|||
Memory::MemorySystem* g_memory;
|
||||
|
||||
/// Initialize the video core
|
||||
ResultStatus Init(Frontend::EmuWindow& emu_window, Memory::MemorySystem& memory) {
|
||||
ResultStatus Init(Frontend::EmuWindow& emu_window, Frontend::EmuWindow* secondary_window,
|
||||
Memory::MemorySystem& memory) {
|
||||
g_memory = &memory;
|
||||
Pica::Init();
|
||||
|
||||
OpenGL::GLES = Settings::values.use_gles;
|
||||
|
||||
g_renderer = std::make_unique<OpenGL::RendererOpenGL>(emu_window);
|
||||
g_renderer = std::make_unique<OpenGL::RendererOpenGL>(emu_window, secondary_window);
|
||||
ResultStatus result = g_renderer->Init();
|
||||
|
||||
if (result != ResultStatus::Success) {
|
||||
|
|
|
@ -54,7 +54,8 @@ enum class ResultStatus {
|
|||
};
|
||||
|
||||
/// Initialize the video core
|
||||
ResultStatus Init(Frontend::EmuWindow& emu_window, Memory::MemorySystem& memory);
|
||||
ResultStatus Init(Frontend::EmuWindow& emu_window, Frontend::EmuWindow* secondary_window,
|
||||
Memory::MemorySystem& memory);
|
||||
|
||||
/// Shutdown the video core
|
||||
void Shutdown();
|
||||
|
|
Loading…
Reference in a new issue