From 3556ecddbef0f2fb29a1969f75a9919f7a2d3cfe Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Mon, 20 Jul 2020 10:07:27 +0300 Subject: [PATCH] Mouse move with collisions --- applications/gui2/src/modules/camera.cpp | 16 +++++++++------- .../src/sources/screencapture/screencapture.cpp | 8 ++++---- components/streams/src/renderers/collisions.cpp | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/applications/gui2/src/modules/camera.cpp b/applications/gui2/src/modules/camera.cpp index 5d0199152..1bf50c6a9 100644 --- a/applications/gui2/src/modules/camera.cpp +++ b/applications/gui2/src/modules/camera.cpp @@ -370,13 +370,15 @@ void Camera::sendPose(const Eigen::Matrix4d &pose) { } void Camera::touch(int id, ftl::codecs::TouchType t, int x, int y, float d, int strength) { - UNIQUE_LOCK(mtx_, lk); - point_.id = id; - point_.type = t; - point_.x = x; - point_.y = y; - point_.d = d; - point_.strength = strength; //std::max((unsigned char)strength, point_.strength); + if (value("enable_touch", false)) { + UNIQUE_LOCK(mtx_, lk); + point_.id = id; + point_.type = t; + point_.x = x; + point_.y = y; + point_.d = d; + point_.strength = strength; //std::max((unsigned char)strength, point_.strength); + } // TODO: Check for touch capability first /*if (auto ptr = std::atomic_load(&latest_)) { diff --git a/components/rgbd-sources/src/sources/screencapture/screencapture.cpp b/components/rgbd-sources/src/sources/screencapture/screencapture.cpp index b893cd049..5c9ca286b 100644 --- a/components/rgbd-sources/src/sources/screencapture/screencapture.cpp +++ b/components/rgbd-sources/src/sources/screencapture/screencapture.cpp @@ -251,8 +251,8 @@ void ScreenCapture::_move(int x, int y) { #ifdef HAVE_X11 auto &s = *impl_state_; - //XTestFakeMotionEvent (s.display, 0, x, y, CurrentTime); - //XSync(s.display, 0); + XTestFakeMotionEvent (s.display, 0, x, y, CurrentTime); + XSync(s.display, 0); #endif } @@ -331,9 +331,9 @@ bool ScreenCapture::retrieve(ftl::rgbd::Frame &frame) { // If there is a touch, render it. if (primary_touch_.id >= 0) { if (pressed_) { - cv::circle(img, cv::Point(primary_touch_.x, primary_touch_.y), 5, cv::Scalar(0,0,255), 3); + cv::circle(img, cv::Point(primary_touch_.x, primary_touch_.y), 10, cv::Scalar(0,0,255), 5); } else { - cv::circle(img, cv::Point(primary_touch_.x, primary_touch_.y), 3, cv::Scalar(0,0,255)); + cv::circle(img, cv::Point(primary_touch_.x, primary_touch_.y), 10, cv::Scalar(0,0,255), 3); } } } diff --git a/components/streams/src/renderers/collisions.cpp b/components/streams/src/renderers/collisions.cpp index a5e21c7a0..ddb5c2d5b 100644 --- a/components/streams/src/renderers/collisions.cpp +++ b/components/streams/src/renderers/collisions.cpp @@ -62,7 +62,7 @@ void ftl::render::collision2touch(const ftl::rgbd::Frame &rgbdframe, touch.x = pt.x; touch.y = pt.y; touch.type = ftl::codecs::TouchType::COLLISION; - touch.strength = (cam.maxDepth - campos.z <= tmin) ? 255 : 0; + touch.strength = (std::abs(campos.z - cam.maxDepth) <= tmin) ? 255 : 0; touch.d = campos.z; } } -- GitLab