Mir
platform.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
17  */
18 
19 #ifndef MIR_INPUT_EVDEV_PLATFORM_H_
20 #define MIR_INPUT_EVDEV_PLATFORM_H_
21 
22 #include "libinput_ptr.h"
23 #include "libinput_device_ptr.h"
24 
25 #include "mir/input/platform.h"
26 
27 #include <vector>
28 
29 struct libinput_device_group;
30 
31 namespace mir
32 {
33 namespace udev
34 {
35 class Device;
36 class Monitor;
37 class Context;
38 }
39 namespace dispatch
40 {
41 class MultiplexingDispatchable;
42 class ReadableFd;
43 }
44 namespace input
45 {
46 class InputDeviceRegistry;
47 namespace evdev
48 {
49 
50 struct MonitorDispatchable;
51 class LibInputDevice;
52 
53 class Platform : public input::Platform
54 {
55 public:
56  Platform(std::shared_ptr<InputDeviceRegistry> const& registry,
57  std::shared_ptr<InputReport> const& report,
58  std::unique_ptr<udev::Context>&& udev_context,
59  std::unique_ptr<udev::Monitor>&& monitor);
60  std::shared_ptr<mir::dispatch::Dispatchable> dispatchable() override;
61  void start() override;
62  void stop() override;
63 
64 private:
65  void scan_for_devices();
66  void process_changes();
67  void device_added(udev::Device const& dev);
68  void device_removed(udev::Device const& dev);
69  void device_changed(udev::Device const& dev);
70  void process_input_events();
71 
72  std::shared_ptr<LibInputDevice> create_device(udev::Device const& dev) const;
73 
74  std::shared_ptr<InputReport> const report;
75  std::shared_ptr<udev::Context> const udev_context;
76  std::unique_ptr<udev::Monitor> const monitor;
77  std::shared_ptr<InputDeviceRegistry> const input_device_registry;
78  std::shared_ptr<dispatch::MultiplexingDispatchable> const platform_dispatchable;
79  std::shared_ptr<dispatch::ReadableFd> const monitor_dispatchable;
80  std::shared_ptr<::libinput> const lib;
81  std::shared_ptr<dispatch::ReadableFd> const libinput_dispatchable;
82 
83  std::vector<std::shared_ptr<LibInputDevice>> devices;
84  auto find_device(char const* devnode) -> decltype(devices)::iterator;
85  auto find_device(libinput_device *) -> decltype(devices)::iterator;
86  auto find_device(libinput_device_group const* group) -> decltype(devices)::iterator;
87 
88  friend class MonitorDispatchable;
89 };
90 }
91 }
92 }
93 
94 #endif
All things Mir.
Definition: atomic_callback.h:25
std::shared_ptr< mir::dispatch::Dispatchable > dispatchable() override
Input Platform is used to discover and access available input devices.
Definition: platform.h:65
Definition: wrapper.h:50
friend class MonitorDispatchable
Definition: platform.h:88
Definition: platform.h:53

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015