From 602334cb1eb3c33072d549d2caca41a00fe3f54c Mon Sep 17 00:00:00 2001 From: Carl Kenner Date: Thu, 24 Jan 2019 00:16:40 +1030 Subject: [PATCH] Fix mouse touchscreen in SBS 3D mode. You can now click or drag on either eye's touchscreen. --- src/core/frontend/emu_window.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 5aa98238e..fb84eff3a 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -63,8 +63,10 @@ static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigne if (Settings::values.toggle_3d) { return (framebuffer_y >= layout.bottom_screen.top && framebuffer_y < layout.bottom_screen.bottom && - framebuffer_x >= layout.bottom_screen.left / 2 && - framebuffer_x < layout.bottom_screen.right / 2); + ((framebuffer_x >= layout.bottom_screen.left / 2 && + framebuffer_x < layout.bottom_screen.right / 2) || + (framebuffer_x >= (layout.bottom_screen.left / 2) + (layout.width / 2) && + framebuffer_x < (layout.bottom_screen.right / 2) + (layout.width / 2)))); } else { return (framebuffer_y >= layout.bottom_screen.top && framebuffer_y < layout.bottom_screen.bottom && @@ -74,8 +76,15 @@ static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigne } std::tuple EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) { - new_x = std::max(new_x, framebuffer_layout.bottom_screen.left); - new_x = std::min(new_x, framebuffer_layout.bottom_screen.right - 1); + if (Settings::values.toggle_3d) { + if (new_x >= framebuffer_layout.width / 2) + new_x -= framebuffer_layout.width / 2; + new_x = std::max(new_x, framebuffer_layout.bottom_screen.left / 2); + new_x = std::min(new_x, framebuffer_layout.bottom_screen.right / 2 - 1); + } else { + new_x = std::max(new_x, framebuffer_layout.bottom_screen.left); + new_x = std::min(new_x, framebuffer_layout.bottom_screen.right - 1); + } new_y = std::max(new_y, framebuffer_layout.bottom_screen.top); new_y = std::min(new_y, framebuffer_layout.bottom_screen.bottom - 1); @@ -87,6 +96,8 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) return; + if (Settings::values.toggle_3d && framebuffer_x >= framebuffer_layout.width / 2) + framebuffer_x -= framebuffer_layout.width / 2; std::lock_guard guard(touch_state->mutex); if (Settings::values.toggle_3d) { touch_state->touch_x =