summaryrefslogtreecommitdiff
path: root/src/common/emu_window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/emu_window.cpp')
-rw-r--r--src/common/emu_window.cpp22
1 files changed, 16 insertions, 6 deletions
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
31std::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
31void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { 42void 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
61EmuWindow::FramebufferLayout EmuWindow::FramebufferLayout::DefaultScreenLayout(unsigned width, 72EmuWindow::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);