Debian Codegraph @

Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.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 <map>
7 #include <string>
8 #include <vector>
9
10 #include "InputCommon/ControllerInterface/ControllerInterface.h"
11
12 namespace ciface::Pipes
13 {
14 // To create a piped controller input, create a named pipe in the
15 // Pipes directory and write commands out to it. Commands are separated
16 // by a newline character, with spaces separating command tokens.
17 // Command syntax is as follows, where curly brackets are one-of and square
18 // brackets are inclusive numeric ranges. Cases are sensitive. Numeric inputs
19 // are clamped to [0, 1] and otherwise invalid commands are discarded.
20 // {PRESS, RELEASE} {A, B, X, Y, Z, START, L, R, D_UP, D_DOWN, D_LEFT, D_RIGHT}
21 // SET {L, R} [0, 1]
22 // SET {MAIN, C} [0, 1] [0, 1]
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 } // namespace ciface::Pipes