OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 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_ |
| 7 |
| 8 #include <gestures/gestures.h> |
| 9 #include <libevdev/libevdev.h> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/events/events_export.h" |
| 14 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
| 15 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" |
| 16 |
| 17 namespace ui { |
| 18 |
| 19 class Event; |
| 20 class EventDeviceInfo; |
| 21 class EventModifiersEvdev; |
| 22 class CursorDelegateEvdev; |
| 23 |
| 24 typedef base::Callback<void(Event*)> EventDispatchCallback; |
| 25 |
| 26 // Convert libevdev-cros events to ui::Events using libgestures. |
| 27 // |
| 28 // This builds a GestureInterpreter for an input device (touchpad or |
| 29 // mouse). |
| 30 // |
| 31 // Raw input events must be preprocessed into a form suitable for |
| 32 // 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 |
| 34 // at sync is then processed by libgestures. |
| 35 // |
| 36 // 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 |
| 38 // converted to ui::Events and dispatched. |
| 39 class EVENTS_EXPORT GestureInterpreterLibevdevCros |
| 40 : public EventReaderLibevdevCros::Delegate { |
| 41 public: |
| 42 GestureInterpreterLibevdevCros(EventModifiersEvdev* modifiers, |
| 43 CursorDelegateEvdev* cursor, |
| 44 const EventDispatchCallback& callback); |
| 45 virtual ~GestureInterpreterLibevdevCros(); |
| 46 |
| 47 // Overriden from ui::EventReaderLibevdevCros::Delegate |
| 48 virtual void OnLibEvdevCrosOpen(Evdev* evdev, |
| 49 EventStateRec* evstate) OVERRIDE; |
| 50 virtual void OnLibEvdevCrosEvent(Evdev* evdev, |
| 51 EventStateRec* evstate, |
| 52 const timeval& time) OVERRIDE; |
| 53 |
| 54 // Handler for gesture events generated from libgestures. |
| 55 void OnGestureReady(const Gesture* gesture); |
| 56 |
| 57 private: |
| 58 void OnGestureMove(const Gesture* gesture, const GestureMove* move); |
| 59 void OnGestureScroll(const Gesture* gesture, const GestureScroll* move); |
| 60 void OnGestureButtonsChange(const Gesture* gesture, |
| 61 const GestureButtonsChange* move); |
| 62 void Dispatch(Event* event); |
| 63 void DispatchMouseButton(unsigned int modifier, bool down); |
| 64 |
| 65 // Shared modifier state. |
| 66 EventModifiersEvdev* modifiers_; |
| 67 |
| 68 // Shared cursor state. |
| 69 CursorDelegateEvdev* cursor_; |
| 70 |
| 71 // Callback for dispatching events. |
| 72 EventDispatchCallback dispatch_callback_; |
| 73 |
| 74 // Gestures interpretation state. |
| 75 gestures::GestureInterpreter* interpreter_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); |
| 78 }; |
| 79 |
| 80 } // namspace ui |
| 81 |
| 82 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_C
ROS_H_ |
OLD | NEW |