OLD | NEW |
(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 #include "ui/gfx/geometry/point_f.h" |
| 12 |
| 13 namespace ui { |
| 14 |
| 15 namespace { |
| 16 |
| 17 // The maximum horizontal distance between touches considered aligned. |
| 18 int kMaxDistance = 3; |
| 19 |
| 20 } // namespace |
| 21 |
| 22 void HorizontallyAlignedTouchNoiseFilter::FilterFrame(Frame* previous, |
| 23 Frame* current) { |
| 24 for (size_t slot = 0; slot < kNumSlots; ++slot) { |
| 25 Finger* cur = ¤t->fingers[slot]; |
| 26 Finger* prev = &previous->fingers[slot]; |
| 27 |
| 28 bool arrived = prev->tracking_id == -1 && cur->tracking_id >= 0; |
| 29 if (!arrived) |
| 30 continue; |
| 31 |
| 32 // Check if within kMaxDistance of an existing touch. |
| 33 for (size_t i = 0; i < kNumSlots; ++i) { |
| 34 if (i == slot || current->fingers[i].tracking_id == -1) |
| 35 continue; |
| 36 if (std::abs(current->fingers[i].location.x() - cur->location.x()) <= |
| 37 kMaxDistance) { |
| 38 VLOG(2) << base::StringPrintf( |
| 39 "Cancel tracking id %d, down at %ld at %s near touch %d at %s", |
| 40 cur->tracking_id, current->timestamp.ToInternalValue(), |
| 41 cur->location.ToString().c_str(), current->fingers[i].tracking_id, |
| 42 current->fingers[i].location.ToString().c_str()); |
| 43 cur->canceled = true; |
| 44 } |
| 45 } |
| 46 } |
| 47 } |
| 48 |
| 49 } // namespace ui |
OLD | NEW |