openMSX
Y8950KeyboardConnector.cc
Go to the documentation of this file.
4#include "checked_cast.hh"
5#include "serialize.hh"
6#include <memory>
7
8namespace openmsx {
9
11 PluggingController& pluggingController_)
12 : Connector(pluggingController_, "audiokeyboardport",
13 std::make_unique<DummyY8950KeyboardDevice>())
14{
15}
16
17void Y8950KeyboardConnector::write(byte newData, EmuTime::param time)
18{
19 if (newData != data) {
20 data = newData;
21 getPluggedKeyb().write(data, time);
22 }
23}
24
25byte Y8950KeyboardConnector::read(EmuTime::param time)
26{
27 return getPluggedKeyb().read(time);
28}
29
30byte Y8950KeyboardConnector::peek(EmuTime::param time) const
31{
32 // TODO implement proper peek
33 return const_cast<Y8950KeyboardConnector*>(this)->read(time);
34}
35
37{
38 return "MSX-AUDIO keyboard connector";
39}
40
41std::string_view Y8950KeyboardConnector::getClass() const
42{
43 return "Y8950 Keyboard Port";
44}
45
46void Y8950KeyboardConnector::plug(Pluggable& dev, EmuTime::param time)
47{
48 Connector::plug(dev, time);
49 getPluggedKeyb().write(data, time);
50}
51
53{
54 return *checked_cast<Y8950KeyboardDevice*>(&getPlugged());
55}
56
57template<typename Archive>
58void Y8950KeyboardConnector::serialize(Archive& ar, unsigned /*version*/)
59{
60 ar.template serializeBase<Connector>(*this);
61 // don't serialize 'data', done in Y8950
62}
64
65} // namespace openmsx
Represents something you can plug devices into.
Definition: Connector.hh:21
Pluggable & getPlugged() const
Returns the Pluggable currently plugged in.
Definition: Connector.hh:59
virtual void plug(Pluggable &device, EmuTime::param time)
This plugs a Pluggable in this Connector.
Definition: Connector.cc:25
Central administration of Connectors and Pluggables.
std::string_view getClass() const final
A Connector belong to a certain class.
void write(byte data, EmuTime::param time)
std::string_view getDescription() const final
Get a description for this connector.
void plug(Pluggable &dev, EmuTime::param time) override
This plugs a Pluggable in this Connector.
Y8950KeyboardConnector(PluggingController &pluggingController)
byte peek(EmuTime::param time) const
void serialize(Archive &ar, unsigned version)
Y8950KeyboardDevice & getPluggedKeyb() const
virtual void write(byte data, EmuTime::param time)=0
Send data to the device.
virtual byte read(EmuTime::param time)=0
Read data from the device.
This file implemented 3 utility functions:
Definition: Autofire.cc:9
STL namespace.
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:1021