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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/task_runner.h"
13 #include "ui/events/events_export.h"
14 #include "ui/events/ozone/evdev/event_converter_evdev.h"
15 #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
16 #include "ui/events/ozone/event_factory_ozone.h"
20 class DeviceManagerEvdev;
22 // Ozone events implementation for the Linux input subsystem ("evdev").
23 class EVENTS_EXPORT EventFactoryEvdev : public EventFactoryOzone {
26 virtual ~EventFactoryEvdev();
28 virtual void StartProcessingEvents() OVERRIDE;
30 // Set task runner to use for device polling & initialization.
31 virtual void SetFileTaskRunner(scoped_refptr<base::TaskRunner> task_runner)
35 // Open device at path & starting processing events (on UI thread).
36 void AttachInputDevice(const base::FilePath& file_path,
37 scoped_ptr<EventConverterEvdev> converter);
39 // Close device at path (on UI thread).
40 void DetachInputDevice(const base::FilePath& file_path);
42 // Callback for device add (on UI thread).
43 void OnDeviceAdded(const base::FilePath& path);
45 // Callback for device remove (on UI thread).
46 void OnDeviceRemoved(const base::FilePath& path);
48 // Owned per-device event converters (by path).
49 std::map<base::FilePath, EventConverterEvdev*> converters_;
51 // Interface for scanning & monitoring input devices.
52 scoped_ptr<DeviceManagerEvdev> device_manager_;
54 // Task runner for event dispatch.
55 scoped_refptr<base::TaskRunner> ui_task_runner_;
57 // Task runner for file I/O.
58 scoped_refptr<base::TaskRunner> file_task_runner_;
60 // Modifier key state (shift, ctrl, etc).
61 EventModifiersEvdev modifiers_;
63 // Support weak pointers for attach & detach callbacks.
64 base::WeakPtrFactory<EventFactoryEvdev> weak_ptr_factory_;
66 DISALLOW_COPY_AND_ASSIGN(EventFactoryEvdev);
71 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_FACTORY_EVDEV_H_