openMSX
JoystickPort.hh
Go to the documentation of this file.
1 #ifndef JOYSTICKPORT_HH
2 #define JOYSTICKPORT_HH
3 
4 #include "Connector.hh"
5 #include "openmsx.hh"
6 
7 namespace openmsx {
8 
9 class JoystickDevice;
10 class PluggingController;
11 
13 {
14 public:
15  virtual ~JoystickPortIf() = default;
16  virtual byte read(EmuTime::param time) = 0;
17  virtual void write(byte value, EmuTime::param time) = 0;
18 protected:
19  JoystickPortIf() = default;
20 };
21 
22 class JoystickPort final : public JoystickPortIf, public Connector
23 {
24 public:
25  JoystickPort(PluggingController& pluggingController,
26  std::string name, std::string description);
27 
29 
30  // Connector
31  std::string_view getDescription() const override;
32  std::string_view getClass() const override;
33  void plug(Pluggable& device, EmuTime::param time) override;
34 
35  byte read(EmuTime::param time) override;
36  void write(byte value, EmuTime::param time) override;
37 
38  template<typename Archive>
39  void serialize(Archive& ar, unsigned version);
40 
41 private:
42  void writeDirect(byte value, EmuTime::param time);
43 
44  byte lastValue;
45  const std::string description;
46 };
47 
48 class DummyJoystickPort final : public JoystickPortIf
49 {
50 public:
51  byte read(EmuTime::param time) override;
52  void write(byte value, EmuTime::param time) override;
53 };
54 
55 } // namespace openmsx
56 
57 #endif
openmsx::DummyJoystickPort::write
void write(byte value, EmuTime::param time) override
Definition: JoystickPort.cc:78
openmsx.hh
openmsx::JoystickPort::getDescription
std::string_view getDescription() const override
Get a description for this connector.
Definition: JoystickPort.cc:21
openmsx::JoystickDevice
Definition: JoystickDevice.hh:10
openmsx::JoystickPort
Definition: JoystickPort.hh:23
openmsx::JoystickPort::getPluggedJoyDev
JoystickDevice & getPluggedJoyDev() const
Definition: JoystickPort.cc:31
openmsx::Pluggable
Definition: Pluggable.hh:12
openmsx::JoystickPortIf
Definition: JoystickPort.hh:13
openmsx::JoystickPortIf::~JoystickPortIf
virtual ~JoystickPortIf()=default
openmsx::JoystickPortIf::JoystickPortIf
JoystickPortIf()=default
openmsx::JoystickPort::serialize
void serialize(Archive &ar, unsigned version)
Definition: JoystickPort.cc:58
openmsx::DummyJoystickPort
Definition: JoystickPort.hh:49
Connector.hh
openmsx::JoystickPort::plug
void plug(Pluggable &device, EmuTime::param time) override
This plugs a Pluggable in this Connector.
Definition: JoystickPort.cc:36
openmsx::JoystickPortIf::write
virtual void write(byte value, EmuTime::param time)=0
openmsx::JoystickPort::getClass
std::string_view getClass() const override
A Connector belong to a certain class.
Definition: JoystickPort.cc:26
openmsx::Connector
Represents something you can plug devices into.
Definition: Connector.hh:21
openmsx::DummyJoystickPort::read
byte read(EmuTime::param time) override
Definition: JoystickPort.cc:73
openmsx::JoystickPort::write
void write(byte value, EmuTime::param time) override
Definition: JoystickPort.cc:47
openmsx::JoystickPortIf::read
virtual byte read(EmuTime::param time)=0
openmsx::JoystickPort::JoystickPort
JoystickPort(PluggingController &pluggingController, std::string name, std::string description)
Definition: JoystickPort.cc:13
openmsx::PluggingController
Central administration of Connectors and Pluggables.
Definition: PluggingController.hh:22
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::JoystickPort::read
byte read(EmuTime::param time) override
Definition: JoystickPort.cc:42