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_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_CROS
_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_CROS
_H_ |
6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_CROS
_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_CROS
_H_ |
7 | 7 |
8 #include <gestures/gestures.h> | 8 #include <gestures/gestures.h> |
9 #include <libevdev/libevdev.h> | 9 #include <libevdev/libevdev.h> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 13 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
14 #include "ui/events/ozone/evdev/event_device_util.h" | 14 #include "ui/events/ozone/evdev/event_device_util.h" |
15 #include "ui/events/ozone/evdev/event_dispatch_callback.h" | 15 #include "ui/events/ozone/evdev/event_dispatch_callback.h" |
16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
17 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" | 17 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" |
18 | 18 |
19 namespace ui { | 19 namespace ui { |
20 | 20 |
21 class EventDeviceInfo; | 21 class EventDeviceInfo; |
22 class EventModifiersEvdev; | 22 class EventModifiersEvdev; |
23 class MouseButtonMapEvdev; | 23 class MouseButtonMapEvdev; |
24 class CursorDelegateEvdev; | 24 class CursorDelegateEvdev; |
25 class KeyboardEvdev; | |
26 struct GestureDeviceProperties; | 25 struct GestureDeviceProperties; |
27 class GesturePropertyProvider; | 26 class GesturePropertyProvider; |
28 | 27 |
29 // Convert libevdev-cros events to ui::Events using libgestures. | 28 // Convert libevdev-cros events to ui::Events using libgestures. |
30 // | 29 // |
31 // This builds a GestureInterpreter for an input device (touchpad or | 30 // This builds a GestureInterpreter for an input device (touchpad or |
32 // mouse). | 31 // mouse). |
33 // | 32 // |
34 // Raw input events must be preprocessed into a form suitable for | 33 // Raw input events must be preprocessed into a form suitable for |
35 // libgestures. The kernel protocol only emits changes to the device state, | 34 // libgestures. The kernel protocol only emits changes to the device state, |
36 // so changes must be accumulated until a sync event. The full device state | 35 // so changes must be accumulated until a sync event. The full device state |
37 // at sync is then processed by libgestures. | 36 // at sync is then processed by libgestures. |
38 // | 37 // |
39 // Once we have the state at sync, we convert it to a HardwareState object | 38 // Once we have the state at sync, we convert it to a HardwareState object |
40 // and forward it to libgestures. If any gestures are produced, they are | 39 // and forward it to libgestures. If any gestures are produced, they are |
41 // converted to ui::Events and dispatched. | 40 // converted to ui::Events and dispatched. |
42 class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros | 41 class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros |
43 : public EventReaderLibevdevCros::Delegate { | 42 : public EventReaderLibevdevCros::Delegate { |
44 public: | 43 public: |
45 GestureInterpreterLibevdevCros(int id, | 44 GestureInterpreterLibevdevCros(int id, |
46 EventModifiersEvdev* modifiers, | 45 EventModifiersEvdev* modifiers, |
47 MouseButtonMapEvdev* button_map, | 46 MouseButtonMapEvdev* button_map, |
48 CursorDelegateEvdev* cursor, | 47 CursorDelegateEvdev* cursor, |
49 KeyboardEvdev* keyboard, | |
50 GesturePropertyProvider* property_provider, | 48 GesturePropertyProvider* property_provider, |
| 49 const KeyEventDispatchCallback& key_callback, |
51 const EventDispatchCallback& callback); | 50 const EventDispatchCallback& callback); |
52 ~GestureInterpreterLibevdevCros() override; | 51 ~GestureInterpreterLibevdevCros() override; |
53 | 52 |
54 // Overriden from ui::EventReaderLibevdevCros::Delegate | 53 // Overriden from ui::EventReaderLibevdevCros::Delegate |
55 void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) override; | 54 void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) override; |
56 void OnLibEvdevCrosEvent(Evdev* evdev, | 55 void OnLibEvdevCrosEvent(Evdev* evdev, |
57 EventStateRec* evstate, | 56 EventStateRec* evstate, |
58 const timeval& time) override; | 57 const timeval& time) override; |
59 void SetAllowedKeys( | 58 void SetAllowedKeys( |
60 scoped_ptr<std::set<DomCode>> allowed_keys) override; | 59 scoped_ptr<std::set<DomCode>> allowed_keys) override; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 97 |
99 // Shared modifier state. | 98 // Shared modifier state. |
100 EventModifiersEvdev* modifiers_; | 99 EventModifiersEvdev* modifiers_; |
101 | 100 |
102 // Shared mouse button map. | 101 // Shared mouse button map. |
103 MouseButtonMapEvdev* button_map_; | 102 MouseButtonMapEvdev* button_map_; |
104 | 103 |
105 // Shared cursor state. | 104 // Shared cursor state. |
106 CursorDelegateEvdev* cursor_; | 105 CursorDelegateEvdev* cursor_; |
107 | 106 |
108 // Shared keyboard state. | |
109 KeyboardEvdev* keyboard_; | |
110 | |
111 // Shared gesture property provider. | 107 // Shared gesture property provider. |
112 GesturePropertyProvider* property_provider_; | 108 GesturePropertyProvider* property_provider_; |
113 | 109 |
114 // Callback for dispatching events. | 110 // Callbacks for dispatching events. |
| 111 KeyEventDispatchCallback key_callback_; |
115 EventDispatchCallback dispatch_callback_; | 112 EventDispatchCallback dispatch_callback_; |
116 | 113 |
117 // Gestures interpretation state. | 114 // Gestures interpretation state. |
118 gestures::GestureInterpreter* interpreter_; | 115 gestures::GestureInterpreter* interpreter_; |
119 | 116 |
120 // Last key state from libevdev. | 117 // Last key state from libevdev. |
121 unsigned long prev_key_state_[EVDEV_BITS_TO_LONGS(KEY_CNT)]; | 118 unsigned long prev_key_state_[EVDEV_BITS_TO_LONGS(KEY_CNT)]; |
122 | 119 |
123 // Device pointer. | 120 // Device pointer. |
124 Evdev* evdev_; | 121 Evdev* evdev_; |
125 | 122 |
126 // Gesture lib device properties. | 123 // Gesture lib device properties. |
127 scoped_ptr<GestureDeviceProperties> device_properties_; | 124 scoped_ptr<GestureDeviceProperties> device_properties_; |
128 | 125 |
129 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); | 126 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); |
130 }; | 127 }; |
131 | 128 |
132 } // namspace ui | 129 } // namspace ui |
133 | 130 |
134 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_C
ROS_H_ | 131 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_C
ROS_H_ |
OLD | NEW |