diff options
Diffstat (limited to '')
| -rw-r--r-- | src/citra/emu_window/emu_window_glfw.cpp | 2 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.cpp | 2 | ||||
| -rw-r--r-- | src/common/emu_window.cpp | 22 | ||||
| -rw-r--r-- | src/common/emu_window.h | 5 |
4 files changed, 23 insertions, 8 deletions
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp index 997e3bc7d..f879ee7ca 100644 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ b/src/citra/emu_window/emu_window_glfw.cpp | |||
| @@ -31,7 +31,7 @@ void EmuWindow_GLFW::OnMouseButtonEvent(GLFWwindow* win, int button, int action, | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | void EmuWindow_GLFW::OnCursorPosEvent(GLFWwindow* win, double x, double y) { | 33 | void EmuWindow_GLFW::OnCursorPosEvent(GLFWwindow* win, double x, double y) { |
| 34 | GetEmuWindow(win)->TouchMoved(static_cast<unsigned>(x), static_cast<unsigned>(y)); | 34 | GetEmuWindow(win)->TouchMoved(static_cast<unsigned>(std::max(x, 0.0)), static_cast<unsigned>(std::max(y, 0.0))); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | /// Called by GLFW when a key event occurs | 37 | /// Called by GLFW when a key event occurs |
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 66a9e6fba..a7f949411 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp | |||
| @@ -225,7 +225,7 @@ void GRenderWindow::mousePressEvent(QMouseEvent *event) | |||
| 225 | void GRenderWindow::mouseMoveEvent(QMouseEvent *event) | 225 | void GRenderWindow::mouseMoveEvent(QMouseEvent *event) |
| 226 | { | 226 | { |
| 227 | auto pos = event->pos(); | 227 | auto pos = event->pos(); |
| 228 | this->TouchMoved(static_cast<unsigned>(pos.x()), static_cast<unsigned>(pos.y())); | 228 | this->TouchMoved(static_cast<unsigned>(std::max(pos.x(), 0)), static_cast<unsigned>(std::max(pos.y(), 0))); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | void GRenderWindow::mouseReleaseEvent(QMouseEvent *event) | 231 | void GRenderWindow::mouseReleaseEvent(QMouseEvent *event) |
diff --git a/src/common/emu_window.cpp b/src/common/emu_window.cpp index 6516fc633..f5b6c7301 100644 --- a/src/common/emu_window.cpp +++ b/src/common/emu_window.cpp | |||
| @@ -28,6 +28,17 @@ static bool IsWithinTouchscreen(const EmuWindow::FramebufferLayout& layout, unsi | |||
| 28 | framebuffer_x < layout.bottom_screen.right); | 28 | framebuffer_x < layout.bottom_screen.right); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | std::tuple<unsigned,unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) { | ||
| 32 | |||
| 33 | new_x = std::max(new_x, framebuffer_layout.bottom_screen.left); | ||
| 34 | new_x = std::min(new_x, framebuffer_layout.bottom_screen.right-1); | ||
| 35 | |||
| 36 | new_y = std::max(new_y, framebuffer_layout.bottom_screen.top); | ||
| 37 | new_y = std::min(new_y, framebuffer_layout.bottom_screen.bottom-1); | ||
| 38 | |||
| 39 | return std::make_tuple(new_x, new_y); | ||
| 40 | } | ||
| 41 | |||
| 31 | void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { | 42 | void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { |
| 32 | if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) | 43 | if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) |
| 33 | return; | 44 | return; |
| @@ -52,14 +63,13 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { | |||
| 52 | if (!touch_pressed) | 63 | if (!touch_pressed) |
| 53 | return; | 64 | return; |
| 54 | 65 | ||
| 55 | if (IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) | 66 | if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) |
| 56 | TouchPressed(framebuffer_x, framebuffer_y); | 67 | std::tie(framebuffer_x, framebuffer_y) = ClipToTouchScreen(framebuffer_x, framebuffer_y); |
| 57 | else | 68 | |
| 58 | TouchReleased(); | 69 | TouchPressed(framebuffer_x, framebuffer_y); |
| 59 | } | 70 | } |
| 60 | 71 | ||
| 61 | EmuWindow::FramebufferLayout EmuWindow::FramebufferLayout::DefaultScreenLayout(unsigned width, | 72 | EmuWindow::FramebufferLayout EmuWindow::FramebufferLayout::DefaultScreenLayout(unsigned width, unsigned height) { |
| 62 | unsigned height) { | ||
| 63 | 73 | ||
| 64 | ASSERT(width > 0); | 74 | ASSERT(width > 0); |
| 65 | ASSERT(height > 0); | 75 | ASSERT(height > 0); |
diff --git a/src/common/emu_window.h b/src/common/emu_window.h index c8e2de04a..e0fc12a48 100644 --- a/src/common/emu_window.h +++ b/src/common/emu_window.h | |||
| @@ -206,5 +206,10 @@ private: | |||
| 206 | u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320) | 206 | u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320) |
| 207 | u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240) | 207 | u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240) |
| 208 | 208 | ||
| 209 | /** | ||
| 210 | * Clip the provided coordinates to be inside the touchscreen area. | ||
| 211 | */ | ||
| 212 | std::tuple<unsigned,unsigned> ClipToTouchScreen(unsigned new_x, unsigned new_y); | ||
| 213 | |||
| 209 | Service::HID::PadState pad_state; | 214 | Service::HID::PadState pad_state; |
| 210 | }; | 215 | }; |