openMSX
PluggableFactory.cc
Go to the documentation of this file.
1#include "PluggableFactory.hh"
2
4#include "MSXMotherBoard.hh"
5#include "Reactor.hh"
6#include "JoyMega.hh"
7#include "ArkanoidPad.hh"
9#include "JoyTap.hh"
10#include "NinjaTap.hh"
11#include "SETetrisDongle.hh"
12#include "MagicKey.hh"
13#include "MSXJoystick.hh"
14#include "KeyJoystick.hh"
15#include "MidiInReader.hh"
16#include "MidiOutLogger.hh"
17#include "Mouse.hh"
18#include "Paddle.hh"
19#include "Trackball.hh"
20#include "Touchpad.hh"
21#include "PrinterPortLogger.hh"
22#include "PrinterPortSimpl.hh"
23#include "Printer.hh"
24#include "RS232Tester.hh"
25#include "WavAudioInput.hh"
26#include "components.hh"
27#if defined(_WIN32)
28#include "MidiInWindows.hh"
29#include "MidiOutWindows.hh"
30#endif
31#if defined(__APPLE__)
32#include "MidiInCoreMIDI.hh"
33#include "MidiOutCoreMIDI.hh"
34#endif
35#if COMPONENT_ALSAMIDI
36#include "MidiSessionALSA.hh"
37#endif
38#include <memory>
39
40namespace openmsx {
41
43 MSXMotherBoard& motherBoard)
44{
45 auto& reactor = motherBoard.getReactor();
46 auto& scheduler = motherBoard.getScheduler();
47 auto& commandController = motherBoard.getCommandController();
48 auto& msxEventDistributor = motherBoard.getMSXEventDistributor();
49 auto& stateChangeDistributor = motherBoard.getStateChangeDistributor();
50 auto& eventDistributor = reactor.getEventDistributor();
51 auto& joystickManager = reactor.getInputEventGenerator().getJoystickManager();
52 auto& display = reactor.getDisplay();
53 // Input devices:
54 // TODO: Support hot-plugging of input devices:
55 // - additional key joysticks can be created by the user
56 // - real joysticks and mice can be hot-plugged (USB)
57 controller.registerPluggable(std::make_unique<ArkanoidPad>(
58 msxEventDistributor, stateChangeDistributor));
59 controller.registerPluggable(std::make_unique<Mouse>(
60 msxEventDistributor, stateChangeDistributor));
61 controller.registerPluggable(std::make_unique<Paddle>(
62 msxEventDistributor, stateChangeDistributor));
63 controller.registerPluggable(std::make_unique<Trackball>(
64 msxEventDistributor, stateChangeDistributor));
65 controller.registerPluggable(std::make_unique<Touchpad>(
66 msxEventDistributor, stateChangeDistributor,
67 display, commandController));
68 controller.registerPluggable(std::make_unique<JoyTap>(
69 controller, "joytap"));
70 controller.registerPluggable(std::make_unique<NinjaTap>(
71 controller, "ninjatap"));
72 controller.registerPluggable(std::make_unique<MSXJoystick>(
73 commandController, msxEventDistributor,
74 stateChangeDistributor, joystickManager, 1)); // msxjoystick1
75 controller.registerPluggable(std::make_unique<MSXJoystick>(
76 commandController, msxEventDistributor,
77 stateChangeDistributor, joystickManager, 2)); // msxjoystick2
78 controller.registerPluggable(std::make_unique<JoyMega>(
79 commandController, msxEventDistributor,
80 stateChangeDistributor, joystickManager, 1)); // joymega1
81 controller.registerPluggable(std::make_unique<JoyMega>(
82 commandController, msxEventDistributor,
83 stateChangeDistributor, joystickManager, 2)); // joymega2
84 controller.registerPluggable(std::make_unique<KeyJoystick>(
85 commandController, msxEventDistributor,
86 stateChangeDistributor, KeyJoystick::ID1));
87 controller.registerPluggable(std::make_unique<KeyJoystick>(
88 commandController, msxEventDistributor,
89 stateChangeDistributor, KeyJoystick::ID2));
90
91 // Dongles
92 controller.registerPluggable(std::make_unique<SETetrisDongle>());
93 controller.registerPluggable(std::make_unique<MagicKey>());
94
95 // Logging:
96 controller.registerPluggable(std::make_unique<PrinterPortLogger>(
97 commandController));
98 controller.registerPluggable(std::make_unique<MidiOutLogger>(
99 commandController));
100
101 // Serial communication:
102 controller.registerPluggable(std::make_unique<RS232Tester>(
103 eventDistributor, scheduler, commandController));
104
105 // Sampled audio:
106 controller.registerPluggable(std::make_unique<PrinterPortSimpl>(
107 *motherBoard.getMachineConfig()));
108 controller.registerPluggable(std::make_unique<WavAudioInput>(
109 commandController));
110
111 // MIDI:
112#if !defined(_WIN32)
113 // Devices and pipes are not usable as files on Windows, and MidiInReader
114 // reads all data as soon as it becomes available, so this pluggable is
115 // not useful on Windows.
116 controller.registerPluggable(std::make_unique<MidiInReader>(
117 eventDistributor, scheduler, commandController));
118#endif
119#if defined(_WIN32)
120 MidiInWindows::registerAll(eventDistributor, scheduler, controller);
121 MidiOutWindows::registerAll(controller);
122#endif
123#if defined(__APPLE__)
124 controller.registerPluggable(std::make_unique<MidiInCoreMIDIVirtual>(
125 eventDistributor, scheduler));
126 MidiInCoreMIDI::registerAll(eventDistributor, scheduler, controller);
127 controller.registerPluggable(std::make_unique<MidiOutCoreMIDIVirtual>());
128 MidiOutCoreMIDI::registerAll(controller);
129#endif
130#if COMPONENT_ALSAMIDI
131 MidiSessionALSA::registerAll(controller, reactor.getCliComm(), eventDistributor, scheduler);
132#endif
133
134 // Printers
135 controller.registerPluggable(std::make_unique<ImagePrinterMSX>(
136 motherBoard));
137 controller.registerPluggable(std::make_unique<ImagePrinterEpson>(
138 motherBoard));
139}
140
141} // namespace openmsx
Dot Matrix Printer Emulation code mostly copied from blueMSX but changed to: OO-style save to png ima...
const HardwareConfig * getMachineConfig() const
MSXEventDistributor & getMSXEventDistributor()
StateChangeDistributor & getStateChangeDistributor()
CommandController & getCommandController()
static void registerAll(PluggingController &controller, CliComm &cliComm, EventDistributor &eventDistributor, Scheduler &scheduler)
static void createAll(PluggingController &controller, MSXMotherBoard &motherBoard)
Central administration of Connectors and Pluggables.
void registerPluggable(std::unique_ptr< Pluggable > pluggable)
Add a Pluggable to the registry.
CliComm & getCliComm()
Access to the MSX specific CliComm, so that Connectors can get it.
This file implemented 3 utility functions:
Definition Autofire.cc:9