Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_filter.cc

Issue 991533002: Port Chromium OS touch noise filtering to Chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_filter.cc
diff --git a/ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_filter.cc b/ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..def0af898ca0f0c20a560b2d8c114250f3edc8cb
--- /dev/null
+++ b/ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_filter.cc
@@ -0,0 +1,46 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_filter.h"
+
+#include <cmath>
+
+#include "base/logging.h"
+#include "base/strings/stringprintf.h"
+
+namespace ui {
+
+namespace {
+
+// The maximum horizontal distance between touches considered aligned.
+int kMaxDistance = 3;
+
+} // namespace
+
+void HorizontallyAlignedTouchNoiseFilter::Filter(
+ const std::vector<InProgressTouchEvdev>& touches,
+ base::TimeDelta time,
+ std::bitset<kNumTouchEvdevSlots>* slots_with_noise) {
+ for (const InProgressTouchEvdev& touch : touches) {
+ // Only consider new touches.
+ if (!touch.touching || touch.was_touching)
+ continue;
+
+ // Check if within kMaxDistance of an existing touch.
+ for (const InProgressTouchEvdev& other_touch : touches) {
+ if (touch.slot == other_touch.slot || !other_touch.touching)
+ continue;
+ if (std::abs(other_touch.x - touch.x) <= kMaxDistance) {
+ VLOG(2) << base::StringPrintf(
+ "Cancel tracking id %d, down at %ld at %f,%f near touch %d at "
+ "%f,%f",
+ touch.tracking_id, time.ToInternalValue(), touch.x, touch.y,
+ other_touch.tracking_id, other_touch.x, other_touch.y);
+ slots_with_noise->set(touch.slot);
+ }
+ }
+ }
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698