| 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_EVENT_CONVERTER_EVDEV_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_H_ |
| 6 #define UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/callback.h" |
| 9 #include "base/bind.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 11 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 | 14 |
| 15 class Event; | 15 class Event; |
| 16 class EventModifiersEvdev; | |
| 17 | 16 |
| 18 typedef base::Callback<void(Event*)> EventDispatchCallback; | 17 typedef base::Callback<void(Event*)> EventDispatchCallback; |
| 19 | 18 |
| 20 // Base class for device-specific evdev event conversion. | 19 class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdev |
| 21 class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdev { | 20 : public base::MessagePumpLibevent::Watcher { |
| 22 public: | 21 public: |
| 23 EventConverterEvdev(); | 22 EventConverterEvdev(int fd, const base::FilePath& path); |
| 24 explicit EventConverterEvdev(const EventDispatchCallback& callback); | |
| 25 virtual ~EventConverterEvdev(); | 23 virtual ~EventConverterEvdev(); |
| 26 | 24 |
| 27 // Start converting events. | 25 // Start reading events. |
| 28 virtual void Start() = 0; | 26 void Start(); |
| 29 | 27 |
| 30 // Stop converting events. | 28 // Stop reading events. |
| 31 virtual void Stop() = 0; | 29 void Stop(); |
| 32 | 30 |
| 33 protected: | 31 protected: |
| 34 // Dispatches an event using the dispatch-callback set using | 32 // base::MessagePumpLibevent::Watcher: |
| 35 // |SetDispatchCalback()|. | 33 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
| 36 virtual void DispatchEventToCallback(ui::Event* event); | 34 |
| 35 // File descriptor to read. |
| 36 int fd_; |
| 37 |
| 38 // Path to input device. |
| 39 base::FilePath path_; |
| 40 |
| 41 // Controller for watching the input fd. |
| 42 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
| 37 | 43 |
| 38 private: | 44 private: |
| 39 EventDispatchCallback dispatch_callback_; | |
| 40 | |
| 41 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdev); | 45 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdev); |
| 42 }; | 46 }; |
| 43 | 47 |
| 44 } // namespace ui | 48 } // namespace ui |
| 45 | 49 |
| 46 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_H_ | 50 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_H_ |
| OLD | NEW |