2020-01-21 19:40:53 +00:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2020-04-02 05:32:58 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <memory>
|
2020-01-21 19:40:53 +00:00
|
|
|
#include <string>
|
2020-04-02 05:32:58 +00:00
|
|
|
|
2020-01-21 19:40:53 +00:00
|
|
|
#include <fmt/format.h>
|
2020-04-02 05:32:58 +00:00
|
|
|
|
2020-01-21 19:40:53 +00:00
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "common/scm_rev.h"
|
2021-04-14 23:07:40 +00:00
|
|
|
#include "common/settings.h"
|
2020-04-02 05:32:58 +00:00
|
|
|
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
2020-01-21 19:40:53 +00:00
|
|
|
#include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h"
|
|
|
|
|
2021-07-16 01:02:00 +00:00
|
|
|
#ifdef YUZU_USE_EXTERNAL_SDL2
|
|
|
|
// Include this before SDL.h to prevent the external from including a dummy
|
|
|
|
#define USING_GENERATED_CONFIG_H
|
|
|
|
#include <SDL_config.h>
|
|
|
|
#endif
|
|
|
|
|
2020-04-02 05:32:58 +00:00
|
|
|
// Include these late to avoid polluting everything with Xlib macros
|
2021-04-18 04:40:31 +00:00
|
|
|
// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307
|
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
|
|
|
|
#endif
|
2020-04-02 05:32:58 +00:00
|
|
|
#include <SDL.h>
|
2021-04-18 04:40:31 +00:00
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
#endif
|
2020-04-02 05:32:58 +00:00
|
|
|
#include <SDL_syswm.h>
|
|
|
|
|
2020-09-19 20:15:02 +00:00
|
|
|
EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem)
|
|
|
|
: EmuWindow_SDL2{input_subsystem} {
|
2020-01-21 19:40:53 +00:00
|
|
|
const std::string window_title = fmt::format("yuzu {} | {}-{} (Vulkan)", Common::g_build_name,
|
|
|
|
Common::g_scm_branch, Common::g_scm_desc);
|
|
|
|
render_window =
|
2020-04-02 05:32:58 +00:00
|
|
|
SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
2020-01-21 19:40:53 +00:00
|
|
|
Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height,
|
2020-04-02 05:32:58 +00:00
|
|
|
SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
2020-01-21 19:40:53 +00:00
|
|
|
|
2020-04-02 05:32:58 +00:00
|
|
|
SDL_SysWMinfo wm;
|
2020-04-22 05:47:21 +00:00
|
|
|
SDL_VERSION(&wm.version);
|
2020-04-02 05:32:58 +00:00
|
|
|
if (SDL_GetWindowWMInfo(render_window, &wm) == SDL_FALSE) {
|
|
|
|
LOG_CRITICAL(Frontend, "Failed to get information from the window manager");
|
|
|
|
std::exit(EXIT_FAILURE);
|
2020-01-21 19:40:53 +00:00
|
|
|
}
|
|
|
|
|
2021-02-14 08:20:41 +00:00
|
|
|
SetWindowIcon();
|
|
|
|
|
2020-04-02 05:32:58 +00:00
|
|
|
switch (wm.subsystem) {
|
|
|
|
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
|
|
|
case SDL_SYSWM_TYPE::SDL_SYSWM_WINDOWS:
|
|
|
|
window_info.type = Core::Frontend::WindowSystemType::Windows;
|
|
|
|
window_info.render_surface = reinterpret_cast<void*>(wm.info.win.window);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef SDL_VIDEO_DRIVER_X11
|
|
|
|
case SDL_SYSWM_TYPE::SDL_SYSWM_X11:
|
|
|
|
window_info.type = Core::Frontend::WindowSystemType::X11;
|
|
|
|
window_info.display_connection = wm.info.x11.display;
|
|
|
|
window_info.render_surface = reinterpret_cast<void*>(wm.info.x11.window);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef SDL_VIDEO_DRIVER_WAYLAND
|
|
|
|
case SDL_SYSWM_TYPE::SDL_SYSWM_WAYLAND:
|
|
|
|
window_info.type = Core::Frontend::WindowSystemType::Wayland;
|
|
|
|
window_info.display_connection = wm.info.wl.display;
|
|
|
|
window_info.render_surface = wm.info.wl.surface;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
LOG_CRITICAL(Frontend, "Window manager subsystem not implemented");
|
|
|
|
std::exit(EXIT_FAILURE);
|
2020-01-21 19:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OnResize();
|
|
|
|
OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
|
|
|
|
SDL_PumpEvents();
|
|
|
|
LOG_INFO(Frontend, "yuzu Version: {} | {}-{} (Vulkan)", Common::g_build_name,
|
|
|
|
Common::g_scm_branch, Common::g_scm_desc);
|
|
|
|
}
|
|
|
|
|
2020-04-02 05:32:58 +00:00
|
|
|
EmuWindow_SDL2_VK::~EmuWindow_SDL2_VK() = default;
|
2020-01-21 19:40:53 +00:00
|
|
|
|
|
|
|
std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_VK::CreateSharedContext() const {
|
2020-04-22 21:36:21 +00:00
|
|
|
return std::make_unique<DummyContext>();
|
2020-01-21 19:40:53 +00:00
|
|
|
}
|