base: Change DCHECK_IS_ON to a macro DCHECK_IS_ON().
[chromium-blink-merge.git] / ui / events / ozone / evdev / event_converter_evdev_impl.h
blobc7e66fe983b384cf62855599cc72effeed388675
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 "base/files/file_path.h"
9 #include "base/message_loop/message_pump_libevent.h"
10 #include "ui/events/devices/input_device.h"
11 #include "ui/events/event.h"
12 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
13 #include "ui/events/ozone/evdev/event_converter_evdev.h"
14 #include "ui/events/ozone/evdev/event_device_info.h"
15 #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
17 #include "ui/events/ozone/evdev/keyboard_evdev.h"
18 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
20 struct input_event;
22 namespace ui {
24 class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl
25 : public EventConverterEvdev {
26 public:
27 EventConverterEvdevImpl(int fd,
28 base::FilePath path,
29 int id,
30 InputDeviceType type,
31 const EventDeviceInfo& info,
32 EventModifiersEvdev* modifiers,
33 MouseButtonMapEvdev* button_map,
34 CursorDelegateEvdev* cursor,
35 KeyboardEvdev* keyboard,
36 const EventDispatchCallback& callback);
37 ~EventConverterEvdevImpl() override;
39 // EventConverterEvdev:
40 void OnFileCanReadWithoutBlocking(int fd) override;
41 bool HasKeyboard() const override;
43 void ProcessEvents(const struct input_event* inputs, int count);
45 private:
46 void ConvertKeyEvent(const input_event& input);
48 void ConvertMouseMoveEvent(const input_event& input);
50 void DispatchMouseButton(const input_event& input);
52 // Flush events delimited by EV_SYN. This is useful for handling
53 // non-axis-aligned movement properly.
54 void FlushEvents();
56 // Input modalities for this device.
57 bool has_keyboard_;
59 // Save x-axis events of relative devices to be flushed at EV_SYN time.
60 int x_offset_;
62 // Save y-axis events of relative devices to be flushed at EV_SYN time.
63 int y_offset_;
65 // Controller for watching the input fd.
66 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
68 // Shared cursor state.
69 CursorDelegateEvdev* cursor_;
71 // Shared keyboard state.
72 KeyboardEvdev* keyboard_;
74 // Modifier key state (shift, ctrl, etc).
75 EventModifiersEvdev* modifiers_;
77 // Shared mouse button map.
78 MouseButtonMapEvdev* button_map_;
80 // Callback for dispatching events.
81 EventDispatchCallback callback_;
83 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImpl);
86 } // namespace ui
88 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_