1 // Copyright 2014 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_EVENT_CONVERTER_EVDEV_H_
6 #define UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "base/message_loop/message_pump_libevent.h"
13 #include "ui/events/event_constants.h"
14 #include "ui/events/ozone/evdev/event_converter_evdev.h"
15 #include "ui/events/ozone/evdev/event_device_info.h"
16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
22 class EVENTS_OZONE_EVDEV_EXPORT TouchEventConverterEvdev
23 : public EventConverterEvdev {
28 TouchEventConverterEvdev(int fd,
30 const EventDeviceInfo& info,
31 const EventDispatchCallback& dispatch);
32 virtual ~TouchEventConverterEvdev();
35 friend class MockTouchEventConverterEvdev;
37 // Unsafe part of initialization.
38 void Init(const EventDeviceInfo& info);
40 // Overidden from base::MessagePumpLibevent::Watcher.
41 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
43 virtual bool Reinitialize();
45 void ProcessInputEvent(const input_event& input);
46 void ProcessAbs(const input_event& input);
47 void ProcessSyn(const input_event& input);
49 void ReportEvents(base::TimeDelta delta);
51 // Callback for dispatching events.
52 EventDispatchCallback callback_;
54 // Set if we have seen a SYN_DROPPED and not yet re-synced with the device.
57 // Set if this is a type A device (uses SYN_MT_REPORT).
62 int pressure_max_; // Used to normalize pressure values.
64 // Input range for x-axis.
68 // Input range for y-axis.
72 // Output range for x-axis.
76 // Output range for y-axis.
80 // Touch point currently being updated from the /dev/input/event* stream.
83 // Bit field tracking which in-progress touch points have been modified
84 // without a syn event.
85 std::bitset<MAX_FINGERS> altered_slots_;
87 struct InProgressEvents {
90 int id_; // Device reported "unique" touch point id; -1 means not active
91 int finger_; // "Finger" id starting from 0; -1 means not active
99 // In-progress touch points.
100 InProgressEvents events_[MAX_FINGERS];
102 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev);
107 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_