OXYGENHUB
◆ main openmsx / src / PluggableFactory.cc
5.6 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "PluggableFactory.hh"
2
3
#include "JoyHandle.hh"
4
#include "ArkanoidPad.hh"
5
#include "CircuitDesignerRDDongle.hh"
6
#include "InputEventGenerator.hh"
7
#include "JoyMega.hh"
8
#include "JoyTap.hh"
9
#include "MSXJoystick.hh"
10
#include "MSXMotherBoard.hh"
11
#include "MagicKey.hh"
12
#include "MidiInReader.hh"
13
#include "MidiOutLogger.hh"
14
#include "Mouse.hh"
15
#include "NinjaTap.hh"
16
#include "Paddle.hh"
17
#include "PluggingController.hh"
18
#include "Plotter.hh"
19
#include "Printer.hh"
20
#include "PrinterPortLogger.hh"
21
#include "PrinterPortSimpl.hh"
22
#include "RS232Net.hh"
23
#include "RS232Raw.hh"
24
#include "RS232Tester.hh"
25
#include "Reactor.hh"
26
#include "SETetrisDongle.hh"
27
#include "Touchpad.hh"
28
#include "Trackball.hh"
29
#include "WavAudioInput.hh"
30
31
#include "components.hh"
32
#if	defined(_WIN32)
33
#include "MidiInWindows.hh"
34
#include "MidiOutWindows.hh"
35
#endif
36
#ifdef __APPLE__
37
#include "MidiInCoreMIDI.hh"
38
#include "MidiOutCoreMIDI.hh"
39
#endif
40
#if COMPONENT_ALSAMIDI
41
#include "MidiSessionALSA.hh"
42
#endif
43
44
#include <memory>
45
46
namespace openmsx {
47
48
void PluggableFactory::createAll(PluggingController& controller,
49
                                 MSXMotherBoard& motherBoard)
50
{
51
	auto& reactor                = motherBoard.getReactor();
52
	auto& scheduler              = motherBoard.getScheduler();
53
	auto& commandController      = motherBoard.getCommandController();
54
	auto& msxEventDistributor    = motherBoard.getMSXEventDistributor();
55
	auto& stateChangeDistributor = motherBoard.getStateChangeDistributor();
56
	auto& eventDistributor       = reactor.getEventDistributor();
57
	auto& joystickManager         = reactor.getInputEventGenerator().getJoystickManager();
58
	auto& display                = reactor.getDisplay();
59
	// Input devices:
60
	// TODO: Support hot-plugging of input devices:
61
	// - additional key joysticks can be created by the user
62
	// - real joysticks and mice can be hot-plugged (USB)
63
	controller.registerPluggable(std::make_unique<ArkanoidPad>(
64
		msxEventDistributor, stateChangeDistributor));
65
	controller.registerPluggable(std::make_unique<Mouse>(
66
		msxEventDistributor, stateChangeDistributor, display));
67
	controller.registerPluggable(std::make_unique<Paddle>(
68
		msxEventDistributor, stateChangeDistributor));
69
	controller.registerPluggable(std::make_unique<Trackball>(
70
		msxEventDistributor, stateChangeDistributor));
71
	controller.registerPluggable(std::make_unique<Touchpad>(
72
		msxEventDistributor, stateChangeDistributor,
73
		display, commandController));
74
	controller.registerPluggable(std::make_unique<JoyTap>(
75
		controller, "joytap"));
76
	controller.registerPluggable(std::make_unique<NinjaTap>(
77
		controller, "ninjatap"));
78
	controller.registerPluggable(std::make_unique<MSXJoystick>(
79
		commandController, msxEventDistributor,
80
		stateChangeDistributor, joystickManager, 1)); // msxjoystick1
81
	controller.registerPluggable(std::make_unique<MSXJoystick>(
82
		commandController, msxEventDistributor,
83
		stateChangeDistributor, joystickManager, 2)); // msxjoystick2
84
	controller.registerPluggable(std::make_unique<JoyMega>(
85
		commandController, msxEventDistributor,
86
		stateChangeDistributor, joystickManager, 1)); // joymega1
87
	controller.registerPluggable(std::make_unique<JoyMega>(
88
		commandController, msxEventDistributor,
89
		stateChangeDistributor, joystickManager, 2)); // joymega2
90
	controller.registerPluggable(std::make_unique<JoyHandle>(
91
		commandController, msxEventDistributor,
92
		stateChangeDistributor, joystickManager, 1)); // joyhandle1
93
	controller.registerPluggable(std::make_unique<JoyHandle>(
94
		commandController, msxEventDistributor,
95
		stateChangeDistributor, joystickManager, 2)); // joyhandle2
96
97
	// Dongles
98
	controller.registerPluggable(std::make_unique<SETetrisDongle>());
99
	controller.registerPluggable(std::make_unique<MagicKey>());
100
	controller.registerPluggable(std::make_unique<CircuitDesignerRDDongle>());
101
102
	// Logging:
103
	controller.registerPluggable(std::make_unique<PrinterPortLogger>(
104
		commandController));
105
	controller.registerPluggable(std::make_unique<MidiOutLogger>(
106
		commandController));
107
108
	// Serial communication:
109
	controller.registerPluggable(std::make_unique<RS232Tester>(
110
		eventDistributor, scheduler, commandController));
111
	controller.registerPluggable(std::make_unique<RS232Net>(
112
		eventDistributor, scheduler, commandController));
113
	controller.registerPluggable(std::make_unique<RS232Raw>(
114
		eventDistributor, scheduler, commandController));
115
116
	// Sampled audio:
117
	controller.registerPluggable(std::make_unique<PrinterPortSimpl>(
118
		*motherBoard.getMachineConfig()));
119
	controller.registerPluggable(std::make_unique<WavAudioInput>(
120
		commandController));
121
122
	// MIDI:
123
#ifndef _WIN32
124
	// Devices and pipes are not usable as files on Windows, and MidiInReader
125
	// reads all data as soon as it becomes available, so this pluggable is
126
	// not useful on Windows.
127
	controller.registerPluggable(std::make_unique<MidiInReader>(
128
		eventDistributor, scheduler, commandController));
129
#endif
130
#ifdef _WIN32
131
	MidiInWindows::registerAll(eventDistributor, scheduler, controller);
132
	MidiOutWindows::registerAll(controller);
133
#endif
134
#ifdef __APPLE__
135
	controller.registerPluggable(std::make_unique<MidiInCoreMIDIVirtual>(
136
		eventDistributor, scheduler));
137
	MidiInCoreMIDI::registerAll(eventDistributor, scheduler, controller);
138
	controller.registerPluggable(std::make_unique<MidiOutCoreMIDIVirtual>());
139
	MidiOutCoreMIDI::registerAll(controller);
140
#endif
141
#if COMPONENT_ALSAMIDI
142
	MidiSessionALSA::registerAll(controller, reactor.getCliComm(), eventDistributor, scheduler);
143
#endif
144
145
	// Printers
146
	controller.registerPluggable(std::make_unique<ImagePrinterMSX>(
147
		motherBoard));
148
	controller.registerPluggable(std::make_unique<ImagePrinterEpson>(
149
		motherBoard));
150
	controller.registerPluggable(std::make_unique<MSXPlotter>(
151
		motherBoard));
152
}
153
154
} // namespace openmsx