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

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..0c0e7bad7065610e72043c406440f4585da2a9ed
--- /dev/null
+++ b/ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_filter.cc
@@ -0,0 +1,49 @@
+// 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"
+#include "ui/gfx/geometry/point_f.h"
+
+namespace ui {
+
+namespace {
+
+// The maximum horizontal distance between touches considered aligned.
+int kMaxDistance = 3;
+
+} // namespace
+
+void HorizontallyAlignedTouchNoiseFilter::FilterFrame(Frame* previous,
+ Frame* current) {
+ for (size_t slot = 0; slot < kNumSlots; ++slot) {
+ Finger* cur = &current->fingers[slot];
+ Finger* prev = &previous->fingers[slot];
+
+ bool arrived = prev->tracking_id == -1 && cur->tracking_id >= 0;
+ if (!arrived)
+ continue;
+
+ // Check if within kMaxDistance of an existing touch.
+ for (size_t i = 0; i < kNumSlots; ++i) {
+ if (i == slot || current->fingers[i].tracking_id == -1)
+ continue;
+ if (std::abs(current->fingers[i].location.x() - cur->location.x()) <=
+ kMaxDistance) {
+ VLOG(2) << base::StringPrintf(
+ "Cancel tracking id %d, down at %ld at %s near touch %d at %s",
+ cur->tracking_id, current->timestamp.ToInternalValue(),
+ cur->location.ToString().c_str(), current->fingers[i].tracking_id,
+ current->fingers[i].location.ToString().c_str());
+ cur->canceled = true;
+ }
+ }
+ }
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698