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