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 DeviceEventDispatcherEvdev
;
24 class EVENTS_OZONE_EVDEV_EXPORT TouchEventConverterEvdev
25 : public EventConverterEvdev
{
27 enum { MAX_FINGERS
= 20 };
28 TouchEventConverterEvdev(int fd
,
32 DeviceEventDispatcherEvdev
* dispatcher
);
33 ~TouchEventConverterEvdev() override
;
35 // EventConverterEvdev:
36 bool HasTouchscreen() const override
;
37 gfx::Size
GetTouchscreenSize() const override
;
38 int GetTouchPoints() const override
;
40 // Unsafe part of initialization.
41 virtual void Initialize(const EventDeviceInfo
& info
);
44 friend class MockTouchEventConverterEvdev
;
46 struct InProgressEvents
{
52 int id_
; // Device reported "unique" touch point id; -1 means not active
53 int finger_
; // "Finger" id starting from 0; -1 means not active
61 // Overidden from base::MessagePumpLibevent::Watcher.
62 void OnFileCanReadWithoutBlocking(int fd
) override
;
64 virtual bool Reinitialize();
66 void ProcessInputEvent(const input_event
& input
);
67 void ProcessAbs(const input_event
& input
);
68 void ProcessSyn(const input_event
& input
);
70 void ReportEvent(int touch_id
,
71 const InProgressEvents
& event
, const base::TimeDelta
& delta
);
72 void ReportEvents(base::TimeDelta delta
);
74 // Dispatcher for events.
75 DeviceEventDispatcherEvdev
* dispatcher_
;
77 // Set if we have seen a SYN_DROPPED and not yet re-synced with the device.
80 // Set if this is a type A device (uses SYN_MT_REPORT).
85 int pressure_max_
; // Used to normalize pressure values.
87 // Input range for x-axis.
91 // Input range for y-axis.
95 // Size of the touchscreen as reported by the driver.
96 gfx::Size native_size_
;
98 // Number of touch points reported by driver
101 // Touch point currently being updated from the /dev/input/event* stream.
102 size_t current_slot_
;
104 // In-progress touch points.
105 std::vector
<InProgressEvents
> events_
;
107 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev
);
112 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_