2015-06-29 00:17:35 +00:00
|
|
|
// 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>
|
|
|
|
|
2016-07-14 15:50:35 +00:00
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
|
|
|
|
2019-06-17 20:39:24 +00:00
|
|
|
namespace ciface::evdev
|
2015-06-29 00:17:35 +00:00
|
|
|
{
|
2016-06-12 15:08:04 +00:00
|
|
|
void Init();
|
2016-10-16 20:39:05 +00:00
|
|
|
void PopulateDevices();
|
2016-07-14 15:50:35 +00:00
|
|
|
void Shutdown();
|
2015-06-29 00:17:35 +00:00
|
|
|
|
|
|
|
class evdevDevice : public Core::Device
|
|
|
|
{
|
|
|
|
private:
|
2019-01-08 15:28:24 +00:00
|
|
|
class Effect : public Core::Device::Output
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-01-08 15:28:24 +00:00
|
|
|
Effect(int fd);
|
|
|
|
~Effect();
|
2015-06-29 00:17:35 +00:00
|
|
|
void SetState(ControlState state) override;
|
|
|
|
|
2019-01-08 15:28:24 +00:00
|
|
|
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:
|
2019-01-17 15:54:07 +00:00
|
|
|
enum class Motor : u8
|
|
|
|
{
|
2019-01-17 16:13:32 +00:00
|
|
|
Weak,
|
|
|
|
Strong,
|
2019-01-17 15:54:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
RumbleEffect(int fd, Motor motor);
|
2019-01-08 15:28:24 +00:00
|
|
|
bool UpdateParameters(ControlState state) override;
|
|
|
|
std::string GetName() const override;
|
|
|
|
|
2015-06-29 00:17:35 +00:00
|
|
|
private:
|
2019-01-17 15:54:07 +00:00
|
|
|
const Motor m_motor;
|
2015-06-29 00:17:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
void UpdateInput() override;
|
2016-07-14 15:50:35 +00:00
|
|
|
bool IsValid() const override;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-06-29 00:17:35 +00:00
|
|
|
~evdevDevice();
|
|
|
|
|
2019-11-16 21:40:43 +00:00
|
|
|
// Return true if node was "interesting".
|
|
|
|
bool AddNode(std::string devnode, int fd, libevdev* dev);
|
|
|
|
|
|
|
|
const char* GetUniqueID() const;
|
|
|
|
|
2015-06-29 00:17:35 +00:00
|
|
|
std::string GetName() const override { return m_name; }
|
|
|
|
std::string GetSource() const override { return "evdev"; }
|
2018-04-12 12:18:04 +00:00
|
|
|
|
2015-06-29 00:17:35 +00:00
|
|
|
private:
|
|
|
|
std::string m_name;
|
2019-11-16 21:40:43 +00:00
|
|
|
|
|
|
|
struct Node
|
|
|
|
{
|
|
|
|
std::string devnode;
|
|
|
|
int fd;
|
|
|
|
libevdev* device;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<Node> m_nodes;
|
2015-06-29 00:17:35 +00:00
|
|
|
};
|
2019-06-17 20:39:24 +00:00
|
|
|
} // namespace ciface::evdev
|