diff options
Diffstat (limited to 'src/yuzu_cmd/emu_window')
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 24 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.h | 15 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp | 17 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h | 8 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp | 11 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h | 12 | 
6 files changed, 43 insertions, 44 deletions
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index 19584360c..521209622 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -13,23 +13,24 @@  #include "input_common/sdl/sdl.h"  #include "yuzu_cmd/emu_window/emu_window_sdl2.h" -EmuWindow_SDL2::EmuWindow_SDL2(Core::System& system, bool fullscreen) : system{system} { +EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_) +    : input_subsystem{input_subsystem_} {      if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {          LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting...");          exit(1);      } -    InputCommon::Init(); +    input_subsystem->Initialize();      SDL_SetMainReady();  }  EmuWindow_SDL2::~EmuWindow_SDL2() { -    InputCommon::Shutdown(); +    input_subsystem->Shutdown();      SDL_Quit();  }  void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {      TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); -    InputCommon::GetMotionEmu()->Tilt(x, y); +    input_subsystem->GetMotionEmu()->Tilt(x, y);  }  void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { @@ -41,9 +42,9 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {          }      } else if (button == SDL_BUTTON_RIGHT) {          if (state == SDL_PRESSED) { -            InputCommon::GetMotionEmu()->BeginTilt(x, y); +            input_subsystem->GetMotionEmu()->BeginTilt(x, y);          } else { -            InputCommon::GetMotionEmu()->EndTilt(); +            input_subsystem->GetMotionEmu()->EndTilt();          }      }  } @@ -79,9 +80,9 @@ void EmuWindow_SDL2::OnFingerUp() {  void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) {      if (state == SDL_PRESSED) { -        InputCommon::GetKeyboard()->PressKey(key); +        input_subsystem->GetKeyboard()->PressKey(key);      } else if (state == SDL_RELEASED) { -        InputCommon::GetKeyboard()->ReleaseKey(key); +        input_subsystem->GetKeyboard()->ReleaseKey(key);      }  } @@ -181,9 +182,10 @@ void EmuWindow_SDL2::PollEvents() {      const u32 current_time = SDL_GetTicks();      if (current_time > last_time + 2000) {          const auto results = Core::System::GetInstance().GetAndResetPerfStats(); -        const auto title = fmt::format( -            "yuzu {} | {}-{} | FPS: {:.0f} ({:.0%})", Common::g_build_fullname, -            Common::g_scm_branch, Common::g_scm_desc, results.game_fps, results.emulation_speed); +        const auto title = +            fmt::format("yuzu {} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname, +                        Common::g_scm_branch, Common::g_scm_desc, results.game_fps, +                        results.emulation_speed * 100.0);          SDL_SetWindowTitle(render_window, title.c_str());          last_time = current_time;      } diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h index fffac4252..53d756c3c 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h @@ -14,9 +14,13 @@ namespace Core {  class System;  } +namespace InputCommon { +class InputSubsystem; +} +  class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {  public: -    explicit EmuWindow_SDL2(Core::System& system, bool fullscreen); +    explicit EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem);      ~EmuWindow_SDL2();      /// Polls window events @@ -28,9 +32,6 @@ public:      /// Returns if window is shown (not minimized)      bool IsShown() const override; -    /// Presents the next frame -    virtual void Present() = 0; -  protected:      /// Called by PollEvents when a key is pressed or released.      void OnKeyEvent(int key, u8 state); @@ -62,9 +63,6 @@ protected:      /// Called when a configuration change affects the minimal size of the window      void OnMinimalClientAreaChangeRequest(std::pair<unsigned, unsigned> minimal_size) override; -    /// Instance of the system, used to access renderer for the presentation thread -    Core::System& system; -      /// Is the window still open?      bool is_open = true; @@ -76,4 +74,7 @@ protected:      /// Keeps track of how often to update the title bar during gameplay      u32 last_time = 0; + +    /// Input subsystem to use with this window. +    InputCommon::InputSubsystem* input_subsystem;  }; 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 411e7e647..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,8 +87,8 @@ bool EmuWindow_SDL2_GL::SupportsRequiredGLExtensions() {      return unsupported_ext.empty();  } -EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(Core::System& system, bool fullscreen) -    : EmuWindow_SDL2{system, fullscreen} { +EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem, bool fullscreen) +    : EmuWindow_SDL2{input_subsystem} {      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);      SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); @@ -98,6 +98,9 @@ EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(Core::System& system, bool fullscreen)      SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);      SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);      SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); +    if (Settings::values.renderer_debug) { +        SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); +    }      SDL_GL_SetSwapInterval(0);      std::string window_title = fmt::format("yuzu {} | {}-{}", Common::g_build_fullname, @@ -159,13 +162,3 @@ EmuWindow_SDL2_GL::~EmuWindow_SDL2_GL() {  std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_GL::CreateSharedContext() const {      return std::make_unique<SDLGLContext>();  } - -void EmuWindow_SDL2_GL::Present() { -    SDL_GL_MakeCurrent(render_window, window_context); -    SDL_GL_SetSwapInterval(Settings::values.use_vsync ? 1 : 0); -    while (IsOpen()) { -        system.Renderer().TryPresent(100); -        SDL_GL_SwapWindow(render_window); -    } -    SDL_GL_MakeCurrent(render_window, nullptr); -} 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 48bb41683..dba5c293c 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h @@ -8,13 +8,15 @@  #include "core/frontend/emu_window.h"  #include "yuzu_cmd/emu_window/emu_window_sdl2.h" +namespace InputCommon { +class InputSubsystem; +} +  class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 {  public: -    explicit EmuWindow_SDL2_GL(Core::System& system, bool fullscreen); +    explicit EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem, bool fullscreen);      ~EmuWindow_SDL2_GL(); -    void Present() override; -      std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;  private: 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 f2990910e..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,8 +19,8 @@  #include <SDL.h>  #include <SDL_syswm.h> -EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(Core::System& system, bool fullscreen) -    : EmuWindow_SDL2{system, fullscreen} { +EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem) +    : EmuWindow_SDL2{input_subsystem} {      const std::string window_title = fmt::format("yuzu {} | {}-{} (Vulkan)", Common::g_build_name,                                                   Common::g_scm_branch, Common::g_scm_desc);      render_window = @@ -29,6 +29,7 @@ EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(Core::System& system, bool fullscreen)                           SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);      SDL_SysWMinfo wm; +    SDL_VERSION(&wm.version);      if (SDL_GetWindowWMInfo(render_window, &wm) == SDL_FALSE) {          LOG_CRITICAL(Frontend, "Failed to get information from the window manager");          std::exit(EXIT_FAILURE); @@ -70,9 +71,5 @@ EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(Core::System& system, bool fullscreen)  EmuWindow_SDL2_VK::~EmuWindow_SDL2_VK() = default;  std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_VK::CreateSharedContext() const { -    return nullptr; -} - -void EmuWindow_SDL2_VK::Present() { -    // TODO (bunnei): ImplementMe +    return std::make_unique<DummyContext>();  } 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 b8021ebea..bdfdc3c6f 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h @@ -13,12 +13,16 @@ namespace Core {  class System;  } +namespace InputCommon { +class InputSubsystem; +} +  class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 {  public: -    explicit EmuWindow_SDL2_VK(Core::System& system, bool fullscreen); -    ~EmuWindow_SDL2_VK(); - -    void Present() override; +    explicit EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem); +    ~EmuWindow_SDL2_VK() override;      std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;  }; + +class DummyContext : public Core::Frontend::GraphicsContext {};  | 
