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 
28  JoystickDevice& getPluggedJoyDev() const;
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
Represents something you can plug devices into.
Definition: Connector.hh:20
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
Central administration of Connectors and Pluggables.
virtual byte read(EmuTime::param time)=0
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
virtual ~JoystickPortIf()=default
virtual void write(byte value, EmuTime::param time)=0
void serialize(Archive &ar, T &t, unsigned version)