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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_fil ter.h"
6
7 #include <cmath>
8
9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h"
11
12 namespace ui {
13
14 namespace {
15
16 // The maximum horizontal distance between touches considered aligned.
17 int kMaxDistance = 3;
18
19 } // namespace
20
21 void HorizontallyAlignedTouchNoiseFilter::Filter(
22 const std::vector<InProgressTouchEvdev>& touches,
23 base::TimeDelta time,
24 std::bitset<kNumTouchEvdevSlots>* slots_with_noise) {
25 for (const InProgressTouchEvdev& touch : touches) {
26 // Only consider new touches.
27 if (!touch.touching || touch.was_touching)
28 continue;
29
30 // Check if within kMaxDistance of an existing touch.
31 for (const InProgressTouchEvdev& other_touch : touches) {
32 if (touch.slot == other_touch.slot || !other_touch.touching)
33 continue;
34 if (std::abs(other_touch.x - touch.x) <= kMaxDistance) {
35 VLOG(2) << base::StringPrintf(
36 "Cancel tracking id %d, down at %ld at %f,%f near touch %d at "
37 "%f,%f",
38 touch.tracking_id, time.ToInternalValue(), touch.x, touch.y,
39 other_touch.tracking_id, other_touch.x, other_touch.y);
40 slots_with_noise->set(touch.slot);
41 }
42 }
43 }
44 }
45
46 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698