Debian Codegraph @

Source/Core/InputCommon/ControllerInterface/evdev/evdev.h

raw symbols SCIP
1 // Copyright 2015 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <libevdev/libevdev.h>
7 #include <string>
8 #include <vector>
9
10 #include "InputCommon/ControllerInterface/ControllerInterface.h"
11
12 namespace ciface::evdev
13 {
14 class InputBackend;
15
16 std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface);
17
18 class evdevDevice : public Core::Device
19 {
20 private:
21 class Effect : public Core::Device::Output
22 {
23 public:
24 Effect(int fd);
25 ~Effect();
26 void SetState(ControlState state) override;
27
28 protected:
29 virtual bool UpdateParameters(ControlState state) = 0;
30
31 ff_effect m_effect = {};
32
33 static constexpr int DISABLED_EFFECT_TYPE = 0;
34
35 private:
36 void UpdateEffect();
37
38 int const m_fd;
39 };
40
41 class ConstantEffect : public Effect
42 {
43 public:
44 ConstantEffect(int fd);
45 bool UpdateParameters(ControlState state) override;
46 std::string GetName() const override;
47 };
48
49 class PeriodicEffect : public Effect
50 {
51 public:
52 PeriodicEffect(int fd, u16 waveform);
53 bool UpdateParameters(ControlState state) override;
54 std::string GetName() const override;
55 };
56
57 class RumbleEffect : public Effect
58 {
59 public:
60 enum class Motor : u8
61 {
62 Weak,
63 Strong,
64 };
65
66 RumbleEffect(int fd, Motor motor);
67 bool UpdateParameters(ControlState state) override;
68 std::string GetName() const override;
69
70 private:
71 const Motor m_motor;
72 };
73
74 public:
75 Core::DeviceRemoval UpdateInput() override;
76 bool IsValid() const override;
77
78 evdevDevice(InputBackend* input_backend);
79 ~evdevDevice();
80
81 // Return true if node was "interesting".
82 bool AddNode(std::string devnode, int fd, libevdev* dev);
83
84 const char* GetUniqueID() const;
85 const char* GetPhysicalLocation() const;
86
87 std::string GetName() const override { return m_name; }
88 std::string GetSource() const override { return "evdev"; }
89
90 private:
91 std::string m_name;
92
93 struct Node
94 {
95 std::string devnode;
96 int fd;
97 libevdev* device;
98 };
99
100 std::vector<Node> m_nodes;
101
102 InputBackend& m_input_backend;
103 };
104 } // namespace ciface::evdev