summaryrefslogtreecommitdiffstats
path: root/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu_cmd/emu_window/emu_window_sdl2.cpp')
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.cpp108
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 @@
#include "core/perf_stats.h"
#include "input_common/keyboard.h"
#include "input_common/main.h"
-#include "input_common/motion_emu.h"
+#include "input_common/mouse/mouse_input.h"
#include "input_common/sdl/sdl.h"
#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
@@ -30,7 +30,7 @@ EmuWindow_SDL2::~EmuWindow_SDL2() {
void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
- input_subsystem->GetMotionEmu()->Tilt(x, y);
+ input_subsystem->GetMouse()->MouseMove(x, y);
}
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) {
}
} else if (button == SDL_BUTTON_RIGHT) {
if (state == SDL_PRESSED) {
- input_subsystem->GetMotionEmu()->BeginTilt(x, y);
+ input_subsystem->GetMouse()->PressButton(x, y, button);
} else {
- input_subsystem->GetMotionEmu()->EndTilt();
+ input_subsystem->GetMouse()->ReleaseButton(button);
}
}
}
@@ -121,62 +121,64 @@ void EmuWindow_SDL2::Fullscreen() {
SDL_MaximizeWindow(render_window);
}
-void EmuWindow_SDL2::PollEvents() {
+void EmuWindow_SDL2::WaitEvent() {
+ // Called on main thread
SDL_Event event;
- // SDL_PollEvent returns 0 when there are no more events in the event queue
- while (SDL_PollEvent(&event)) {
- switch (event.type) {
- case SDL_WINDOWEVENT:
- switch (event.window.event) {
- case SDL_WINDOWEVENT_SIZE_CHANGED:
- case SDL_WINDOWEVENT_RESIZED:
- case SDL_WINDOWEVENT_MAXIMIZED:
- case SDL_WINDOWEVENT_RESTORED:
- OnResize();
- break;
- case SDL_WINDOWEVENT_MINIMIZED:
- case SDL_WINDOWEVENT_EXPOSED:
- is_shown = event.window.event == SDL_WINDOWEVENT_EXPOSED;
- OnResize();
- break;
- case SDL_WINDOWEVENT_CLOSE:
- is_open = false;
- break;
- }
- break;
- case SDL_KEYDOWN:
- case SDL_KEYUP:
- OnKeyEvent(static_cast<int>(event.key.keysym.scancode), event.key.state);
- break;
- case SDL_MOUSEMOTION:
- // ignore if it came from touch
- if (event.button.which != SDL_TOUCH_MOUSEID)
- OnMouseMotion(event.motion.x, event.motion.y);
- break;
- case SDL_MOUSEBUTTONDOWN:
- case SDL_MOUSEBUTTONUP:
- // ignore if it came from touch
- if (event.button.which != SDL_TOUCH_MOUSEID) {
- OnMouseButton(event.button.button, event.button.state, event.button.x,
- event.button.y);
- }
- break;
- case SDL_FINGERDOWN:
- OnFingerDown(event.tfinger.x, event.tfinger.y);
- break;
- case SDL_FINGERMOTION:
- OnFingerMotion(event.tfinger.x, event.tfinger.y);
+ if (!SDL_WaitEvent(&event)) {
+ LOG_CRITICAL(Frontend, "SDL_WaitEvent failed: {}", SDL_GetError());
+ exit(1);
+ }
+
+ switch (event.type) {
+ case SDL_WINDOWEVENT:
+ switch (event.window.event) {
+ case SDL_WINDOWEVENT_SIZE_CHANGED:
+ case SDL_WINDOWEVENT_RESIZED:
+ case SDL_WINDOWEVENT_MAXIMIZED:
+ case SDL_WINDOWEVENT_RESTORED:
+ OnResize();
break;
- case SDL_FINGERUP:
- OnFingerUp();
+ case SDL_WINDOWEVENT_MINIMIZED:
+ case SDL_WINDOWEVENT_EXPOSED:
+ is_shown = event.window.event == SDL_WINDOWEVENT_EXPOSED;
+ OnResize();
break;
- case SDL_QUIT:
+ case SDL_WINDOWEVENT_CLOSE:
is_open = false;
break;
- default:
- break;
}
+ break;
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+ OnKeyEvent(static_cast<int>(event.key.keysym.scancode), event.key.state);
+ break;
+ case SDL_MOUSEMOTION:
+ // ignore if it came from touch
+ if (event.button.which != SDL_TOUCH_MOUSEID)
+ OnMouseMotion(event.motion.x, event.motion.y);
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONUP:
+ // ignore if it came from touch
+ if (event.button.which != SDL_TOUCH_MOUSEID) {
+ OnMouseButton(event.button.button, event.button.state, event.button.x, event.button.y);
+ }
+ break;
+ case SDL_FINGERDOWN:
+ OnFingerDown(event.tfinger.x, event.tfinger.y);
+ break;
+ case SDL_FINGERMOTION:
+ OnFingerMotion(event.tfinger.x, event.tfinger.y);
+ break;
+ case SDL_FINGERUP:
+ OnFingerUp();
+ break;
+ case SDL_QUIT:
+ is_open = false;
+ break;
+ default:
+ break;
}
const u32 current_time = SDL_GetTicks();