openMSX
KeyJoystick.hh
Go to the documentation of this file.
1 #ifndef KEYJOYSTICK_HH
2 #define KEYJOYSTICK_HH
3 
4 #include "JoystickDevice.hh"
5 #include "MSXEventListener.hh"
6 #include "StateChangeListener.hh"
7 #include "KeyCodeSetting.hh"
8 #include "serialize_meta.hh"
9 
10 namespace openmsx {
11 
12 class CommandController;
13 class MSXEventDistributor;
14 class StateChangeDistributor;
15 
16 class KeyJoystick final : public JoystickDevice, private MSXEventListener
17  , private StateChangeListener
18 {
19 public:
20  enum ID { ID1, ID2, UNKNOWN };
21 
22 public:
23  KeyJoystick(CommandController& commandController,
24  MSXEventDistributor& eventDistributor,
25  StateChangeDistributor& stateChangeDistributor,
26  ID id);
27  ~KeyJoystick() override;
28 
29  template<typename Archive>
30  void serialize(Archive& ar, unsigned version);
31 
32 private:
33  // Pluggable
34  [[nodiscard]] std::string_view getName() const override;
35  [[nodiscard]] std::string_view getDescription() const override;
36  void plugHelper(Connector& connector, EmuTime::param time) override;
37  void unplugHelper(EmuTime::param time) override;
38 
39  // KeyJoystickDevice
40  [[nodiscard]] byte read(EmuTime::param time) override;
41  void write(byte value, EmuTime::param time) override;
42 
43  // MSXEventListener
44  void signalMSXEvent(const Event& event,
45  EmuTime::param time) noexcept override;
46  // StateChangeListener
47  void signalStateChange(const StateChange& event) override;
48  void stopReplay(EmuTime::param time) noexcept override;
49 
50 private:
51  MSXEventDistributor& eventDistributor;
52  StateChangeDistributor& stateChangeDistributor;
53  KeyCodeSetting up;
54  KeyCodeSetting down;
55  KeyCodeSetting left;
56  KeyCodeSetting right;
57  KeyCodeSetting trigA;
58  KeyCodeSetting trigB;
59  const ID id;
60 
61  byte status;
62  bool pin8;
63 };
65 
66 } // namespace openmsx
67 
68 #endif
Represents something you can plug devices into.
Definition: Connector.hh:21
KeyJoystick(CommandController &commandController, MSXEventDistributor &eventDistributor, StateChangeDistributor &stateChangeDistributor, ID id)
Definition: KeyJoystick.cc:52
~KeyJoystick() override
Definition: KeyJoystick.cc:76
void serialize(Archive &ar, unsigned version)
Definition: KeyJoystick.cc:177
Base class for all external MSX state changing events.
Definition: StateChange.hh:20
This file implemented 3 utility functions:
Definition: Autofire.cc:9
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)