Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / events / ozone / evdev / touch_event_converter_evdev.h
blobc1b78946a4fe5dfb7fb8ee5cf24c359a9b39f246
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_
8 #include <bitset>
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_pump_libevent.h"
14 #include "ui/events/event_constants.h"
15 #include "ui/events/ozone/evdev/event_converter_evdev.h"
16 #include "ui/events/ozone/evdev/event_device_info.h"
17 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
19 namespace ui {
21 class DeviceEventDispatcherEvdev;
22 class TouchEvent;
23 class TouchNoiseFinder;
24 struct InProgressTouchEvdev;
26 class EVENTS_OZONE_EVDEV_EXPORT TouchEventConverterEvdev
27 : public EventConverterEvdev {
28 public:
29 TouchEventConverterEvdev(int fd,
30 base::FilePath path,
31 int id,
32 InputDeviceType type,
33 DeviceEventDispatcherEvdev* dispatcher);
34 ~TouchEventConverterEvdev() override;
36 // EventConverterEvdev:
37 bool HasTouchscreen() const override;
38 gfx::Size GetTouchscreenSize() const override;
39 int GetTouchPoints() const override;
41 // Unsafe part of initialization.
42 virtual void Initialize(const EventDeviceInfo& info);
44 private:
45 friend class MockTouchEventConverterEvdev;
47 // Overidden from base::MessagePumpLibevent::Watcher.
48 void OnFileCanReadWithoutBlocking(int fd) override;
50 virtual bool Reinitialize();
52 void ProcessMultitouchEvent(const input_event& input);
53 void EmulateMultitouchEvent(const input_event& input);
54 void ProcessKey(const input_event& input);
55 void ProcessAbs(const input_event& input);
56 void ProcessSyn(const input_event& input);
58 // Returns an EventType to dispatch for |touch|. Returns ET_UNKNOWN if an
59 // event should not be dispatched.
60 EventType GetEventTypeForTouch(const InProgressTouchEvdev& touch);
62 void ReportEvent(const InProgressTouchEvdev& event,
63 EventType event_type,
64 const base::TimeDelta& delta);
65 void ReportEvents(base::TimeDelta delta);
67 // Normalize pressure value to [0, 1].
68 float ScalePressure(int32_t value);
70 int NextTrackingId();
72 // Dispatcher for events.
73 DeviceEventDispatcherEvdev* dispatcher_;
75 // Set if we have seen a SYN_DROPPED and not yet re-synced with the device.
76 bool syn_dropped_;
78 // Device has multitouch capability.
79 bool has_mt_;
81 // Pressure values.
82 int pressure_min_;
83 int pressure_max_; // Used to normalize pressure values.
85 // Input range for x-axis.
86 float x_min_tuxels_;
87 float x_num_tuxels_;
89 // Input range for y-axis.
90 float y_min_tuxels_;
91 float y_num_tuxels_;
93 // Number of touch points reported by driver
94 int touch_points_;
96 // Tracking id counter.
97 int next_tracking_id_;
99 // Touch point currently being updated from the /dev/input/event* stream.
100 size_t current_slot_;
102 // In-progress touch points.
103 std::vector<InProgressTouchEvdev> events_;
105 // Finds touch noise.
106 scoped_ptr<TouchNoiseFinder> touch_noise_finder_;
108 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev);
111 } // namespace ui
113 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_