openMSX
Touchpad.hh
Go to the documentation of this file.
1#ifndef TOUCHPAD_HH
2#define TOUCHPAD_HH
3
4#include "EmuTime.hh"
5#include "JoystickDevice.hh"
6#include "MSXEventListener.hh"
8#include "StringSetting.hh"
9#include "gl_mat.hh"
10
11namespace openmsx {
12
13class MSXEventDistributor;
14class StateChangeDistributor;
15class Display;
16class CommandController;
17class TclObject;
18class Interpreter;
19
20class Touchpad final : public JoystickDevice, private MSXEventListener
21 , private StateChangeListener
22{
23public:
24 Touchpad(MSXEventDistributor& eventDistributor,
25 StateChangeDistributor& stateChangeDistributor,
26 Display& display,
27 CommandController& commandController);
28 ~Touchpad() override;
29
30 template<typename Archive>
31 void serialize(Archive& ar, unsigned version);
32
33private:
34 void createTouchpadStateChange(EmuTime::param time,
35 uint8_t x, uint8_t y, bool touch, bool button);
36 void parseTransformMatrix(Interpreter& interp, const TclObject& value);
37 [[nodiscard]] gl::ivec2 transformCoords(gl::ivec2 xy);
38
39 // Pluggable
40 [[nodiscard]] std::string_view getName() const override;
41 [[nodiscard]] std::string_view getDescription() const override;
42 void plugHelper(Connector& connector, EmuTime::param time) override;
43 void unplugHelper(EmuTime::param time) override;
44
45 // JoystickDevice
46 [[nodiscard]] uint8_t read(EmuTime::param time) override;
47 void write(uint8_t value, EmuTime::param time) override;
48
49 // MSXEventListener
50 void signalMSXEvent(const Event& event,
51 EmuTime::param time) noexcept override;
52 // StateChangeListener
53 void signalStateChange(const StateChange& event) override;
54 void stopReplay(EmuTime::param time) noexcept override;
55
56private:
57 MSXEventDistributor& eventDistributor;
58 StateChangeDistributor& stateChangeDistributor;
59 Display& display;
60
61 StringSetting transformSetting;
62 gl::matMxN<2, 3, float> m; // transformation matrix
63
64 EmuTime start = EmuTime::zero(); // last time when CS switched 0->1
65 gl::ivec2 hostPos; // host state
66 uint8_t hostButtons = 0; //
67 uint8_t x = 0, y = 0; // msx state (different from host state
68 bool touch = false, button = false; // during replay)
69 uint8_t shift = 0; // shift register to both transmit and receive data
70 uint8_t channel = 0; // [0..3] 0->x, 3->y, 1,2->not used
71 uint8_t last = 0; // last written data, to detect transitions
72};
73
74} // namespace openmsx
75
76#endif
Represents something you can plug devices into.
Definition Connector.hh:21
Represents the output window/screen of openMSX.
Definition Display.hh:32
Base class for all external MSX state changing events.
~Touchpad() override
Definition Touchpad.cc:88
void serialize(Archive &ar, unsigned version)
Definition Touchpad.cc:279
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:444