Landing Recent QUIC Changes.
[chromium-blink-merge.git] / ui / events / ozone / evdev / event_converter_evdev_impl.h
blobeef569e85cc0fed3a43ed8eb783ebf346d728d70
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_EVENT_CONVERTER_EVDEV_IMPL_H_
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_
8 #include <set>
10 #include "base/files/file_path.h"
11 #include "base/message_loop/message_pump_libevent.h"
12 #include "ui/events/devices/input_device.h"
13 #include "ui/events/event.h"
14 #include "ui/events/ozone/evdev/cursor_delegate_evdev.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/event_modifiers_evdev.h"
18 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
19 #include "ui/events/ozone/evdev/keyboard_evdev.h"
20 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
22 struct input_event;
24 namespace ui {
26 class DeviceEventDispatcherEvdev;
28 class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl
29 : public EventConverterEvdev {
30 public:
31 EventConverterEvdevImpl(int fd,
32 base::FilePath path,
33 int id,
34 InputDeviceType type,
35 const EventDeviceInfo& info,
36 CursorDelegateEvdev* cursor,
37 DeviceEventDispatcherEvdev* dispatcher);
38 ~EventConverterEvdevImpl() override;
40 // EventConverterEvdev:
41 void OnFileCanReadWithoutBlocking(int fd) override;
42 bool HasKeyboard() const override;
43 bool HasTouchpad() const override;
44 void SetAllowedKeys(scoped_ptr<std::set<DomCode>> allowed_keys) override;
45 void AllowAllKeys() override;
47 void ProcessEvents(const struct input_event* inputs, int count);
49 private:
50 void ConvertKeyEvent(const input_event& input);
52 void ConvertMouseMoveEvent(const input_event& input);
54 void DispatchMouseButton(const input_event& input);
56 // Flush events delimited by EV_SYN. This is useful for handling
57 // non-axis-aligned movement properly.
58 void FlushEvents();
60 // Input modalities for this device.
61 bool has_keyboard_;
62 bool has_touchpad_;
64 // Save x-axis events of relative devices to be flushed at EV_SYN time.
65 int x_offset_;
67 // Save y-axis events of relative devices to be flushed at EV_SYN time.
68 int y_offset_;
70 // Controller for watching the input fd.
71 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
73 // The keys which should be processed. nullptr if all keys should be
74 // processed.
75 scoped_ptr<std::set<DomCode>> allowed_keys_;
77 // Shared cursor state.
78 CursorDelegateEvdev* cursor_;
80 // Callbacks for dispatching events.
81 DeviceEventDispatcherEvdev* dispatcher_;
83 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImpl);
86 } // namespace ui
88 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_