| 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; | |
| 23 class CursorDelegateEvdev; | 22 class CursorDelegateEvdev; |
| 24 struct GestureDeviceProperties; | 23 struct GestureDeviceProperties; |
| 25 class GesturePropertyProvider; | 24 class GesturePropertyProvider; |
| 26 | 25 |
| 27 // Convert libevdev-cros events to ui::Events using libgestures. | 26 // Convert libevdev-cros events to ui::Events using libgestures. |
| 28 // | 27 // |
| 29 // This builds a GestureInterpreter for an input device (touchpad or | 28 // This builds a GestureInterpreter for an input device (touchpad or |
| 30 // mouse). | 29 // mouse). |
| 31 // | 30 // |
| 32 // Raw input events must be preprocessed into a form suitable for | 31 // Raw input events must be preprocessed into a form suitable for |
| 33 // libgestures. The kernel protocol only emits changes to the device state, | 32 // libgestures. The kernel protocol only emits changes to the device state, |
| 34 // so changes must be accumulated until a sync event. The full device state | 33 // so changes must be accumulated until a sync event. The full device state |
| 35 // at sync is then processed by libgestures. | 34 // at sync is then processed by libgestures. |
| 36 // | 35 // |
| 37 // Once we have the state at sync, we convert it to a HardwareState object | 36 // Once we have the state at sync, we convert it to a HardwareState object |
| 38 // and forward it to libgestures. If any gestures are produced, they are | 37 // and forward it to libgestures. If any gestures are produced, they are |
| 39 // converted to ui::Events and dispatched. | 38 // converted to ui::Events and dispatched. |
| 40 class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros | 39 class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros |
| 41 : public EventReaderLibevdevCros::Delegate { | 40 : public EventReaderLibevdevCros::Delegate { |
| 42 public: | 41 public: |
| 43 GestureInterpreterLibevdevCros( | 42 GestureInterpreterLibevdevCros( |
| 44 int id, | 43 int id, |
| 45 EventModifiersEvdev* modifiers, | |
| 46 CursorDelegateEvdev* cursor, | 44 CursorDelegateEvdev* cursor, |
| 47 GesturePropertyProvider* property_provider, | 45 GesturePropertyProvider* property_provider, |
| 48 const KeyEventDispatchCallback& key_callback, | 46 const KeyEventDispatchCallback& key_callback, |
| 49 const MouseMoveEventDispatchCallback& mouse_move_callback, | 47 const MouseMoveEventDispatchCallback& mouse_move_callback, |
| 50 const MouseButtonEventDispatchCallback& mouse_button_callback, | 48 const MouseButtonEventDispatchCallback& mouse_button_callback, |
| 51 const EventDispatchCallback& callback); | 49 const MouseWheelEventDispatchCallback& mouse_wheel_callback, |
| 50 const ScrollEventDispatchCallback& scroll_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; |
| 61 void AllowAllKeys() override; | 60 void AllowAllKeys() override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 void OnGestureButtonsChange(const Gesture* gesture, | 73 void OnGestureButtonsChange(const Gesture* gesture, |
| 75 const GestureButtonsChange* move); | 74 const GestureButtonsChange* move); |
| 76 void OnGestureContactInitiated(const Gesture* gesture); | 75 void OnGestureContactInitiated(const Gesture* gesture); |
| 77 void OnGestureFling(const Gesture* gesture, const GestureFling* fling); | 76 void OnGestureFling(const Gesture* gesture, const GestureFling* fling); |
| 78 void OnGestureSwipe(const Gesture* gesture, const GestureSwipe* swipe); | 77 void OnGestureSwipe(const Gesture* gesture, const GestureSwipe* swipe); |
| 79 void OnGestureSwipeLift(const Gesture* gesture, | 78 void OnGestureSwipeLift(const Gesture* gesture, |
| 80 const GestureSwipeLift* swipelift); | 79 const GestureSwipeLift* swipelift); |
| 81 void OnGesturePinch(const Gesture* gesture, const GesturePinch* pinch); | 80 void OnGesturePinch(const Gesture* gesture, const GesturePinch* pinch); |
| 82 void OnGestureMetrics(const Gesture* gesture, const GestureMetrics* metrics); | 81 void OnGestureMetrics(const Gesture* gesture, const GestureMetrics* metrics); |
| 83 | 82 |
| 84 void Dispatch(scoped_ptr<Event> event); | |
| 85 void DispatchMouseButton(unsigned int modifier, bool down); | 83 void DispatchMouseButton(unsigned int modifier, bool down); |
| 86 void DispatchChangedKeys(Evdev* evdev, const timeval& time); | 84 void DispatchChangedKeys(Evdev* evdev, const timeval& time); |
| 87 | 85 |
| 88 // The unique device id. | 86 // The unique device id. |
| 89 int id_; | 87 int id_; |
| 90 | 88 |
| 91 // True if the device may be regarded as a mouse. This includes normal mice | 89 // True if the device may be regarded as a mouse. This includes normal mice |
| 92 // and multi-touch mice. | 90 // and multi-touch mice. |
| 93 bool is_mouse_; | 91 bool is_mouse_; |
| 94 | 92 |
| 95 // The evdev codes of the keys which should be processed. nullptr if all keys | 93 // The evdev codes of the keys which should be processed. nullptr if all keys |
| 96 // should be processed. | 94 // should be processed. |
| 97 scoped_ptr<std::set<int>> allowed_keys_; | 95 scoped_ptr<std::set<int>> allowed_keys_; |
| 98 | 96 |
| 99 // Shared modifier state. | |
| 100 EventModifiersEvdev* modifiers_; | |
| 101 | |
| 102 // Shared cursor state. | 97 // Shared cursor state. |
| 103 CursorDelegateEvdev* cursor_; | 98 CursorDelegateEvdev* cursor_; |
| 104 | 99 |
| 105 // Shared gesture property provider. | 100 // Shared gesture property provider. |
| 106 GesturePropertyProvider* property_provider_; | 101 GesturePropertyProvider* property_provider_; |
| 107 | 102 |
| 108 // Callbacks for dispatching events. | 103 // Callbacks for dispatching events. |
| 109 KeyEventDispatchCallback key_callback_; | 104 KeyEventDispatchCallback key_callback_; |
| 110 MouseMoveEventDispatchCallback mouse_move_callback_; | 105 MouseMoveEventDispatchCallback mouse_move_callback_; |
| 111 MouseButtonEventDispatchCallback mouse_button_callback_; | 106 MouseButtonEventDispatchCallback mouse_button_callback_; |
| 112 EventDispatchCallback dispatch_callback_; | 107 MouseWheelEventDispatchCallback mouse_wheel_callback_; |
| 108 ScrollEventDispatchCallback scroll_callback_; |
| 113 | 109 |
| 114 // Gestures interpretation state. | 110 // Gestures interpretation state. |
| 115 gestures::GestureInterpreter* interpreter_; | 111 gestures::GestureInterpreter* interpreter_; |
| 116 | 112 |
| 117 // Last key state from libevdev. | 113 // Last key state from libevdev. |
| 118 unsigned long prev_key_state_[EVDEV_BITS_TO_LONGS(KEY_CNT)]; | 114 unsigned long prev_key_state_[EVDEV_BITS_TO_LONGS(KEY_CNT)]; |
| 119 | 115 |
| 120 // Device pointer. | 116 // Device pointer. |
| 121 Evdev* evdev_; | 117 Evdev* evdev_; |
| 122 | 118 |
| 123 // Gesture lib device properties. | 119 // Gesture lib device properties. |
| 124 scoped_ptr<GestureDeviceProperties> device_properties_; | 120 scoped_ptr<GestureDeviceProperties> device_properties_; |
| 125 | 121 |
| 126 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); | 122 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); |
| 127 }; | 123 }; |
| 128 | 124 |
| 129 } // namspace ui | 125 } // namspace ui |
| 130 | 126 |
| 131 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_C
ROS_H_ | 127 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_C
ROS_H_ |
| OLD | NEW |