| 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 "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "ui/events/ozone/evdev/event_converter_evdev.h" | 12 #include "ui/events/ozone/evdev/event_converter_evdev.h" |
| 13 #include "ui/events/ozone/evdev/event_device_info.h" |
| 13 | 14 |
| 14 namespace ui { | 15 namespace ui { |
| 15 | 16 |
| 16 // Basic wrapper for libevdev-cros. | 17 // Basic wrapper for libevdev-cros. |
| 17 // | 18 // |
| 18 // This drives libevdev-cros from a file descriptor and calls delegate | 19 // This drives libevdev-cros from a file descriptor and calls delegate |
| 19 // with the updated event state from libevdev-cros. | 20 // with the updated event state from libevdev-cros. |
| 20 // | 21 // |
| 21 // The library doesn't support all devices currently. In particular there | 22 // The library doesn't support all devices currently. In particular there |
| 22 // is no support for keyboard events. | 23 // is no support for keyboard events. |
| 23 class EventReaderLibevdevCros : public EventConverterEvdev { | 24 class EventReaderLibevdevCros : public EventConverterEvdev { |
| 24 public: | 25 public: |
| 25 class Delegate { | 26 class Delegate { |
| 26 public: | 27 public: |
| 27 virtual ~Delegate(); | 28 virtual ~Delegate(); |
| 28 | 29 |
| 29 // Notifier for open. This is called with the initial event state. | 30 // Notifier for open. This is called with the initial event state. |
| 30 virtual void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) = 0; | 31 virtual void OnLibEvdevCrosOpen(Evdev* evdev, EventStateRec* evstate) = 0; |
| 31 | 32 |
| 32 // Notifier for event. This is called with the updated event state. | 33 // Notifier for event. This is called with the updated event state. |
| 33 virtual void OnLibEvdevCrosEvent(Evdev* evdev, | 34 virtual void OnLibEvdevCrosEvent(Evdev* evdev, |
| 34 EventStateRec* state, | 35 EventStateRec* state, |
| 35 const timeval& time) = 0; | 36 const timeval& time) = 0; |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 EventReaderLibevdevCros(int fd, | 39 EventReaderLibevdevCros(int fd, |
| 39 const base::FilePath& path, | 40 const base::FilePath& path, |
| 40 int id, | 41 int id, |
| 41 InputDeviceType type, | 42 InputDeviceType type, |
| 43 const EventDeviceInfo& devinfo, |
| 42 scoped_ptr<Delegate> delegate); | 44 scoped_ptr<Delegate> delegate); |
| 43 ~EventReaderLibevdevCros(); | 45 ~EventReaderLibevdevCros(); |
| 44 | 46 |
| 45 // EventConverterEvdev: | 47 // EventConverterEvdev: |
| 46 void OnFileCanReadWithoutBlocking(int fd) override; | 48 void OnFileCanReadWithoutBlocking(int fd) override; |
| 49 bool HasKeyboard() const override; |
| 47 | 50 |
| 48 private: | 51 private: |
| 49 static void OnSynReport(void* data, | 52 static void OnSynReport(void* data, |
| 50 EventStateRec* evstate, | 53 EventStateRec* evstate, |
| 51 struct timeval* tv); | 54 struct timeval* tv); |
| 52 static void OnLogMessage(void*, int level, const char*, ...); | 55 static void OnLogMessage(void*, int level, const char*, ...); |
| 53 | 56 |
| 57 // Input modalities for this device. |
| 58 bool has_keyboard_; |
| 59 |
| 54 // Libevdev state. | 60 // Libevdev state. |
| 55 Evdev evdev_; | 61 Evdev evdev_; |
| 56 | 62 |
| 57 // Event state. | 63 // Event state. |
| 58 EventStateRec evstate_; | 64 EventStateRec evstate_; |
| 59 | 65 |
| 60 // Path to input device. | 66 // Path to input device. |
| 61 base::FilePath path_; | 67 base::FilePath path_; |
| 62 | 68 |
| 63 // Delegate for event processing. | 69 // Delegate for event processing. |
| 64 scoped_ptr<Delegate> delegate_; | 70 scoped_ptr<Delegate> delegate_; |
| 65 | 71 |
| 66 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros); | 72 DISALLOW_COPY_AND_ASSIGN(EventReaderLibevdevCros); |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 } // namspace ui | 75 } // namspace ui |
| 70 | 76 |
| 71 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_ | 77 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_EVENT_READER_LIBEVDEV_CROS_H_ |
| OLD | NEW |