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