OXYGENHUB
◆ main openmsx / src / input / JoyTap.hh
1.4 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef JOYTAP_HH
2
#define JOYTAP_HH
3
4
#include "JoystickDevice.hh"
5
#include "JoystickPort.hh"
6
#include "serialize_meta.hh"
7
#include <array>
8
#include <optional>
9
#include <string_view>
10
11
namespace openmsx {
12
13
class PluggingController;
14
15
/** This device is plugged in into the joy-ports and consolidates several other
16
 * joysticks plugged into it. This JoyTap simply ANDs all the joystick
17
 * outputs, acting as a simple wiring of all digital joysticks into one
18
 * connector.
19
 * This is the base class for the NinjaTap device and the FNano2 multiplayer
20
 * extension, who basically have other read and write methods
21
 */
22
class JoyTap : public JoystickDevice
23
{
24
public:
25
	JoyTap(PluggingController& pluggingController, std::string name);
26
27
	// Pluggable
28
	[[nodiscard]] zstring_view getName() const override;
29
	[[nodiscard]] zstring_view getDescription() const override;
30
	void plugHelper(Connector& connector, EmuTime time) override;
31
	void unplugHelper(EmuTime time) override;
32
33
	// JoystickDevice
34
	[[nodiscard]] uint8_t read(EmuTime time) override;
35
	void write(uint8_t value, EmuTime time) override;
36
37
	template<typename Archive>
38
	void serialize(Archive& ar, unsigned version);
39
40
protected:
41
	void createPorts(std::string_view description, EmuTime time);
42
43
protected:
44
	std::array<std::optional<JoystickPort>, 4> slaves;
45
	PluggingController& pluggingController;
46
47
private:
48
	const std::string name;
49
};
50
51
REGISTER_BASE_NAME_HELPER(JoyTap, "JoyTap");
52
53
} // namespace openmsx
54
55
#endif