openMSX
Y8950KeyboardConnector.cc
Go to the documentation of this file.
4 #include "checked_cast.hh"
5 #include "serialize.hh"
6 #include <memory>
7 
8 namespace openmsx {
9 
10 Y8950KeyboardConnector::Y8950KeyboardConnector(
11  PluggingController& pluggingController_)
12  : Connector(pluggingController_, "audiokeyboardport",
14  , data(255)
15 {
16 }
17 
18 void Y8950KeyboardConnector::write(byte newData, EmuTime::param time)
19 {
20  if (newData != data) {
21  data = newData;
22  getPluggedKeyb().write(data, time);
23  }
24 }
25 
26 byte Y8950KeyboardConnector::read(EmuTime::param time)
27 {
28  return getPluggedKeyb().read(time);
29 }
30 
31 byte Y8950KeyboardConnector::peek(EmuTime::param time) const
32 {
33  // TODO implement proper peek
34  return const_cast<Y8950KeyboardConnector*>(this)->read(time);
35 }
36 
37 std::string_view Y8950KeyboardConnector::getDescription() const
38 {
39  return "MSX-AUDIO keyboard connector";
40 }
41 
42 std::string_view Y8950KeyboardConnector::getClass() const
43 {
44  return "Y8950 Keyboard Port";
45 }
46 
47 void Y8950KeyboardConnector::plug(Pluggable& dev, EmuTime::param time)
48 {
49  Connector::plug(dev, time);
50  getPluggedKeyb().write(data, time);
51 }
52 
53 Y8950KeyboardDevice& Y8950KeyboardConnector::getPluggedKeyb() const
54 {
55  return *checked_cast<Y8950KeyboardDevice*>(&getPlugged());
56 }
57 
58 template<typename Archive>
59 void 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
bool getEnum() const noexcept
Definition: EnumSetting.hh:96
Represents something you can plug devices into.
Definition: Connector.hh:20
std::string_view getDescription() const final override
Get a description for this connector.
Y8950KeyboardConnector(PluggingController &pluggingController)
Central administration of Connectors and Pluggables.
byte peek(EmuTime::param time) const
void plug(Pluggable &dev, EmuTime::param time) override
This plugs a Pluggable in this Connector.
std::string_view getClass() const final override
A Connector belong to a certain class.
void write(byte data, EmuTime::param time)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
void serialize(Archive &ar, unsigned version)
Y8950KeyboardDevice & getPluggedKeyb() const