| 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 DeviceEventDispatcherEvdev; |
| 21 class EventDeviceInfo; | 22 class EventDeviceInfo; |
| 22 class CursorDelegateEvdev; | 23 class CursorDelegateEvdev; |
| 23 struct GestureDeviceProperties; | 24 struct GestureDeviceProperties; |
| 24 class GesturePropertyProvider; | 25 class GesturePropertyProvider; |
| 25 | 26 |
| 26 // Convert libevdev-cros events to ui::Events using libgestures. | 27 // Convert libevdev-cros events to ui::Events using libgestures. |
| 27 // | 28 // |
| 28 // This builds a GestureInterpreter for an input device (touchpad or | 29 // This builds a GestureInterpreter for an input device (touchpad or |
| 29 // mouse). | 30 // mouse). |
| 30 // | 31 // |
| 31 // Raw input events must be preprocessed into a form suitable for | 32 // Raw input events must be preprocessed into a form suitable for |
| 32 // libgestures. The kernel protocol only emits changes to the device state, | 33 // 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 // so changes must be accumulated until a sync event. The full device state |
| 34 // at sync is then processed by libgestures. | 35 // at sync is then processed by libgestures. |
| 35 // | 36 // |
| 36 // Once we have the state at sync, we convert it to a HardwareState object | 37 // 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 // and forward it to libgestures. If any gestures are produced, they are |
| 38 // converted to ui::Events and dispatched. | 39 // converted to ui::Events and dispatched. |
| 39 class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros | 40 class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros |
| 40 : public EventReaderLibevdevCros::Delegate { | 41 : public EventReaderLibevdevCros::Delegate { |
| 41 public: | 42 public: |
| 42 GestureInterpreterLibevdevCros( | 43 GestureInterpreterLibevdevCros(int id, |
| 43 int id, | 44 CursorDelegateEvdev* cursor, |
| 44 CursorDelegateEvdev* cursor, | 45 GesturePropertyProvider* property_provider, |
| 45 GesturePropertyProvider* property_provider, | 46 DeviceEventDispatcherEvdev* dispatcher); |
| 46 const KeyEventDispatchCallback& key_callback, | |
| 47 const MouseMoveEventDispatchCallback& mouse_move_callback, | |
| 48 const MouseButtonEventDispatchCallback& mouse_button_callback, | |
| 49 const MouseWheelEventDispatchCallback& mouse_wheel_callback, | |
| 50 const ScrollEventDispatchCallback& scroll_callback); | |
| 51 ~GestureInterpreterLibevdevCros() override; | 47 ~GestureInterpreterLibevdevCros() override; |
| 52 | 48 |
| 53 // Overriden from ui::EventReaderLibevdevCros::Delegate | 49 // Overriden from ui::EventReaderLibevdevCros::Delegate |
| 54 void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) override; | 50 void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) override; |
| 55 void OnLibEvdevCrosEvent(Evdev* evdev, | 51 void OnLibEvdevCrosEvent(Evdev* evdev, |
| 56 EventStateRec* evstate, | 52 EventStateRec* evstate, |
| 57 const timeval& time) override; | 53 const timeval& time) override; |
| 58 void SetAllowedKeys( | 54 void SetAllowedKeys( |
| 59 scoped_ptr<std::set<DomCode>> allowed_keys) override; | 55 scoped_ptr<std::set<DomCode>> allowed_keys) override; |
| 60 void AllowAllKeys() override; | 56 void AllowAllKeys() override; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // The evdev codes of the keys which should be processed. nullptr if all keys | 89 // The evdev codes of the keys which should be processed. nullptr if all keys |
| 94 // should be processed. | 90 // should be processed. |
| 95 scoped_ptr<std::set<int>> allowed_keys_; | 91 scoped_ptr<std::set<int>> allowed_keys_; |
| 96 | 92 |
| 97 // Shared cursor state. | 93 // Shared cursor state. |
| 98 CursorDelegateEvdev* cursor_; | 94 CursorDelegateEvdev* cursor_; |
| 99 | 95 |
| 100 // Shared gesture property provider. | 96 // Shared gesture property provider. |
| 101 GesturePropertyProvider* property_provider_; | 97 GesturePropertyProvider* property_provider_; |
| 102 | 98 |
| 103 // Callbacks for dispatching events. | 99 // Dispatcher for events. |
| 104 KeyEventDispatchCallback key_callback_; | 100 DeviceEventDispatcherEvdev* dispatcher_; |
| 105 MouseMoveEventDispatchCallback mouse_move_callback_; | |
| 106 MouseButtonEventDispatchCallback mouse_button_callback_; | |
| 107 MouseWheelEventDispatchCallback mouse_wheel_callback_; | |
| 108 ScrollEventDispatchCallback scroll_callback_; | |
| 109 | 101 |
| 110 // Gestures interpretation state. | 102 // Gestures interpretation state. |
| 111 gestures::GestureInterpreter* interpreter_; | 103 gestures::GestureInterpreter* interpreter_; |
| 112 | 104 |
| 113 // Last key state from libevdev. | 105 // Last key state from libevdev. |
| 114 unsigned long prev_key_state_[EVDEV_BITS_TO_LONGS(KEY_CNT)]; | 106 unsigned long prev_key_state_[EVDEV_BITS_TO_LONGS(KEY_CNT)]; |
| 115 | 107 |
| 116 // Device pointer. | 108 // Device pointer. |
| 117 Evdev* evdev_; | 109 Evdev* evdev_; |
| 118 | 110 |
| 119 // Gesture lib device properties. | 111 // Gesture lib device properties. |
| 120 scoped_ptr<GestureDeviceProperties> device_properties_; | 112 scoped_ptr<GestureDeviceProperties> device_properties_; |
| 121 | 113 |
| 122 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); | 114 DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros); |
| 123 }; | 115 }; |
| 124 | 116 |
| 125 } // namspace ui | 117 } // namspace ui |
| 126 | 118 |
| 127 #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 |