| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <map> |
| 7 |
#include <string> |
| 8 |
#include <vector> |
| 9 |
|
| 10 |
#include "InputCommon/ControllerInterface/ControllerInterface.h" |
| 11 |
|
| 12 |
namespace ciface::Pipes |
| 13 |
{ |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface); |
| 25 |
|
| 26 |
class PipeDevice : public Core::Device |
| 27 |
{ |
| 28 |
public: |
| 29 |
PipeDevice(int fd, std::string name); |
| 30 |
~PipeDevice(); |
| 31 |
|
| 32 |
Core::DeviceRemoval UpdateInput() override; |
| 33 |
std::string GetName() const override { return m_name; } |
| 34 |
std::string GetSource() const override { return "Pipe"; } |
| 35 |
|
| 36 |
private: |
| 37 |
class PipeInput : public Input |
| 38 |
{ |
| 39 |
public: |
| 40 |
PipeInput(const std::string& name) : m_name(name), m_state(0.0) {} |
| 41 |
std::string GetName() const override { return m_name; } |
| 42 |
ControlState GetState() const override { return m_state; } |
| 43 |
void SetState(ControlState state) { m_state = state; } |
| 44 |
|
| 45 |
private: |
| 46 |
const std::string m_name; |
| 47 |
ControlState m_state; |
| 48 |
}; |
| 49 |
|
| 50 |
void AddAxis(const std::string& name, double value); |
| 51 |
void ParseCommand(const std::string& command); |
| 52 |
void SetAxis(const std::string& entry, double value); |
| 53 |
|
| 54 |
const int m_fd; |
| 55 |
const std::string m_name; |
| 56 |
std::string m_buf; |
| 57 |
std::map<std::string, PipeInput*> m_buttons; |
| 58 |
std::map<std::string, PipeInput*> m_axes; |
| 59 |
}; |
| 60 |
} |