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