| 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_EVENT_READER_LIBEVDEV_CROS_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_ |
| 6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_ |
| 7 | 7 |
| 8 #include <libevdev/libevdev.h> | 8 #include <libevdev/libevdev.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "ui/events/ozone/evdev/event_converter_evdev.h" | 15 #include "ui/events/ozone/evdev/event_converter_evdev.h" |
| 16 #include "ui/events/ozone/evdev/event_device_info.h" | 16 #include "ui/events/ozone/evdev/event_device_info.h" |
| 17 #include "ui/events/ozone/evdev/scoped_input_device.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 | 20 |
| 20 // Basic wrapper for libevdev-cros. | 21 // Basic wrapper for libevdev-cros. |
| 21 // | 22 // |
| 22 // This drives libevdev-cros from a file descriptor and calls delegate | 23 // This drives libevdev-cros from a file descriptor and calls delegate |
| 23 // with the updated event state from libevdev-cros. | 24 // with the updated event state from libevdev-cros. |
| 24 // | 25 // |
| 25 // The library doesn't support all devices currently. In particular there | 26 // The library doesn't support all devices currently. In particular there |
| 26 // is no support for keyboard events. | 27 // is no support for keyboard events. |
| 27 class EventReaderLibevdevCros : public EventConverterEvdev { | 28 class EventReaderLibevdevCros : public EventConverterEvdev { |
| 28 public: | 29 public: |
| 29 class Delegate { | 30 class Delegate { |
| 30 public: | 31 public: |
| 31 virtual ~Delegate(); | 32 virtual ~Delegate(); |
| 32 | 33 |
| 33 // Notifier for open. This is called with the initial event state. | 34 // Notifier for open. This is called with the initial event state. |
| 34 virtual void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) = 0; | 35 virtual void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) = 0; |
| 35 | 36 |
| 36 // Notifier for event. This is called with the updated event state. | 37 // Notifier for event. This is called with the updated event state. |
| 37 virtual void OnLibEvdevCrosEvent(Evdev* evdev, | 38 virtual void OnLibEvdevCrosEvent(Evdev* evdev, |
| 38 EventStateRec* state, | 39 EventStateRec* state, |
| 39 const timeval& time) = 0; | 40 const timeval& time) = 0; |
| 40 | 41 |
| 41 // Notifier for stop. This is called with the final event state. | 42 // Notifier for stop. This is called with the final event state. |
| 42 virtual void OnLibEvdevCrosStopped(Evdev* evdev, EventStateRec* state) = 0; | 43 virtual void OnLibEvdevCrosStopped(Evdev* evdev, EventStateRec* state) = 0; |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 EventReaderLibevdevCros(int fd, | 46 EventReaderLibevdevCros(ScopedInputDevice fd, |
| 46 const base::FilePath& path, | 47 const base::FilePath& path, |
| 47 int id, | 48 int id, |
| 48 const EventDeviceInfo& devinfo, | 49 const EventDeviceInfo& devinfo, |
| 49 std::unique_ptr<Delegate> delegate); | 50 std::unique_ptr<Delegate> delegate); |
| 50 ~EventReaderLibevdevCros() override; | 51 ~EventReaderLibevdevCros() override; |
| 51 | 52 |
| 52 // EventConverterEvdev: | 53 // EventConverterEvdev: |
| 53 void OnFileCanReadWithoutBlocking(int fd) override; | 54 void OnFileCanReadWithoutBlocking(int fd) override; |
| 54 bool HasKeyboard() const override; | 55 bool HasKeyboard() const override; |
| 55 bool HasMouse() const override; | 56 bool HasMouse() const override; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 82 | 83 |
| 83 // Delegate for event processing. | 84 // Delegate for event processing. |
| 84 std::unique_ptr<Delegate> delegate_; | 85 std::unique_ptr<Delegate> delegate_; |
| 85 | 86 |
| 86 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros); | 87 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros); |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 } // namspace ui | 90 } // namspace ui |
| 90 | 91 |
| 91 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_ | 92 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_ |
| OLD | NEW |