diff options
Diffstat (limited to 'src/yuzu_cmd/emu_window/emu_window_sdl2.cpp')
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 18 |
1 files changed, 10 insertions, 8 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 | ||