| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_EVENT_FACTORY_DELEGATE_EVDEV_H_ | 5 #ifndef UI_EVENTS_OZONE_EVENT_FACTORY_DELEGATE_EVDEV_H_ |
| 6 #define UI_EVENTS_OZONE_EVENT_FACTORY_DELEGATE_EVDEV_H_ | 6 #define UI_EVENTS_OZONE_EVENT_FACTORY_DELEGATE_EVDEV_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" |
| 8 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 10 #include "ui/events/events_export.h" | 11 #include "ui/events/events_export.h" |
| 11 #include "ui/events/ozone/evdev/event_converter.h" | 12 #include "ui/events/ozone/evdev/event_converter.h" |
| 12 #include "ui/events/ozone/evdev/event_modifiers.h" | 13 #include "ui/events/ozone/evdev/event_modifiers.h" |
| 13 #include "ui/events/ozone/event_factory_ozone.h" | 14 #include "ui/events/ozone/event_factory_ozone.h" |
| 14 | 15 |
| 15 #if defined(USE_UDEV) | 16 namespace ui { |
| 16 #include "ui/events/ozone/evdev/scoped_udev.h" | |
| 17 #endif | |
| 18 | 17 |
| 19 namespace ui { | 18 typedef base::Callback<void(const base::FilePath& file_path)> |
| 19 EvdevDeviceCallback; |
| 20 |
| 21 // Interface for scanning & monitoring input devices. |
| 22 class DeviceManagerEvdev { |
| 23 public: |
| 24 virtual ~DeviceManagerEvdev(); |
| 25 |
| 26 // Enumerate devices & start watching for changes. |
| 27 virtual void ScanAndStartMonitoring( |
| 28 const EvdevDeviceCallback& device_added, |
| 29 const EvdevDeviceCallback& device_removed) = 0; |
| 30 }; |
| 20 | 31 |
| 21 // Ozone events implementation for the Linux input subsystem ("evdev"). | 32 // Ozone events implementation for the Linux input subsystem ("evdev"). |
| 22 class EVENTS_EXPORT EventFactoryEvdev : public EventFactoryOzone { | 33 class EVENTS_EXPORT EventFactoryEvdev : public EventFactoryOzone { |
| 23 public: | 34 public: |
| 24 EventFactoryEvdev(); | 35 EventFactoryEvdev(); |
| 25 virtual ~EventFactoryEvdev(); | 36 virtual ~EventFactoryEvdev(); |
| 26 | 37 |
| 27 virtual void StartProcessingEvents() OVERRIDE; | 38 virtual void StartProcessingEvents() OVERRIDE; |
| 28 | 39 |
| 29 private: | 40 private: |
| 30 // Open device at path & starting processing events. | 41 // Open device at path & starting processing events. |
| 31 void AttachInputDevice(const base::FilePath& file_path); | 42 void AttachInputDevice(const base::FilePath& file_path); |
| 32 | 43 |
| 33 // Scan & open devices in /dev/input (without udev). | 44 // Close device at path. |
| 34 void StartProcessingEventsManual(); | 45 void DetachInputDevice(const base::FilePath& file_path); |
| 35 | |
| 36 #if defined(USE_UDEV) | |
| 37 // Scan & open devices using udev. | |
| 38 void StartProcessingEventsUdev(); | |
| 39 #endif | |
| 40 | 46 |
| 41 // Owned per-device event converters (by path). | 47 // Owned per-device event converters (by path). |
| 42 std::map<base::FilePath, EventConverterEvdev*> converters_; | 48 std::map<base::FilePath, EventConverterEvdev*> converters_; |
| 43 | 49 |
| 44 #if defined(USE_UDEV) | 50 // Interface for scanning & monitoring input devices. |
| 45 // Udev daemon connection. | 51 scoped_ptr<DeviceManagerEvdev> device_manager_; |
| 46 scoped_udev udev_; | |
| 47 #endif | |
| 48 | 52 |
| 49 EventModifiersEvdev modifiers_; | 53 EventModifiersEvdev modifiers_; |
| 50 | 54 |
| 51 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev); | 55 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev); |
| 52 }; | 56 }; |
| 53 | 57 |
| 54 } // namespace ui | 58 } // namespace ui |
| 55 | 59 |
| 56 #endif // UI_EVENTS_OZONE_EVENT_FACTORY_DELEGATE_EVDEV_H_ | 60 #endif // UI_EVENTS_OZONE_EVENT_FACTORY_DELEGATE_EVDEV_H_ |
| OLD | NEW |