summaryrefslogtreecommitdiff
path: root/src/yuzu_cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu_cmd')
-rw-r--r--src/yuzu_cmd/config.cpp2
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.cpp5
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.h9
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp15
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h5
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp9
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h7
-rw-r--r--src/yuzu_cmd/yuzu.cpp7
8 files changed, 14 insertions, 45 deletions
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index e9f1c6500..23448e747 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -290,6 +290,8 @@ void Config::ReadValues() {
290 290
291 Settings::values.vibration_enabled = 291 Settings::values.vibration_enabled =
292 sdl2_config->GetBoolean("ControlsGeneral", "vibration_enabled", true); 292 sdl2_config->GetBoolean("ControlsGeneral", "vibration_enabled", true);
293 Settings::values.motion_enabled =
294 sdl2_config->GetBoolean("ControlsGeneral", "motion_enabled", true);
293 Settings::values.touchscreen.enabled = 295 Settings::values.touchscreen.enabled =
294 sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true); 296 sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true);
295 Settings::values.touchscreen.device = 297 Settings::values.touchscreen.device =
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
index a804d5185..521209622 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
@@ -13,9 +13,8 @@
13#include "input_common/sdl/sdl.h" 13#include "input_common/sdl/sdl.h"
14#include "yuzu_cmd/emu_window/emu_window_sdl2.h" 14#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
15 15
16EmuWindow_SDL2::EmuWindow_SDL2(Core::System& system, bool fullscreen, 16EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_)
17 InputCommon::InputSubsystem* input_subsystem_) 17 : input_subsystem{input_subsystem_} {
18 : system{system}, input_subsystem{input_subsystem_} {
19 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { 18 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
20 LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting..."); 19 LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting...");
21 exit(1); 20 exit(1);
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
index 82750ffec..53d756c3c 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
@@ -20,8 +20,7 @@ class InputSubsystem;
20 20
21class EmuWindow_SDL2 : public Core::Frontend::EmuWindow { 21class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
22public: 22public:
23 explicit EmuWindow_SDL2(Core::System& system, bool fullscreen, 23 explicit EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem);
24 InputCommon::InputSubsystem* input_subsystem);
25 ~EmuWindow_SDL2(); 24 ~EmuWindow_SDL2();
26 25
27 /// Polls window events 26 /// Polls window events
@@ -33,9 +32,6 @@ public:
33 /// Returns if window is shown (not minimized) 32 /// Returns if window is shown (not minimized)
34 bool IsShown() const override; 33 bool IsShown() const override;
35 34
36 /// Presents the next frame
37 virtual void Present() = 0;
38
39protected: 35protected:
40 /// Called by PollEvents when a key is pressed or released. 36 /// Called by PollEvents when a key is pressed or released.
41 void OnKeyEvent(int key, u8 state); 37 void OnKeyEvent(int key, u8 state);
@@ -67,9 +63,6 @@ protected:
67 /// Called when a configuration change affects the minimal size of the window 63 /// Called when a configuration change affects the minimal size of the window
68 void OnMinimalClientAreaChangeRequest(std::pair<unsigned, unsigned> minimal_size) override; 64 void OnMinimalClientAreaChangeRequest(std::pair<unsigned, unsigned> minimal_size) override;
69 65
70 /// Instance of the system, used to access renderer for the presentation thread
71 Core::System& system;
72
73 /// Is the window still open? 66 /// Is the window still open?
74 bool is_open = true; 67 bool is_open = true;
75 68
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
index 881b67a76..5f35233b5 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp
@@ -87,9 +87,8 @@ bool EmuWindow_SDL2_GL::SupportsRequiredGLExtensions() {
87 return unsupported_ext.empty(); 87 return unsupported_ext.empty();
88} 88}
89 89
90EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(Core::System& system, bool fullscreen, 90EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem, bool fullscreen)
91 InputCommon::InputSubsystem* input_subsystem) 91 : EmuWindow_SDL2{input_subsystem} {
92 : EmuWindow_SDL2{system, fullscreen, input_subsystem} {
93 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); 92 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
94 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); 93 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
95 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); 94 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
@@ -163,13 +162,3 @@ EmuWindow_SDL2_GL::~EmuWindow_SDL2_GL() {
163std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_GL::CreateSharedContext() const { 162std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_GL::CreateSharedContext() const {
164 return std::make_unique<SDLGLContext>(); 163 return std::make_unique<SDLGLContext>();
165} 164}
166
167void EmuWindow_SDL2_GL::Present() {
168 SDL_GL_MakeCurrent(render_window, window_context);
169 SDL_GL_SetSwapInterval(Settings::values.use_vsync.GetValue() ? 1 : 0);
170 while (IsOpen()) {
171 system.Renderer().TryPresent(100);
172 SDL_GL_SwapWindow(render_window);
173 }
174 SDL_GL_MakeCurrent(render_window, nullptr);
175}
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h
index 732a64edd..dba5c293c 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h
@@ -14,12 +14,9 @@ class InputSubsystem;
14 14
15class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 { 15class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 {
16public: 16public:
17 explicit EmuWindow_SDL2_GL(Core::System& system, bool fullscreen, 17 explicit EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem, bool fullscreen);
18 InputCommon::InputSubsystem* input_subsystem);
19 ~EmuWindow_SDL2_GL(); 18 ~EmuWindow_SDL2_GL();
20 19
21 void Present() override;
22
23 std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override; 20 std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
24 21
25private: 22private:
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp
index 53491f86e..3ba657c00 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp
@@ -19,9 +19,8 @@
19#include <SDL.h> 19#include <SDL.h>
20#include <SDL_syswm.h> 20#include <SDL_syswm.h>
21 21
22EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(Core::System& system, bool fullscreen, 22EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem)
23 InputCommon::InputSubsystem* input_subsystem) 23 : EmuWindow_SDL2{input_subsystem} {
24 : EmuWindow_SDL2{system, fullscreen, input_subsystem} {
25 const std::string window_title = fmt::format("yuzu {} | {}-{} (Vulkan)", Common::g_build_name, 24 const std::string window_title = fmt::format("yuzu {} | {}-{} (Vulkan)", Common::g_build_name,
26 Common::g_scm_branch, Common::g_scm_desc); 25 Common::g_scm_branch, Common::g_scm_desc);
27 render_window = 26 render_window =
@@ -74,7 +73,3 @@ EmuWindow_SDL2_VK::~EmuWindow_SDL2_VK() = default;
74std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_VK::CreateSharedContext() const { 73std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_VK::CreateSharedContext() const {
75 return std::make_unique<DummyContext>(); 74 return std::make_unique<DummyContext>();
76} 75}
77
78void EmuWindow_SDL2_VK::Present() {
79 // TODO (bunnei): ImplementMe
80}
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h
index f99704d4c..bdfdc3c6f 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h
@@ -19,11 +19,8 @@ class InputSubsystem;
19 19
20class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 { 20class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 {
21public: 21public:
22 explicit EmuWindow_SDL2_VK(Core::System& system, bool fullscreen, 22 explicit EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem);
23 InputCommon::InputSubsystem* input_subsystem); 23 ~EmuWindow_SDL2_VK() override;
24 ~EmuWindow_SDL2_VK();
25
26 void Present() override;
27 24
28 std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override; 25 std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
29}; 26};
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index e960b5413..3a76c785f 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -185,11 +185,11 @@ int main(int argc, char** argv) {
185 std::unique_ptr<EmuWindow_SDL2> emu_window; 185 std::unique_ptr<EmuWindow_SDL2> emu_window;
186 switch (Settings::values.renderer_backend.GetValue()) { 186 switch (Settings::values.renderer_backend.GetValue()) {
187 case Settings::RendererBackend::OpenGL: 187 case Settings::RendererBackend::OpenGL:
188 emu_window = std::make_unique<EmuWindow_SDL2_GL>(system, fullscreen, &input_subsystem); 188 emu_window = std::make_unique<EmuWindow_SDL2_GL>(&input_subsystem, fullscreen);
189 break; 189 break;
190 case Settings::RendererBackend::Vulkan: 190 case Settings::RendererBackend::Vulkan:
191#ifdef HAS_VULKAN 191#ifdef HAS_VULKAN
192 emu_window = std::make_unique<EmuWindow_SDL2_VK>(system, fullscreen, &input_subsystem); 192 emu_window = std::make_unique<EmuWindow_SDL2_VK>(&input_subsystem);
193 break; 193 break;
194#else 194#else
195 LOG_CRITICAL(Frontend, "Vulkan backend has not been compiled!"); 195 LOG_CRITICAL(Frontend, "Vulkan backend has not been compiled!");
@@ -240,14 +240,11 @@ int main(int argc, char** argv) {
240 system.CurrentProcess()->GetTitleID(), false, 240 system.CurrentProcess()->GetTitleID(), false,
241 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {}); 241 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {});
242 242
243 std::thread render_thread([&emu_window] { emu_window->Present(); });
244 system.Run(); 243 system.Run();
245 while (emu_window->IsOpen()) { 244 while (emu_window->IsOpen()) {
246 std::this_thread::sleep_for(std::chrono::milliseconds(1)); 245 std::this_thread::sleep_for(std::chrono::milliseconds(1));
247 } 246 }
248 system.Pause(); 247 system.Pause();
249 render_thread.join();
250
251 system.Shutdown(); 248 system.Shutdown();
252 249
253 detached_tasks.WaitForAllTasks(); 250 detached_tasks.WaitForAllTasks();