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 "RS232Net.hh"
26#include "WavAudioInput.hh"
27#include "components.hh"
28#if defined(_WIN32)
29#include "MidiInWindows.hh"
30#include "MidiOutWindows.hh"
31#endif
32#if defined(__APPLE__)
33#include "MidiInCoreMIDI.hh"
34#include "MidiOutCoreMIDI.hh"
35#endif
36#if COMPONENT_ALSAMIDI
37#include "MidiSessionALSA.hh"
38#endif
39#include <memory>
40
41namespace openmsx {
42
44 MSXMotherBoard& motherBoard)
45{
46 auto& reactor = motherBoard.getReactor();
47 auto& scheduler = motherBoard.getScheduler();
48 auto& commandController = motherBoard.getCommandController();
49 auto& msxEventDistributor = motherBoard.getMSXEventDistributor();
50 auto& stateChangeDistributor = motherBoard.getStateChangeDistributor();
51 auto& eventDistributor = reactor.getEventDistributor();
52 auto& joystickManager = reactor.getInputEventGenerator().getJoystickManager();
53 auto& display = reactor.getDisplay();
54 // Input devices:
55 // TODO: Support hot-plugging of input devices:
56 // - additional key joysticks can be created by the user
57 // - real joysticks and mice can be hot-plugged (USB)
58 controller.registerPluggable(std::make_unique<ArkanoidPad>(
59 msxEventDistributor, stateChangeDistributor));
60 controller.registerPluggable(std::make_unique<Mouse>(
61 msxEventDistributor, stateChangeDistributor));
62 controller.registerPluggable(std::make_unique<Paddle>(
63 msxEventDistributor, stateChangeDistributor));
64 controller.registerPluggable(std::make_unique<Trackball>(
65 msxEventDistributor, stateChangeDistributor));
66 controller.registerPluggable(std::make_unique<Touchpad>(
67 msxEventDistributor, stateChangeDistributor,
68 display, commandController));
69 controller.registerPluggable(std::make_unique<JoyTap>(
70 controller, "joytap"));
71 controller.registerPluggable(std::make_unique<NinjaTap>(
72 controller, "ninjatap"));
73 controller.registerPluggable(std::make_unique<MSXJoystick>(
74 commandController, msxEventDistributor,
75 stateChangeDistributor, joystickManager, 1)); // msxjoystick1
76 controller.registerPluggable(std::make_unique<MSXJoystick>(
77 commandController, msxEventDistributor,
78 stateChangeDistributor, joystickManager, 2)); // msxjoystick2
79 controller.registerPluggable(std::make_unique<JoyMega>(
80 commandController, msxEventDistributor,
81 stateChangeDistributor, joystickManager, 1)); // joymega1
82 controller.registerPluggable(std::make_unique<JoyMega>(
83 commandController, msxEventDistributor,
84 stateChangeDistributor, joystickManager, 2)); // joymega2
85 controller.registerPluggable(std::make_unique<KeyJoystick>(
86 commandController, msxEventDistributor,
87 stateChangeDistributor, KeyJoystick::ID1));
88 controller.registerPluggable(std::make_unique<KeyJoystick>(
89 commandController, msxEventDistributor,
90 stateChangeDistributor, KeyJoystick::ID2));
91
92 // Dongles
93 controller.registerPluggable(std::make_unique<SETetrisDongle>());
94 controller.registerPluggable(std::make_unique<MagicKey>());
95
96 // Logging:
97 controller.registerPluggable(std::make_unique<PrinterPortLogger>(
98 commandController));
99 controller.registerPluggable(std::make_unique<MidiOutLogger>(
100 commandController));
101
102 // Serial communication:
103 controller.registerPluggable(std::make_unique<RS232Tester>(
104 eventDistributor, scheduler, commandController));
105 controller.registerPluggable(std::make_unique<RS232Net>(
106 eventDistributor, scheduler, commandController));
107
108 // Sampled audio:
109 controller.registerPluggable(std::make_unique<PrinterPortSimpl>(
110 *motherBoard.getMachineConfig()));
111 controller.registerPluggable(std::make_unique<WavAudioInput>(
112 commandController));
113
114 // MIDI:
115#if !defined(_WIN32)
116 // Devices and pipes are not usable as files on Windows, and MidiInReader
117 // reads all data as soon as it becomes available, so this pluggable is
118 // not useful on Windows.
119 controller.registerPluggable(std::make_unique<MidiInReader>(
120 eventDistributor, scheduler, commandController));
121#endif
122#if defined(_WIN32)
123 MidiInWindows::registerAll(eventDistributor, scheduler, controller);
124 MidiOutWindows::registerAll(controller);
125#endif
126#if defined(__APPLE__)
127 controller.registerPluggable(std::make_unique<MidiInCoreMIDIVirtual>(
128 eventDistributor, scheduler));
129 MidiInCoreMIDI::registerAll(eventDistributor, scheduler, controller);
130 controller.registerPluggable(std::make_unique<MidiOutCoreMIDIVirtual>());
131 MidiOutCoreMIDI::registerAll(controller);
132#endif
133#if COMPONENT_ALSAMIDI
134 MidiSessionALSA::registerAll(controller, reactor.getCliComm(), eventDistributor, scheduler);
135#endif
136
137 // Printers
138 controller.registerPluggable(std::make_unique<ImagePrinterMSX>(
139 motherBoard));
140 controller.registerPluggable(std::make_unique<ImagePrinterEpson>(
141 motherBoard));
142}
143
144} // 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