| 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 CursorDelegateEvdev; | 23 class CursorDelegateEvdev; |
| 24 class KeyboardEvdev; | 24 class KeyboardEvdev; |
| 25 class GestureDeviceProperties; |
| 26 class GesturePropertyProvider; |
| 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(int id, |
| 45 EventModifiersEvdev* modifiers, |
| 43 CursorDelegateEvdev* cursor, | 46 CursorDelegateEvdev* cursor, |
| 44 KeyboardEvdev* keyboard, | 47 KeyboardEvdev* keyboard, |
| 48 GesturePropertyProvider* property_provider, |
| 45 const EventDispatchCallback& callback); | 49 const EventDispatchCallback& callback); |
| 46 virtual ~GestureInterpreterLibevdevCros(); | 50 virtual ~GestureInterpreterLibevdevCros(); |
| 47 | 51 |
| 48 // Overriden from ui::EventReaderLibevdevCros::Delegate | 52 // Overriden from ui::EventReaderLibevdevCros::Delegate |
| 49 virtual void OnLibEvdevCrosOpen(Evdev* evdev, | 53 virtual void OnLibEvdevCrosOpen(Evdev* evdev, |
| 50 EventStateRec* evstate) override; | 54 EventStateRec* evstate) override; |
| 51 virtual void OnLibEvdevCrosEvent(Evdev* evdev, | 55 virtual void OnLibEvdevCrosEvent(Evdev* evdev, |
| 52 EventStateRec* evstate, | 56 EventStateRec* evstate, |
| 53 const timeval& time) override; | 57 const timeval& time) override; |
| 54 | 58 |
| 55 // Handler for gesture events generated from libgestures. | 59 // Handler for gesture events generated from libgestures. |
| 56 void OnGestureReady(const Gesture* gesture); | 60 void OnGestureReady(const Gesture* gesture); |
| 57 | 61 |
| 62 // Accessors. |
| 63 int id() { return id_; } |
| 64 GesturePropertyProvider* property_provider() { return property_provider_; } |
| 65 Evdev* evdev() { return evdev_; } |
| 66 |
| 58 private: | 67 private: |
| 59 void OnGestureMove(const Gesture* gesture, const GestureMove* move); | 68 void OnGestureMove(const Gesture* gesture, const GestureMove* move); |
| 60 void OnGestureScroll(const Gesture* gesture, const GestureScroll* move); | 69 void OnGestureScroll(const Gesture* gesture, const GestureScroll* move); |
| 61 void OnGestureButtonsChange(const Gesture* gesture, | 70 void OnGestureButtonsChange(const Gesture* gesture, |
| 62 const GestureButtonsChange* move); | 71 const GestureButtonsChange* move); |
| 63 void OnGestureContactInitiated(const Gesture* gesture); | 72 void OnGestureContactInitiated(const Gesture* gesture); |
| 64 void OnGestureFling(const Gesture* gesture, const GestureFling* fling); | 73 void OnGestureFling(const Gesture* gesture, const GestureFling* fling); |
| 65 void OnGestureSwipe(const Gesture* gesture, const GestureSwipe* swipe); | 74 void OnGestureSwipe(const Gesture* gesture, const GestureSwipe* swipe); |
| 66 void OnGestureSwipeLift(const Gesture* gesture, | 75 void OnGestureSwipeLift(const Gesture* gesture, |
| 67 const GestureSwipeLift* swipelift); | 76 const GestureSwipeLift* swipelift); |
| 68 void OnGesturePinch(const Gesture* gesture, const GesturePinch* pinch); | 77 void OnGesturePinch(const Gesture* gesture, const GesturePinch* pinch); |
| 69 void OnGestureMetrics(const Gesture* gesture, const GestureMetrics* metrics); | 78 void OnGestureMetrics(const Gesture* gesture, const GestureMetrics* metrics); |
| 70 | 79 |
| 71 void Dispatch(Event* event); | 80 void Dispatch(Event* event); |
| 72 void DispatchMouseButton(unsigned int modifier, bool down); | 81 void DispatchMouseButton(unsigned int modifier, bool down); |
| 73 void DispatchChangedKeys(Evdev* evdev, const timeval& time); | 82 void DispatchChangedKeys(Evdev* evdev, const timeval& time); |
| 74 | 83 |
| 84 // The unique device id. |
| 85 int id_; |
| 86 |
| 75 // Shared modifier state. | 87 // Shared modifier state. |
| 76 EventModifiersEvdev* modifiers_; | 88 EventModifiersEvdev* modifiers_; |
| 77 | 89 |
| 78 // Shared cursor state. | 90 // Shared cursor state. |
| 79 CursorDelegateEvdev* cursor_; | 91 CursorDelegateEvdev* cursor_; |
| 80 | 92 |
| 81 // Shared keyboard state. | 93 // Shared keyboard state. |
| 82 KeyboardEvdev* keyboard_; | 94 KeyboardEvdev* keyboard_; |
| 83 | 95 |
| 96 // Shared gesture property provider. |
| 97 GesturePropertyProvider* property_provider_; |
| 98 |
| 84 // Callback for dispatching events. | 99 // Callback for dispatching events. |
| 85 EventDispatchCallback dispatch_callback_; | 100 EventDispatchCallback dispatch_callback_; |
| 86 | 101 |
| 87 // Gestures interpretation state. | 102 // Gestures interpretation state. |
| 88 gestures::GestureInterpreter* interpreter_; | 103 gestures::GestureInterpreter* interpreter_; |
| 89 | 104 |
| 90 // Last key state from libevdev. | 105 // Last key state from libevdev. |
| 91 unsigned long prev_key_state_[EVDEV_BITS_TO_LONGS(KEY_CNT)]; | 106 unsigned long prev_key_state_[EVDEV_BITS_TO_LONGS(KEY_CNT)]; |
| 92 | 107 |
| 108 // Device pointer. |
| 109 Evdev* evdev_; |
| 110 |
| 111 // Gesture lib device properties. |
| 112 scoped_ptr<GestureDeviceProperties> device_properties_; |
| 113 |
| 93 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); | 114 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); |
| 94 }; | 115 }; |
| 95 | 116 |
| 96 } // namspace ui | 117 } // namspace ui |
| 97 | 118 |
| 98 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_C
ROS_H_ | 119 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_C
ROS_H_ |
| OLD | NEW |