diff options
Diffstat (limited to 'src/yuzu_cmd')
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 2 | ||||
| -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 | ||||
| -rw-r--r-- | src/yuzu_cmd/yuzu.cpp | 9 |
8 files changed, 44 insertions, 19 deletions
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 8a63fd191..e9f1c6500 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -288,6 +288,8 @@ void Config::ReadValues() { | |||
| 288 | Settings::values.debug_pad_analogs[i] = default_param; | 288 | Settings::values.debug_pad_analogs[i] = default_param; |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | Settings::values.vibration_enabled = | ||
| 292 | sdl2_config->GetBoolean("ControlsGeneral", "vibration_enabled", true); | ||
| 291 | Settings::values.touchscreen.enabled = | 293 | Settings::values.touchscreen.enabled = |
| 292 | sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true); | 294 | sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true); |
| 293 | Settings::values.touchscreen.device = | 295 | 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 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; |
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 8efe49390..4f00c804d 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp | |||
| @@ -23,12 +23,14 @@ | |||
| 23 | #include "common/telemetry.h" | 23 | #include "common/telemetry.h" |
| 24 | #include "core/core.h" | 24 | #include "core/core.h" |
| 25 | #include "core/crypto/key_manager.h" | 25 | #include "core/crypto/key_manager.h" |
| 26 | #include "core/file_sys/registered_cache.h" | ||
| 26 | #include "core/file_sys/vfs_real.h" | 27 | #include "core/file_sys/vfs_real.h" |
| 27 | #include "core/gdbstub/gdbstub.h" | 28 | #include "core/gdbstub/gdbstub.h" |
| 28 | #include "core/hle/service/filesystem/filesystem.h" | 29 | #include "core/hle/service/filesystem/filesystem.h" |
| 29 | #include "core/loader/loader.h" | 30 | #include "core/loader/loader.h" |
| 30 | #include "core/settings.h" | 31 | #include "core/settings.h" |
| 31 | #include "core/telemetry_session.h" | 32 | #include "core/telemetry_session.h" |
| 33 | #include "input_common/main.h" | ||
| 32 | #include "video_core/renderer_base.h" | 34 | #include "video_core/renderer_base.h" |
| 33 | #include "yuzu_cmd/config.h" | 35 | #include "yuzu_cmd/config.h" |
| 34 | #include "yuzu_cmd/emu_window/emu_window_sdl2.h" | 36 | #include "yuzu_cmd/emu_window/emu_window_sdl2.h" |
| @@ -37,8 +39,6 @@ | |||
| 37 | #include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h" | 39 | #include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h" |
| 38 | #endif | 40 | #endif |
| 39 | 41 | ||
| 40 | #include "core/file_sys/registered_cache.h" | ||
| 41 | |||
| 42 | #ifdef _WIN32 | 42 | #ifdef _WIN32 |
| 43 | // windows.h needs to be included before shellapi.h | 43 | // windows.h needs to be included before shellapi.h |
| 44 | #include <windows.h> | 44 | #include <windows.h> |
| @@ -179,15 +179,16 @@ int main(int argc, char** argv) { | |||
| 179 | Settings::Apply(); | 179 | Settings::Apply(); |
| 180 | 180 | ||
| 181 | Core::System& system{Core::System::GetInstance()}; | 181 | Core::System& system{Core::System::GetInstance()}; |
| 182 | InputCommon::InputSubsystem input_subsystem; | ||
| 182 | 183 | ||
| 183 | std::unique_ptr<EmuWindow_SDL2> emu_window; | 184 | std::unique_ptr<EmuWindow_SDL2> emu_window; |
| 184 | switch (Settings::values.renderer_backend.GetValue()) { | 185 | switch (Settings::values.renderer_backend.GetValue()) { |
| 185 | case Settings::RendererBackend::OpenGL: | 186 | case Settings::RendererBackend::OpenGL: |
| 186 | emu_window = std::make_unique<EmuWindow_SDL2_GL>(system, fullscreen); | 187 | emu_window = std::make_unique<EmuWindow_SDL2_GL>(system, fullscreen, &input_subsystem); |
| 187 | break; | 188 | break; |
| 188 | case Settings::RendererBackend::Vulkan: | 189 | case Settings::RendererBackend::Vulkan: |
| 189 | #ifdef HAS_VULKAN | 190 | #ifdef HAS_VULKAN |
| 190 | emu_window = std::make_unique<EmuWindow_SDL2_VK>(system, fullscreen); | 191 | emu_window = std::make_unique<EmuWindow_SDL2_VK>(system, fullscreen, &input_subsystem); |
| 191 | break; | 192 | break; |
| 192 | #else | 193 | #else |
| 193 | LOG_CRITICAL(Frontend, "Vulkan backend has not been compiled!"); | 194 | LOG_CRITICAL(Frontend, "Vulkan backend has not been compiled!"); |