summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h
diff options
context:
space:
mode:
authorAnthony <Helios747@users.noreply.github.com>2019-02-03 10:25:23 -0800
committerGitHub <noreply@github.com>2019-02-03 10:25:23 -0800
commite9130734af0ff86f4034fd9505ddbe8ef497a2a1 (patch)
tree0ab40c0aa2b456488ac9a045b699dbfeb5657b0e /Source/Core/InputCommon/ControllerInterface/evdev/evdev.h
parentd11ee96eaca2033d4b4d1febe14becf107a2d0e7 (diff)
parent6cc8775510f96437ef3aa987d6d3a3a03e6dff1f (diff)
Merge pull request #7688 from jordan-woyak/evdev-improve
ControllerInterface: evdev: Cleanups and effect processing fixes.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/evdev/evdev.h')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/evdev/evdev.h65
1 files changed, 51 insertions, 14 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h
index c1a3da2ada..5196084d24 100644
--- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h
+++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h
@@ -44,24 +44,62 @@ private:
private:
const u16 m_code;
const u8 m_index;
- const bool m_upper;
int m_range;
- int m_min;
+ int m_base;
libevdev* m_dev;
};
- class ForceFeedback : public Core::Device::Output
+ class Effect : public Core::Device::Output
{
public:
- std::string GetName() const override;
- ForceFeedback(u16 type, libevdev* dev) : m_type(type), m_id(-1) { m_fd = libevdev_get_fd(dev); }
- ~ForceFeedback();
+ 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 u16 m_type;
- int m_fd;
- int m_id;
+ const Motor m_motor;
};
public:
@@ -73,15 +111,14 @@ public:
std::string GetName() const override { return m_name; }
std::string GetSource() const override { return "evdev"; }
- bool IsInteresting() const { return m_initialized && m_interesting; }
+ bool IsInteresting() const { return m_interesting; }
private:
const std::string m_devfile;
int m_fd;
libevdev* m_dev;
std::string m_name;
- bool m_initialized;
- bool m_interesting;
+ bool m_interesting = false;
};
-}
-}
+} // namespace evdev
+} // namespace ciface