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.
5 #ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_NOISE_TOUCH_NOISE_FINDER_H_
6 #define UI_EVENTS_OZONE_EVDEV_TOUCH_NOISE_TOUCH_NOISE_FINDER_H_
11 #include "base/basictypes.h"
12 #include "base/time/time.h"
13 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
14 #include "ui/events/ozone/evdev/touch_evdev_types.h"
17 class TouchNoiseFilter
;
19 // Finds touches which are likely touch noise.
20 class EVENTS_OZONE_EVDEV_EXPORT TouchNoiseFinder
{
25 // Updates which ABS_MT_SLOTs are noise. |touches| should contain all of the
26 // in-progress touches at |time| (including noisy touches).
27 // |touches| should have at most one entry per ABS_MT_SLOT.
28 void HandleTouches(const std::vector
<InProgressTouchEvdev
>& touches
,
29 base::TimeDelta time
);
31 // Returns whether the in-progress touch at ABS_MT_SLOT |slot| is noise.
32 bool SlotHasNoise(size_t slot
) const;
35 // Records how frequently noisy touches occur to UMA.
36 void RecordUMA(bool had_noise
, base::TimeDelta time
);
38 friend class TouchEventConverterEvdevTouchNoiseTest
;
40 // The slots which are noise.
41 std::bitset
<kNumTouchEvdevSlots
> slots_with_noise_
;
43 // The time of the previous noise occurence in any of the slots.
44 base::TimeDelta last_noise_time_
;
46 std::vector
<TouchNoiseFilter
*> filters_
;
48 DISALLOW_COPY_AND_ASSIGN(TouchNoiseFinder
);
53 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_NOISE_TOUCH_NOISE_FINDER_H_