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 "Clock.hh"
8 #include "serialize_meta.hh"
9 
10 namespace openmsx {
11 
12 class MSXEventDistributor;
13 class StateChangeDistributor;
14 
15 class Mouse : public JoystickDevice, private MSXEventListener
16  , private StateChangeListener
17 {
18 public:
19  Mouse(MSXEventDistributor& eventDistributor,
20  StateChangeDistributor& stateChangeDistributor);
21  virtual ~Mouse();
22 
23  template<typename Archive>
24  void serialize(Archive& ar, unsigned version);
25 
26 private:
27  // Pluggable
28  virtual const std::string& getName() const;
29  virtual string_ref getDescription() const;
30  virtual void plugHelper(Connector& connector, EmuTime::param time);
31  virtual void unplugHelper(EmuTime::param time);
32 
33  // JoystickDevice
34  virtual byte read(EmuTime::param time);
35  virtual void write(byte value, EmuTime::param time);
36 
37  // MSXEventListener
38  virtual void signalEvent(const std::shared_ptr<const Event>& event,
39  EmuTime::param time);
40  // StateChangeListener
41  virtual void signalStateChange(const std::shared_ptr<StateChange>& event);
42  virtual void stopReplay(EmuTime::param time);
43 
44  void createMouseStateChange(EmuTime::param time,
45  int deltaX, int deltaY, byte press, byte release);
46  void emulateJoystick();
47  void plugHelper2();
48 
49  MSXEventDistributor& eventDistributor;
50  StateChangeDistributor& stateChangeDistributor;
51  Clock<1000> lastTime; // ms
52  int faze;
53  int xrel, yrel;
54  int curxrel, curyrel;
55  int absHostX, absHostY;
56  byte status;
57  bool mouseMode;
58 };
60 
61 } // namespace openmsx
62 
63 #endif