OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_EVENTS_OZONE_TABLET_EVENT_CONVERTER_EVDEV_H_ | 5 #ifndef UI_EVENTS_OZONE_TABLET_EVENT_CONVERTER_EVDEV_H_ |
6 #define UI_EVENTS_OZONE_TABLET_EVENT_CONVERTER_EVDEV_H_ | 6 #define UI_EVENTS_OZONE_TABLET_EVENT_CONVERTER_EVDEV_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/message_loop/message_pump_libevent.h" | 9 #include "base/message_loop/message_pump_libevent.h" |
10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
11 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 11 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
12 #include "ui/events/ozone/evdev/event_converter_evdev.h" | 12 #include "ui/events/ozone/evdev/event_converter_evdev.h" |
13 #include "ui/events/ozone/evdev/event_device_info.h" | 13 #include "ui/events/ozone/evdev/event_device_info.h" |
14 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 14 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
15 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 15 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
16 | 16 |
17 struct input_event; | 17 struct input_event; |
18 | 18 |
19 namespace ui { | 19 namespace ui { |
20 | 20 |
21 class EVENTS_OZONE_EVDEV_EXPORT TabletEventConverterEvdev | 21 class EVENTS_OZONE_EVDEV_EXPORT TabletEventConverterEvdev |
22 : public EventConverterEvdev { | 22 : public EventConverterEvdev { |
23 public: | 23 public: |
24 TabletEventConverterEvdev(int fd, | 24 TabletEventConverterEvdev( |
25 base::FilePath path, | 25 int fd, |
26 int id, | 26 base::FilePath path, |
27 InputDeviceType type, | 27 int id, |
28 EventModifiersEvdev* modifiers, | 28 InputDeviceType type, |
29 CursorDelegateEvdev* cursor, | 29 CursorDelegateEvdev* cursor, |
30 const EventDeviceInfo& info, | 30 const EventDeviceInfo& info, |
31 const EventDispatchCallback& callback); | 31 const MouseMoveEventDispatchCallback& mouse_move_callback, |
| 32 const MouseButtonEventDispatchCallback& mouse_button_callback); |
32 ~TabletEventConverterEvdev() override; | 33 ~TabletEventConverterEvdev() override; |
33 | 34 |
34 // EventConverterEvdev: | 35 // EventConverterEvdev: |
35 void OnFileCanReadWithoutBlocking(int fd) override; | 36 void OnFileCanReadWithoutBlocking(int fd) override; |
36 | 37 |
37 void ProcessEvents(const struct input_event* inputs, int count); | 38 void ProcessEvents(const struct input_event* inputs, int count); |
38 | 39 |
39 private: | 40 private: |
40 friend class MockTabletEventConverterEvdev; | 41 friend class MockTabletEventConverterEvdev; |
41 void ConvertKeyEvent(const input_event& input); | 42 void ConvertKeyEvent(const input_event& input); |
42 void ConvertAbsEvent(const input_event& input); | 43 void ConvertAbsEvent(const input_event& input); |
43 void DispatchMouseButton(const input_event& input); | 44 void DispatchMouseButton(const input_event& input); |
44 void UpdateCursor(); | 45 void UpdateCursor(); |
45 | 46 |
46 // Flush events delimited by EV_SYN. This is useful for handling | 47 // Flush events delimited by EV_SYN. This is useful for handling |
47 // non-axis-aligned movement properly. | 48 // non-axis-aligned movement properly. |
48 void FlushEvents(); | 49 void FlushEvents(); |
49 | 50 |
50 // Controller for watching the input fd. | 51 // Controller for watching the input fd. |
51 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 52 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
52 | 53 |
53 // Shared cursor state. | 54 // Shared cursor state. |
54 CursorDelegateEvdev* cursor_; | 55 CursorDelegateEvdev* cursor_; |
55 | 56 |
56 // Modifier key state (shift, ctrl, etc). | 57 // Callbacks for dispatching events. |
57 EventModifiersEvdev* modifiers_; | 58 MouseMoveEventDispatchCallback mouse_move_callback_; |
58 | 59 MouseButtonEventDispatchCallback mouse_button_callback_; |
59 // Callback for dispatching events. | |
60 EventDispatchCallback callback_; | |
61 | 60 |
62 int y_abs_location_; | 61 int y_abs_location_; |
63 int x_abs_location_; | 62 int x_abs_location_; |
64 int x_abs_min_; | 63 int x_abs_min_; |
65 int y_abs_min_; | 64 int y_abs_min_; |
66 int x_abs_range_; | 65 int x_abs_range_; |
67 int y_abs_range_; | 66 int y_abs_range_; |
68 | 67 |
69 // BTN_TOOL_ code for the active device | 68 // BTN_TOOL_ code for the active device |
70 int stylus_; | 69 int stylus_; |
71 | 70 |
72 // Whether we need to move the cursor | 71 // Whether we need to move the cursor |
73 bool abs_value_dirty_; | 72 bool abs_value_dirty_; |
74 | 73 |
75 DISALLOW_COPY_AND_ASSIGN(TabletEventConverterEvdev); | 74 DISALLOW_COPY_AND_ASSIGN(TabletEventConverterEvdev); |
76 }; | 75 }; |
77 | 76 |
78 } // namespace ui | 77 } // namespace ui |
79 | 78 |
80 #endif // UI_EVENTS_OZONE_TABLET_EVENT_CONVERTER_EVDEV_H_ | 79 #endif // UI_EVENTS_OZONE_TABLET_EVENT_CONVERTER_EVDEV_H_ |
OLD | NEW |