openMSX
JoyMega.hh
Go to the documentation of this file.
1#ifndef JOYMEGA_HH
2#define JOYMEGA_HH
3
4#include "JoystickDevice.hh"
5
6#include "BooleanInput.hh"
7#include "MSXEventListener.hh"
9#include "StringSetting.hh"
10
11#include <array>
12#include <vector>
13
14namespace openmsx {
15
16class CommandController;
17class JoystickManager;
18class MSXEventDistributor;
19class StateChangeDistributor;
20
21class JoyMega final : public JoystickDevice, private MSXEventListener
22 , private StateChangeListener
23{
24public:
25 JoyMega(CommandController& commandController,
26 MSXEventDistributor& eventDistributor,
27 StateChangeDistributor& stateChangeDistributor,
28 JoystickManager& joystickManager,
29 uint8_t id);
30 ~JoyMega() override ;
31
32 [[nodiscard]] static TclObject getDefaultConfig(JoystickId joyId, const JoystickManager& joystickManager);
33
34 template<typename Archive>
35 void serialize(Archive& ar, unsigned version);
36
37private:
38 void checkJoystickConfig(TclObject& newValue);
39
40 // Pluggable
41 [[nodiscard]] std::string_view getName() const override;
42 [[nodiscard]] std::string_view getDescription() const override;
43 void plugHelper(Connector& connector, EmuTime::param time) override;
44 void unplugHelper(EmuTime::param time) override;
45
46 // JoystickDevice
47 [[nodiscard]] uint8_t read(EmuTime::param time) override;
48 void write(uint8_t value, EmuTime::param time) override;
49
50 // MSXEventListener
51 void signalMSXEvent(const Event& event,
52 EmuTime::param time) noexcept override;
53 // StateChangeListener
54 void signalStateChange(const StateChange& event) override;
55 void stopReplay(EmuTime::param time) noexcept override;
56
57 void plugHelper2();
58 void checkTime(EmuTime::param time);
59
60private:
61 CommandController& commandController;
62 MSXEventDistributor& eventDistributor;
63 StateChangeDistributor& stateChangeDistributor;
64 JoystickManager& joystickManager;
65 StringSetting configSetting;
66
67 // 0...3 : up, down, left, right
68 // 4...7 : a, b, c, start
69 // 8..11 : x, y, z, select
70 std::array<std::vector<BooleanInput>, 12> bindings; // calculated from 'configSetting'
71
72 const std::string description;
73 EmuTime lastTime = EmuTime::zero();
74 unsigned status = 0xfff;
75 uint8_t cycle; // 0-7
76 uint8_t cycleMask; // 1 or 7
77 const uint8_t id;
78};
79
80} // namespace openmsx
81
82#endif
uintptr_t id
Represents something you can plug devices into.
Definition Connector.hh:21
static TclObject getDefaultConfig(JoystickId joyId, const JoystickManager &joystickManager)
Definition JoyMega.cc:48
~JoyMega() override
Definition JoyMega.cc:93
void serialize(Archive &ar, unsigned version)
Definition JoyMega.cc:271
Base class for all external MSX state changing events.
This file implemented 3 utility functions:
Definition Autofire.cc:9
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:452