summaryrefslogtreecommitdiff
path: root/chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_report_filter.h
blob: 1c7e28b8e5a881551c1aca8704ef8ced9759322f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2019 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.

#ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_NEURAL_STYLUS_PALM_REPORT_FILTER_H_
#define UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_NEURAL_STYLUS_PALM_REPORT_FILTER_H_

#include <bitset>
#include <vector>

#include "base/component_export.h"
#include "base/time/time.h"
#include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/touch_evdev_types.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter.h"
#include "ui/events/ozone/evdev/touch_filter/shared_palm_detection_filter_state.h"

namespace ui {

// A palm detection filter that doesn't change any reports, but adds UMA reports
// based on the shared palm state. Otherwise behaves identically to
// OpenPalmDetectionFilter.
class COMPONENT_EXPORT(EVDEV) NeuralStylusReportFilter
    : public PalmDetectionFilter {
 public:
  explicit NeuralStylusReportFilter(
      SharedPalmDetectionFilterState* shared_palm_state);
  ~NeuralStylusReportFilter() override;

  static bool CompatibleWithNeuralStylusReportFilter(
      const EventDeviceInfo& devinfo);

  void Filter(const std::vector<InProgressTouchEvdev>& touches,
              base::TimeTicks time,
              std::bitset<kNumTouchEvdevSlots>* slots_to_hold,
              std::bitset<kNumTouchEvdevSlots>* slots_to_suppress) override;

  static const char kFilterName[];
  static const char kNeuralFingerAge[];
  static const char kNeuralPalmAge[];
  static const char kNeuralPalmTouchCount[];
  std::string FilterNameForTesting() const override;

 private:
  bool previous_update_ = false;
  DISALLOW_COPY_AND_ASSIGN(NeuralStylusReportFilter);
};

}  // namespace ui

#endif  // UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_NEURAL_STYLUS_PALM_REPORT_FILTER_H_