openMSX
MSXJoystick.hh
Go to the documentation of this file.
1#ifndef MSXJOYSTICK_HH
2#define MSXJOYSTICK_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 MSXJoystick final : public JoystickDevice, private MSXEventListener
22 , private StateChangeListener
23{
24public:
25 MSXJoystick(CommandController& commandController,
26 MSXEventDistributor& eventDistributor,
27 StateChangeDistributor& stateChangeDistributor,
28 JoystickManager& joystickManager,
29 uint8_t id);
30 ~MSXJoystick() 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(const 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 // MSXJoystickDevice
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
57private:
58 CommandController& commandController;
59 MSXEventDistributor& eventDistributor;
60 StateChangeDistributor& stateChangeDistributor;
61 JoystickManager& joystickManager;
62 StringSetting configSetting;
63
64 // up, down, left, right, a, b (in sync with order in JoystickDevice)
65 std::array<std::vector<BooleanInput>, 6> bindings; // calculated from 'configSetting'
66
67 const std::string description;
68 const uint8_t id;
69 uint8_t status = JOY_UP | JOY_DOWN | JOY_LEFT | JOY_RIGHT |
71 bool pin8;
72};
73
74} // namespace openmsx
75
76#endif
uintptr_t id
Represents something you can plug devices into.
Definition Connector.hh:21
static constexpr uint8_t JOY_BUTTONA
static constexpr uint8_t JOY_RIGHT
static constexpr uint8_t JOY_LEFT
static constexpr uint8_t JOY_DOWN
static constexpr uint8_t JOY_UP
static constexpr uint8_t JOY_BUTTONB
static TclObject getDefaultConfig(JoystickId joyId, const JoystickManager &joystickManager)
~MSXJoystick() override
void serialize(Archive &ar, unsigned version)
Base class for all external MSX state changing events.
This file implemented 3 utility functions:
Definition Autofire.cc:11
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, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:445