From 8792089752f1c8341f31d18e5602c6da2ff0d289 Mon Sep 17 00:00:00 2001 From: Michael Herzberg Date: Sat, 23 Feb 2019 17:37:11 +0000 Subject: [PATCH] Ignore first pair of coordinates, which are occasionally far off. --- src/io/input.cpp | 12 ++++++++---- src/io/input.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/io/input.cpp b/src/io/input.cpp index 943dc96..62929d1 100644 --- a/src/io/input.cpp +++ b/src/io/input.cpp @@ -54,8 +54,8 @@ void gebaar::io::Input::handle_swipe_event_without_coords(libinput_event_gesture { if (begin) { gesture_swipe_event.fingers = libinput_event_gesture_get_finger_count(gev); - } - else { + has_received_updates = false; + } else { double x = gesture_swipe_event.x; double y = gesture_swipe_event.y; int swipe_type = 5; // middle = no swipe @@ -99,8 +99,12 @@ void gebaar::io::Input::handle_swipe_event_without_coords(libinput_event_gesture */ void gebaar::io::Input::handle_swipe_event_with_coords(libinput_event_gesture* gev) { - gesture_swipe_event.x += libinput_event_gesture_get_dx(gev); - gesture_swipe_event.y += libinput_event_gesture_get_dy(gev); + if (has_received_updates) { + gesture_swipe_event.x += libinput_event_gesture_get_dx(gev); + gesture_swipe_event.y += libinput_event_gesture_get_dy(gev); + } else { + has_received_updates = true; + } } /** diff --git a/src/io/input.h b/src/io/input.h index b40d61f..f7299c2 100644 --- a/src/io/input.h +++ b/src/io/input.h @@ -44,6 +44,8 @@ namespace gebaar::io { private: std::shared_ptr config; + bool has_received_updates; + struct libinput* libinput; struct libinput_event* libinput_event; struct udev* udev;