diff options
| author | 2021-01-10 22:09:56 -0700 | |
|---|---|---|
| committer | 2021-01-10 22:09:56 -0700 | |
| commit | 7a3c884e39fccfbb498b855080bffabc9ce2e7f1 (patch) | |
| tree | 5056f9406dec188439cb0deb87603498243a9412 /src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | |
| parent | More forgetting... duh (diff) | |
| parent | Merge pull request #5229 from Morph1984/fullscreen-opt (diff) | |
| download | yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.gz yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.xz yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.zip | |
Merge remote-tracking branch 'upstream/master' into int-flags
Diffstat (limited to 'src/yuzu_cmd/emu_window/emu_window_sdl2.cpp')
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 108 |
1 files changed, 55 insertions, 53 deletions
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index 521209622..e32bed5e6 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "core/perf_stats.h" | 9 | #include "core/perf_stats.h" |
| 10 | #include "input_common/keyboard.h" | 10 | #include "input_common/keyboard.h" |
| 11 | #include "input_common/main.h" | 11 | #include "input_common/main.h" |
| 12 | #include "input_common/motion_emu.h" | 12 | #include "input_common/mouse/mouse_input.h" |
| 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 | ||
| @@ -30,7 +30,7 @@ EmuWindow_SDL2::~EmuWindow_SDL2() { | |||
| 30 | 30 | ||
| 31 | void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { | 31 | void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { |
| 32 | TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); | 32 | TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); |
| 33 | input_subsystem->GetMotionEmu()->Tilt(x, y); | 33 | input_subsystem->GetMouse()->MouseMove(x, y); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { | 36 | void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { |
| @@ -42,9 +42,9 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) { | |||
| 42 | } | 42 | } |
| 43 | } else if (button == SDL_BUTTON_RIGHT) { | 43 | } else if (button == SDL_BUTTON_RIGHT) { |
| 44 | if (state == SDL_PRESSED) { | 44 | if (state == SDL_PRESSED) { |
| 45 | input_subsystem->GetMotionEmu()->BeginTilt(x, y); | 45 | input_subsystem->GetMouse()->PressButton(x, y, button); |
| 46 | } else { | 46 | } else { |
| 47 | input_subsystem->GetMotionEmu()->EndTilt(); | 47 | input_subsystem->GetMouse()->ReleaseButton(button); |
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| @@ -121,62 +121,64 @@ void EmuWindow_SDL2::Fullscreen() { | |||
| 121 | SDL_MaximizeWindow(render_window); | 121 | SDL_MaximizeWindow(render_window); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | void EmuWindow_SDL2::PollEvents() { | 124 | void EmuWindow_SDL2::WaitEvent() { |
| 125 | // Called on main thread | ||
| 125 | SDL_Event event; | 126 | SDL_Event event; |
| 126 | 127 | ||
| 127 | // SDL_PollEvent returns 0 when there are no more events in the event queue | 128 | if (!SDL_WaitEvent(&event)) { |
| 128 | while (SDL_PollEvent(&event)) { | 129 | LOG_CRITICAL(Frontend, "SDL_WaitEvent failed: {}", SDL_GetError()); |
| 129 | switch (event.type) { | 130 | exit(1); |
| 130 | case SDL_WINDOWEVENT: | 131 | } |
| 131 | switch (event.window.event) { | 132 | |
| 132 | case SDL_WINDOWEVENT_SIZE_CHANGED: | 133 | switch (event.type) { |
| 133 | case SDL_WINDOWEVENT_RESIZED: | 134 | case SDL_WINDOWEVENT: |
| 134 | case SDL_WINDOWEVENT_MAXIMIZED: | 135 | switch (event.window.event) { |
| 135 | case SDL_WINDOWEVENT_RESTORED: | 136 | case SDL_WINDOWEVENT_SIZE_CHANGED: |
| 136 | OnResize(); | 137 | case SDL_WINDOWEVENT_RESIZED: |
| 137 | break; | 138 | case SDL_WINDOWEVENT_MAXIMIZED: |
| 138 | case SDL_WINDOWEVENT_MINIMIZED: | 139 | case SDL_WINDOWEVENT_RESTORED: |
| 139 | case SDL_WINDOWEVENT_EXPOSED: | 140 | OnResize(); |
| 140 | is_shown = event.window.event == SDL_WINDOWEVENT_EXPOSED; | ||
| 141 | OnResize(); | ||
| 142 | break; | ||
| 143 | case SDL_WINDOWEVENT_CLOSE: | ||
| 144 | is_open = false; | ||
| 145 | break; | ||
| 146 | } | ||
| 147 | break; | ||
| 148 | case SDL_KEYDOWN: | ||
| 149 | case SDL_KEYUP: | ||
| 150 | OnKeyEvent(static_cast<int>(event.key.keysym.scancode), event.key.state); | ||
| 151 | break; | ||
| 152 | case SDL_MOUSEMOTION: | ||
| 153 | // ignore if it came from touch | ||
| 154 | if (event.button.which != SDL_TOUCH_MOUSEID) | ||
| 155 | OnMouseMotion(event.motion.x, event.motion.y); | ||
| 156 | break; | ||
| 157 | case SDL_MOUSEBUTTONDOWN: | ||
| 158 | case SDL_MOUSEBUTTONUP: | ||
| 159 | // ignore if it came from touch | ||
| 160 | if (event.button.which != SDL_TOUCH_MOUSEID) { | ||
| 161 | OnMouseButton(event.button.button, event.button.state, event.button.x, | ||
| 162 | event.button.y); | ||
| 163 | } | ||
| 164 | break; | ||
| 165 | case SDL_FINGERDOWN: | ||
| 166 | OnFingerDown(event.tfinger.x, event.tfinger.y); | ||
| 167 | break; | ||
| 168 | case SDL_FINGERMOTION: | ||
| 169 | OnFingerMotion(event.tfinger.x, event.tfinger.y); | ||
| 170 | break; | 141 | break; |
| 171 | case SDL_FINGERUP: | 142 | case SDL_WINDOWEVENT_MINIMIZED: |
| 172 | OnFingerUp(); | 143 | case SDL_WINDOWEVENT_EXPOSED: |
| 144 | is_shown = event.window.event == SDL_WINDOWEVENT_EXPOSED; | ||
| 145 | OnResize(); | ||
| 173 | break; | 146 | break; |
| 174 | case SDL_QUIT: | 147 | case SDL_WINDOWEVENT_CLOSE: |
| 175 | is_open = false; | 148 | is_open = false; |
| 176 | break; | 149 | break; |
| 177 | default: | ||
| 178 | break; | ||
| 179 | } | 150 | } |
| 151 | break; | ||
| 152 | case SDL_KEYDOWN: | ||
| 153 | case SDL_KEYUP: | ||
| 154 | OnKeyEvent(static_cast<int>(event.key.keysym.scancode), event.key.state); | ||
| 155 | break; | ||
| 156 | case SDL_MOUSEMOTION: | ||
| 157 | // ignore if it came from touch | ||
| 158 | if (event.button.which != SDL_TOUCH_MOUSEID) | ||
| 159 | OnMouseMotion(event.motion.x, event.motion.y); | ||
| 160 | break; | ||
| 161 | case SDL_MOUSEBUTTONDOWN: | ||
| 162 | case SDL_MOUSEBUTTONUP: | ||
| 163 | // ignore if it came from touch | ||
| 164 | if (event.button.which != SDL_TOUCH_MOUSEID) { | ||
| 165 | OnMouseButton(event.button.button, event.button.state, event.button.x, event.button.y); | ||
| 166 | } | ||
| 167 | break; | ||
| 168 | case SDL_FINGERDOWN: | ||
| 169 | OnFingerDown(event.tfinger.x, event.tfinger.y); | ||
| 170 | break; | ||
| 171 | case SDL_FINGERMOTION: | ||
| 172 | OnFingerMotion(event.tfinger.x, event.tfinger.y); | ||
| 173 | break; | ||
| 174 | case SDL_FINGERUP: | ||
| 175 | OnFingerUp(); | ||
| 176 | break; | ||
| 177 | case SDL_QUIT: | ||
| 178 | is_open = false; | ||
| 179 | break; | ||
| 180 | default: | ||
| 181 | break; | ||
| 180 | } | 182 | } |
| 181 | 183 | ||
| 182 | const u32 current_time = SDL_GetTicks(); | 184 | const u32 current_time = SDL_GetTicks(); |