From 74367203cf0d9683e47633862549a9d2ba453d83 Mon Sep 17 00:00:00 2001 From: N00byKing Date: Sun, 17 Jun 2018 13:52:16 +0200 Subject: [PATCH] emu_window: Adapt Touchscreen to 3D Settings --- src/core/frontend/emu_window.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index e67394177..5aa98238e 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -60,9 +60,17 @@ EmuWindow::~EmuWindow() { */ static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigned framebuffer_x, unsigned framebuffer_y) { - return ( - framebuffer_y >= layout.bottom_screen.top && framebuffer_y < layout.bottom_screen.bottom && - framebuffer_x >= layout.bottom_screen.left && framebuffer_x < layout.bottom_screen.right); + 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); + } else { + return (framebuffer_y >= layout.bottom_screen.top && + framebuffer_y < layout.bottom_screen.bottom && + framebuffer_x >= layout.bottom_screen.left && + framebuffer_x < layout.bottom_screen.right); + } } std::tuple EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) { @@ -80,9 +88,16 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { return; std::lock_guard guard(touch_state->mutex); - touch_state->touch_x = - static_cast(framebuffer_x - framebuffer_layout.bottom_screen.left) / - (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left); + if (Settings::values.toggle_3d) { + touch_state->touch_x = + static_cast(framebuffer_x - framebuffer_layout.bottom_screen.left / 2) / + (framebuffer_layout.bottom_screen.right / 2 - + framebuffer_layout.bottom_screen.left / 2); + } else { + touch_state->touch_x = + static_cast(framebuffer_x - framebuffer_layout.bottom_screen.left) / + (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left); + } touch_state->touch_y = static_cast(framebuffer_y - framebuffer_layout.bottom_screen.top) / (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top);