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 , data(255)
15{
16}
17
18void Y8950KeyboardConnector::write(byte newData, EmuTime::param time)
19{
20 if (newData != data) {
21 data = newData;
22 getPluggedKeyb().write(data, time);
23 }
24}
25
26byte Y8950KeyboardConnector::read(EmuTime::param time)
27{
28 return getPluggedKeyb().read(time);
29}
30
31byte Y8950KeyboardConnector::peek(EmuTime::param time) const
32{
33 // TODO implement proper peek
34 return const_cast<Y8950KeyboardConnector*>(this)->read(time);
35}
36
38{
39 return "MSX-AUDIO keyboard connector";
40}
41
42std::string_view Y8950KeyboardConnector::getClass() const
43{
44 return "Y8950 Keyboard Port";
45}
46
47void Y8950KeyboardConnector::plug(Pluggable& dev, EmuTime::param time)
48{
49 Connector::plug(dev, time);
50 getPluggedKeyb().write(data, time);
51}
52
54{
55 return *checked_cast<Y8950KeyboardDevice*>(&getPlugged());
56}
57
58template<typename Archive>
59void Y8950KeyboardConnector::serialize(Archive& ar, unsigned /*version*/)
60{
61 ar.template serializeBase<Connector>(*this);
62 // don't serialize 'data', done in Y8950
63}
65
66} // 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:1009