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_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_ |
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_ |
7 | 7 |
| 8 #include <set> |
| 9 |
8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
9 #include "base/message_loop/message_pump_libevent.h" | 11 #include "base/message_loop/message_pump_libevent.h" |
10 #include "ui/events/devices/input_device.h" | 12 #include "ui/events/devices/input_device.h" |
11 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 14 #include "ui/events/keycodes/keyboard_codes.h" |
12 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
13 #include "ui/events/ozone/evdev/event_converter_evdev.h" | 16 #include "ui/events/ozone/evdev/event_converter_evdev.h" |
14 #include "ui/events/ozone/evdev/event_device_info.h" | 17 #include "ui/events/ozone/evdev/event_device_info.h" |
15 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 18 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 19 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
17 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 20 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
18 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" | 21 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" |
19 | 22 |
20 struct input_event; | 23 struct input_event; |
21 | 24 |
22 namespace ui { | 25 namespace ui { |
23 | 26 |
24 class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl | 27 class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl |
25 : public EventConverterEvdev { | 28 : public EventConverterEvdev { |
26 public: | 29 public: |
27 EventConverterEvdevImpl(int fd, | 30 EventConverterEvdevImpl(int fd, |
28 base::FilePath path, | 31 base::FilePath path, |
29 int id, | 32 int id, |
30 InputDeviceType type, | 33 InputDeviceType type, |
31 const EventDeviceInfo& info, | 34 const EventDeviceInfo& info, |
32 EventModifiersEvdev* modifiers, | 35 EventModifiersEvdev* modifiers, |
33 MouseButtonMapEvdev* button_map, | 36 MouseButtonMapEvdev* button_map, |
34 CursorDelegateEvdev* cursor, | 37 CursorDelegateEvdev* cursor, |
35 KeyboardEvdev* keyboard, | 38 KeyboardEvdev* keyboard, |
36 const EventDispatchCallback& callback); | 39 const EventDispatchCallback& callback); |
37 ~EventConverterEvdevImpl() override; | 40 ~EventConverterEvdevImpl() override; |
38 | 41 |
39 // EventConverterEvdev: | 42 // EventConverterEvdev: |
40 void OnFileCanReadWithoutBlocking(int fd) override; | 43 void OnFileCanReadWithoutBlocking(int fd) override; |
| 44 void SetAllowedKeys(scoped_ptr<std::set<KeyboardCode>> allowed_keys) override; |
| 45 void AllowAllKeys() override; |
41 bool HasKeyboard() const override; | 46 bool HasKeyboard() const override; |
| 47 bool HasTouchpad() const override; |
42 | 48 |
43 void ProcessEvents(const struct input_event* inputs, int count); | 49 void ProcessEvents(const struct input_event* inputs, int count); |
44 | 50 |
45 private: | 51 private: |
46 void ConvertKeyEvent(const input_event& input); | 52 void ConvertKeyEvent(const input_event& input); |
47 | 53 |
48 void ConvertMouseMoveEvent(const input_event& input); | 54 void ConvertMouseMoveEvent(const input_event& input); |
49 | 55 |
50 void DispatchMouseButton(const input_event& input); | 56 void DispatchMouseButton(const input_event& input); |
51 | 57 |
52 // Flush events delimited by EV_SYN. This is useful for handling | 58 // Flush events delimited by EV_SYN. This is useful for handling |
53 // non-axis-aligned movement properly. | 59 // non-axis-aligned movement properly. |
54 void FlushEvents(); | 60 void FlushEvents(); |
55 | 61 |
56 // Input modalities for this device. | 62 // Input modalities for this device. |
57 bool has_keyboard_; | 63 bool has_keyboard_; |
| 64 bool has_touchpad_; |
58 | 65 |
59 // Save x-axis events of relative devices to be flushed at EV_SYN time. | 66 // Save x-axis events of relative devices to be flushed at EV_SYN time. |
60 int x_offset_; | 67 int x_offset_; |
61 | 68 |
62 // Save y-axis events of relative devices to be flushed at EV_SYN time. | 69 // Save y-axis events of relative devices to be flushed at EV_SYN time. |
63 int y_offset_; | 70 int y_offset_; |
64 | 71 |
65 // Controller for watching the input fd. | 72 // Controller for watching the input fd. |
66 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 73 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
67 | 74 |
| 75 // The keys which should be processed. nullptr if all keys should be |
| 76 // processed. |
| 77 scoped_ptr<std::set<KeyboardCode>> allowed_keys_; |
| 78 |
68 // Shared cursor state. | 79 // Shared cursor state. |
69 CursorDelegateEvdev* cursor_; | 80 CursorDelegateEvdev* cursor_; |
70 | 81 |
71 // Shared keyboard state. | 82 // Shared keyboard state. |
72 KeyboardEvdev* keyboard_; | 83 KeyboardEvdev* keyboard_; |
73 | 84 |
74 // Modifier key state (shift, ctrl, etc). | 85 // Modifier key state (shift, ctrl, etc). |
75 EventModifiersEvdev* modifiers_; | 86 EventModifiersEvdev* modifiers_; |
76 | 87 |
77 // Shared mouse button map. | 88 // Shared mouse button map. |
78 MouseButtonMapEvdev* button_map_; | 89 MouseButtonMapEvdev* button_map_; |
79 | 90 |
80 // Callback for dispatching events. | 91 // Callback for dispatching events. |
81 EventDispatchCallback callback_; | 92 EventDispatchCallback callback_; |
82 | 93 |
83 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImpl); | 94 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImpl); |
84 }; | 95 }; |
85 | 96 |
86 } // namespace ui | 97 } // namespace ui |
87 | 98 |
88 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_ | 99 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_IMPL_H_ |
89 | 100 |
OLD | NEW |