diff options
Diffstat (limited to 'src/yuzu_cmd/emu_window')
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 18 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.h | 10 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp | 5 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h | 7 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp | 5 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h | 7 |
6 files changed, 37 insertions, 15 deletions
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index e5e684206..a804d5185 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | |||
| @@ -13,23 +13,25 @@ | |||
| 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 | ||
| 16 | EmuWindow_SDL2::EmuWindow_SDL2(Core::System& system, bool fullscreen) : system{system} { | 16 | EmuWindow_SDL2::EmuWindow_SDL2(Core::System& system, bool fullscreen, |
| 17 | InputCommon::InputSubsystem* input_subsystem_) | ||
| 18 | : system{system}, input_subsystem{input_subsystem_} { | ||
| 17 | if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { | 19 | if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { |
| 18 | LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting..."); | 20 | LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting..."); |
| 19 | exit(1); | 21 | exit(1); |
| 20 | } | 22 | } |
| 21 | InputCommon::Init(); | 23 | input_subsystem->Initialize(); |
| 22 | SDL_SetMainReady(); | 24 | SDL_SetMainReady(); |
| 23 | } | 25 | } |
| 24 | 26 | ||
| 25 | EmuWindow_SDL2::~EmuWindow_SDL2() { | 27 | EmuWindow_SDL2::~EmuWindow_SDL2() { |
| 26 | InputCommon::Shutdown(); | 28 | input_subsystem->Shutdown(); |
| 27 | SDL_Quit(); | 29 | SDL_Quit(); |
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { | 32 | void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { |
| 31 | TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); | 33 | TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); |
| 32 | InputCommon::GetMotionEmu()->Tilt(x, y); | 34 | input_subsystem->GetMotionEmu()->Tilt(x, y); |
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { | 37 | void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { |
| @@ -41,9 +43,9 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { | |||
| 41 | } | 43 | } |
| 42 | } else if (button == SDL_BUTTON_RIGHT) { | 44 | } else if (button == SDL_BUTTON_RIGHT) { |
| 43 | if (state == SDL_PRESSED) { | 45 | if (state == SDL_PRESSED) { |
| 44 | InputCommon::GetMotionEmu()->BeginTilt(x, y); | 46 | input_subsystem->GetMotionEmu()->BeginTilt(x, y); |
| 45 | } else { | 47 | } else { |
| 46 | InputCommon::GetMotionEmu()->EndTilt(); | 48 | input_subsystem->GetMotionEmu()->EndTilt(); |
| 47 | } | 49 | } |
| 48 | } | 50 | } |
| 49 | } | 51 | } |
| @@ -79,9 +81,9 @@ void EmuWindow_SDL2::OnFingerUp() { | |||
| 79 | 81 | ||
| 80 | void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { | 82 | void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) { |
| 81 | if (state == SDL_PRESSED) { | 83 | if (state == SDL_PRESSED) { |
| 82 | InputCommon::GetKeyboard()->PressKey(key); | 84 | input_subsystem->GetKeyboard()->PressKey(key); |
| 83 | } else if (state == SDL_RELEASED) { | 85 | } else if (state == SDL_RELEASED) { |
| 84 | InputCommon::GetKeyboard()->ReleaseKey(key); | 86 | input_subsystem->GetKeyboard()->ReleaseKey(key); |
| 85 | } | 87 | } |
| 86 | } | 88 | } |
| 87 | 89 | ||
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h index fffac4252..82750ffec 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h | |||
| @@ -14,9 +14,14 @@ namespace Core { | |||
| 14 | class System; | 14 | class System; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | namespace InputCommon { | ||
| 18 | class InputSubsystem; | ||
| 19 | } | ||
| 20 | |||
| 17 | class EmuWindow_SDL2 : public Core::Frontend::EmuWindow { | 21 | class EmuWindow_SDL2 : public Core::Frontend::EmuWindow { |
| 18 | public: | 22 | public: |
| 19 | explicit EmuWindow_SDL2(Core::System& system, bool fullscreen); | 23 | explicit EmuWindow_SDL2(Core::System& system, bool fullscreen, |
| 24 | InputCommon::InputSubsystem* input_subsystem); | ||
| 20 | ~EmuWindow_SDL2(); | 25 | ~EmuWindow_SDL2(); |
| 21 | 26 | ||
| 22 | /// Polls window events | 27 | /// Polls window events |
| @@ -76,4 +81,7 @@ protected: | |||
| 76 | 81 | ||
| 77 | /// Keeps track of how often to update the title bar during gameplay | 82 | /// Keeps track of how often to update the title bar during gameplay |
| 78 | u32 last_time = 0; | 83 | u32 last_time = 0; |
| 84 | |||
| 85 | /// Input subsystem to use with this window. | ||
| 86 | InputCommon::InputSubsystem* input_subsystem; | ||
| 79 | }; | 87 | }; |
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 e78025737..881b67a76 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,9 @@ bool EmuWindow_SDL2_GL::SupportsRequiredGLExtensions() { | |||
| 87 | return unsupported_ext.empty(); | 87 | return unsupported_ext.empty(); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(Core::System& system, bool fullscreen) | 90 | EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(Core::System& system, bool fullscreen, |
| 91 | : EmuWindow_SDL2{system, fullscreen} { | 91 | InputCommon::InputSubsystem* input_subsystem) |
| 92 | : EmuWindow_SDL2{system, fullscreen, input_subsystem} { | ||
| 92 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); | 93 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); |
| 93 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); | 94 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); |
| 94 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); | 95 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); |
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..732a64edd 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h | |||
| @@ -8,9 +8,14 @@ | |||
| 8 | #include "core/frontend/emu_window.h" | 8 | #include "core/frontend/emu_window.h" |
| 9 | #include "yuzu_cmd/emu_window/emu_window_sdl2.h" | 9 | #include "yuzu_cmd/emu_window/emu_window_sdl2.h" |
| 10 | 10 | ||
| 11 | namespace InputCommon { | ||
| 12 | class InputSubsystem; | ||
| 13 | } | ||
| 14 | |||
| 11 | class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 { | 15 | class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 { |
| 12 | public: | 16 | public: |
| 13 | explicit EmuWindow_SDL2_GL(Core::System& system, bool fullscreen); | 17 | explicit EmuWindow_SDL2_GL(Core::System& system, bool fullscreen, |
| 18 | InputCommon::InputSubsystem* input_subsystem); | ||
| 14 | ~EmuWindow_SDL2_GL(); | 19 | ~EmuWindow_SDL2_GL(); |
| 15 | 20 | ||
| 16 | void Present() override; | 21 | void Present() override; |
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 cb8e68a39..53491f86e 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,9 @@ | |||
| 19 | #include <SDL.h> | 19 | #include <SDL.h> |
| 20 | #include <SDL_syswm.h> | 20 | #include <SDL_syswm.h> |
| 21 | 21 | ||
| 22 | EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(Core::System& system, bool fullscreen) | 22 | EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(Core::System& system, bool fullscreen, |
| 23 | : EmuWindow_SDL2{system, fullscreen} { | 23 | InputCommon::InputSubsystem* input_subsystem) |
| 24 | : EmuWindow_SDL2{system, fullscreen, input_subsystem} { | ||
| 24 | const std::string window_title = fmt::format("yuzu {} | {}-{} (Vulkan)", Common::g_build_name, | 25 | const std::string window_title = fmt::format("yuzu {} | {}-{} (Vulkan)", Common::g_build_name, |
| 25 | Common::g_scm_branch, Common::g_scm_desc); | 26 | Common::g_scm_branch, Common::g_scm_desc); |
| 26 | render_window = | 27 | render_window = |
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 77a6ca72b..f99704d4c 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h | |||
| @@ -13,9 +13,14 @@ namespace Core { | |||
| 13 | class System; | 13 | class System; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | namespace InputCommon { | ||
| 17 | class InputSubsystem; | ||
| 18 | } | ||
| 19 | |||
| 16 | class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 { | 20 | class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 { |
| 17 | public: | 21 | public: |
| 18 | explicit EmuWindow_SDL2_VK(Core::System& system, bool fullscreen); | 22 | explicit EmuWindow_SDL2_VK(Core::System& system, bool fullscreen, |
| 23 | InputCommon::InputSubsystem* input_subsystem); | ||
| 19 | ~EmuWindow_SDL2_VK(); | 24 | ~EmuWindow_SDL2_VK(); |
| 20 | 25 | ||
| 21 | void Present() override; | 26 | void Present() override; |