summaryrefslogtreecommitdiff
path: root/chromium/ui/events/ozone/evdev/touch_evdev_debug_buffer.h
blob: 1f17608e94d0939f785223e35eefd0e5aaf85070 (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
52
53
54
55
56
57
58
59
60
61
// 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.

#ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_DEBUG_BUFFER_H_
#define UI_EVENTS_OZONE_EVDEV_TOUCH_DEBUG_BUFFER_H_

#include <linux/input.h>
#include <stddef.h>

#include <memory>
#include <string>
#include <vector>

#include "base/component_export.h"

#ifndef input_event_sec
#define input_event_sec time.tv_sec
#define input_event_usec time.tv_usec
#endif

namespace ui {

class EventDeviceInfo;

class COMPONENT_EXPORT(EVDEV) TouchEventLogEvdev {
 public:
  TouchEventLogEvdev();
  ~TouchEventLogEvdev();

  void Initialize(const EventDeviceInfo& devinfo);
  void ProcessEvent(size_t cur_slot, const input_event* ev);

  void DumpLog(const char* filename);

 private:
  struct TouchEvent {
    struct input_event ev;
    int slot;
  };
  const int kDebugBufferSize = 65536;
  std::unique_ptr<TouchEvent[]> logged_events_;
  int debug_buffer_tail_ = 0;

  std::string device_name_;

  struct AbsAxisData {
    AbsAxisData(int code, const input_absinfo& info);
    AbsAxisData(const AbsAxisData& other);
    ~AbsAxisData();

    int code;
    input_absinfo info;
  };

  std::vector<AbsAxisData> axes_;
};

}  // namespace ui

#endif  // UI_EVENTS_OZONE_EVDEV_TOUCH_EVDEV_BUFFER_H_