openMSX
Mouse.hh
Go to the documentation of this file.
1 #ifndef MOUSE_HH
2 #define MOUSE_HH
3 
4 #include "JoystickDevice.hh"
5 #include "MSXEventListener.hh"
6 #include "StateChangeListener.hh"
7 #include "serialize_meta.hh"
8 
9 namespace openmsx {
10 
11 class MSXEventDistributor;
12 class StateChangeDistributor;
13 
14 class Mouse final : public JoystickDevice, private MSXEventListener
15  , private StateChangeListener
16 {
17 public:
18  Mouse(MSXEventDistributor& eventDistributor,
19  StateChangeDistributor& stateChangeDistributor);
20  ~Mouse() override;
21 
22  template<typename Archive>
23  void serialize(Archive& ar, unsigned version);
24 
25 private:
26  // Pluggable
27  [[nodiscard]] std::string_view getName() const override;
28  [[nodiscard]] std::string_view getDescription() const override;
29  void plugHelper(Connector& connector, EmuTime::param time) override;
30  void unplugHelper(EmuTime::param time) override;
31 
32  // JoystickDevice
33  [[nodiscard]] byte read(EmuTime::param time) override;
34  void write(byte value, EmuTime::param time) override;
35 
36  // MSXEventListener
37  void signalMSXEvent(const Event& event,
38  EmuTime::param time) noexcept override;
39  // StateChangeListener
40  void signalStateChange(const StateChange& event) override;
41  void stopReplay(EmuTime::param time) noexcept override;
42 
43  void createMouseStateChange(EmuTime::param time,
44  int deltaX, int deltaY, byte press, byte release);
45  void emulateJoystick();
46  void plugHelper2();
47 
48 private:
49  MSXEventDistributor& eventDistributor;
50  StateChangeDistributor& stateChangeDistributor;
51  EmuTime lastTime;
52  int phase;
53  int xrel, yrel; // latched X/Y values, these are returned to the MSX
54  int curxrel, curyrel; // running X/Y values, already scaled down
55  int absHostX, absHostY; // running X/Y values, not yet scaled down
56  byte status;
57  bool mouseMode;
58 };
60 
61 } // namespace openmsx
62 
63 #endif
Represents something you can plug devices into.
Definition: Connector.hh:21
Mouse(MSXEventDistributor &eventDistributor, StateChangeDistributor &stateChangeDistributor)
Definition: Mouse.cc:52
~Mouse() override
Definition: Mouse.cc:65
void serialize(Archive &ar, unsigned version)
Definition: Mouse.cc:332
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)