blob: 4b6d0bc0b235839a4c213c77a3ff7e657fa44f22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <libevdev/libevdev.h>
#include <string>
#include <vector>
#include "InputCommon/ControllerInterface/ControllerInterface.h"
namespace ciface
{
namespace evdev
{
void Init();
void PopulateDevices();
void Shutdown();
class evdevDevice : public Core::Device
{
private:
class Button : public Core::Device::Input
{
public:
std::string GetName() const override;
Button(u8 index, u16 code, libevdev* dev) : m_index(index), m_code(code), m_dev(dev) {}
ControlState GetState() const override;
private:
const u8 m_index;
const u16 m_code;
libevdev* m_dev;
};
class Axis : public Core::Device::Input
{
public:
std::string GetName() const override;
Axis(u8 index, u16 code, bool upper, libevdev* dev);
ControlState GetState() const override;
private:
const u16 m_code;
const u8 m_index;
int m_range;
int m_base;
libevdev* m_dev;
};
class Effect : public Core::Device::Output
{
public:
Effect(int fd);
~Effect();
void SetState(ControlState state) override;
protected:
virtual bool UpdateParameters(ControlState state) = 0;
ff_effect m_effect = {};
static constexpr int DISABLED_EFFECT_TYPE = 0;
private:
void UpdateEffect();
int const m_fd;
};
class ConstantEffect : public Effect
{
public:
ConstantEffect(int fd);
bool UpdateParameters(ControlState state) override;
std::string GetName() const override;
};
class PeriodicEffect : public Effect
{
public:
PeriodicEffect(int fd, u16 waveform);
bool UpdateParameters(ControlState state) override;
std::string GetName() const override;
};
class RumbleEffect : public Effect
{
public:
enum class Motor : u8
{
Weak,
Strong,
};
RumbleEffect(int fd, Motor motor);
bool UpdateParameters(ControlState state) override;
std::string GetName() const override;
private:
const Motor m_motor;
};
public:
void UpdateInput() override;
bool IsValid() const override;
evdevDevice(const std::string& devnode);
~evdevDevice();
std::string GetName() const override { return m_name; }
std::string GetSource() const override { return "evdev"; }
bool IsInteresting() const { return m_interesting; }
private:
const std::string m_devfile;
int m_fd;
libevdev* m_dev;
std::string m_name;
bool m_interesting = false;
};
} // namespace evdev
} // namespace ciface
|