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/events_ozone_evdev_export.h" | 14 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
15 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" | 15 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 | 18 |
19 class Event; | 19 class Event; |
20 class EventDeviceInfo; | 20 class EventDeviceInfo; |
21 class EventModifiersEvdev; | 21 class EventModifiersEvdev; |
22 class CursorDelegateEvdev; | 22 class CursorDelegateEvdev; |
23 class GestureDeviceProperties; | |
24 class GesturePropertyProvider; | |
23 | 25 |
24 typedef base::Callback<void(Event*)> EventDispatchCallback; | 26 typedef base::Callback<void(Event*)> EventDispatchCallback; |
25 | 27 |
26 // Convert libevdev-cros events to ui::Events using libgestures. | 28 // Convert libevdev-cros events to ui::Events using libgestures. |
27 // | 29 // |
28 // This builds a GestureInterpreter for an input device (touchpad or | 30 // This builds a GestureInterpreter for an input device (touchpad or |
29 // mouse). | 31 // mouse). |
30 // | 32 // |
31 // Raw input events must be preprocessed into a form suitable for | 33 // Raw input events must be preprocessed into a form suitable for |
32 // libgestures. The kernel protocol only emits changes to the device state, | 34 // libgestures. The kernel protocol only emits changes to the device state, |
33 // 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 |
34 // at sync is then processed by libgestures. | 36 // at sync is then processed by libgestures. |
35 // | 37 // |
36 // 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 |
37 // 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 |
38 // converted to ui::Events and dispatched. | 40 // converted to ui::Events and dispatched. |
39 class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros | 41 class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros |
40 : public EventReaderLibevdevCros::Delegate { | 42 : public EventReaderLibevdevCros::Delegate { |
41 public: | 43 public: |
42 GestureInterpreterLibevdevCros(EventModifiersEvdev* modifiers, | 44 GestureInterpreterLibevdevCros(EventModifiersEvdev* modifiers, |
43 CursorDelegateEvdev* cursor, | 45 CursorDelegateEvdev* cursor, |
46 GesturePropertyProvider* prop_provider, | |
44 const EventDispatchCallback& callback); | 47 const EventDispatchCallback& callback); |
45 virtual ~GestureInterpreterLibevdevCros(); | 48 virtual ~GestureInterpreterLibevdevCros(); |
46 | 49 |
47 // Overriden from ui::EventReaderLibevdevCros::Delegate | 50 // Overriden from ui::EventReaderLibevdevCros::Delegate |
48 virtual void OnLibEvdevCrosOpen(Evdev* evdev, | 51 virtual void OnLibEvdevCrosOpen(Evdev* evdev, |
49 EventStateRec* evstate) OVERRIDE; | 52 EventStateRec* evstate) OVERRIDE; |
50 virtual void OnLibEvdevCrosEvent(Evdev* evdev, | 53 virtual void OnLibEvdevCrosEvent(Evdev* evdev, |
51 EventStateRec* evstate, | 54 EventStateRec* evstate, |
52 const timeval& time) OVERRIDE; | 55 const timeval& time) OVERRIDE; |
53 | 56 |
54 // Handler for gesture events generated from libgestures. | 57 // Handler for gesture events generated from libgestures. |
55 void OnGestureReady(const Gesture* gesture); | 58 void OnGestureReady(const Gesture* gesture); |
56 | 59 |
60 // Return the GesturePropertyProvider object pointer. | |
61 GesturePropertyProvider* GetPropertyProvider() { return prop_provider_; } | |
alexst (slow to review)
2014/10/03 22:32:02
Per google code style http://google-styleguide.goo
Shecky Lin
2014/10/08 10:51:00
Done.
| |
62 | |
63 // Return the Evdev device pointer. | |
64 Evdev* GetDevicePointer() { return dev_; } | |
alexst (slow to review)
2014/10/03 22:32:02
Evdev* evdev() { return dev_; }
Shecky Lin
2014/10/08 10:50:59
Done.
| |
65 | |
57 private: | 66 private: |
58 void OnGestureMove(const Gesture* gesture, const GestureMove* move); | 67 void OnGestureMove(const Gesture* gesture, const GestureMove* move); |
59 void OnGestureScroll(const Gesture* gesture, const GestureScroll* move); | 68 void OnGestureScroll(const Gesture* gesture, const GestureScroll* move); |
60 void OnGestureButtonsChange(const Gesture* gesture, | 69 void OnGestureButtonsChange(const Gesture* gesture, |
61 const GestureButtonsChange* move); | 70 const GestureButtonsChange* move); |
62 void OnGestureContactInitiated(const Gesture* gesture); | 71 void OnGestureContactInitiated(const Gesture* gesture); |
63 void OnGestureFling(const Gesture* gesture, const GestureFling* fling); | 72 void OnGestureFling(const Gesture* gesture, const GestureFling* fling); |
64 void OnGestureSwipe(const Gesture* gesture, const GestureSwipe* swipe); | 73 void OnGestureSwipe(const Gesture* gesture, const GestureSwipe* swipe); |
65 void OnGestureSwipeLift(const Gesture* gesture, | 74 void OnGestureSwipeLift(const Gesture* gesture, |
66 const GestureSwipeLift* swipelift); | 75 const GestureSwipeLift* swipelift); |
67 void OnGesturePinch(const Gesture* gesture, const GesturePinch* pinch); | 76 void OnGesturePinch(const Gesture* gesture, const GesturePinch* pinch); |
68 void OnGestureMetrics(const Gesture* gesture, const GestureMetrics* metrics); | 77 void OnGestureMetrics(const Gesture* gesture, const GestureMetrics* metrics); |
69 | 78 |
70 void Dispatch(Event* event); | 79 void Dispatch(Event* event); |
71 void DispatchMouseButton(unsigned int modifier, bool down); | 80 void DispatchMouseButton(unsigned int modifier, bool down); |
72 | 81 |
73 // Shared modifier state. | 82 // Shared modifier state. |
74 EventModifiersEvdev* modifiers_; | 83 EventModifiersEvdev* modifiers_; |
75 | 84 |
76 // Shared cursor state. | 85 // Shared cursor state. |
77 CursorDelegateEvdev* cursor_; | 86 CursorDelegateEvdev* cursor_; |
78 | 87 |
88 // Shared gesture property provider. | |
89 GesturePropertyProvider* prop_provider_; | |
alexst (slow to review)
2014/10/03 22:32:02
Use full names please, property_provider_
Shecky Lin
2014/10/08 10:50:59
Done.
| |
90 | |
79 // Callback for dispatching events. | 91 // Callback for dispatching events. |
80 EventDispatchCallback dispatch_callback_; | 92 EventDispatchCallback dispatch_callback_; |
81 | 93 |
82 // Gestures interpretation state. | 94 // Gestures interpretation state. |
83 gestures::GestureInterpreter* interpreter_; | 95 gestures::GestureInterpreter* interpreter_; |
84 | 96 |
97 // Device pointer. | |
98 Evdev* dev_; | |
alexst (slow to review)
2014/10/03 22:32:02
Full name here as well, evdev_
Shecky Lin
2014/10/08 10:50:59
Done.
| |
99 | |
100 // Gesture lib device properties. | |
101 scoped_ptr<GestureDeviceProperties> device_props_; | |
alexst (slow to review)
2014/10/03 22:32:02
device_properties_
Shecky Lin
2014/10/08 10:50:59
Done.
| |
102 | |
85 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); | 103 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); |
86 }; | 104 }; |
87 | 105 |
88 } // namspace ui | 106 } // namspace ui |
89 | 107 |
90 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_C ROS_H_ | 108 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_C ROS_H_ |
OLD | NEW |