| 1 |
#ifndef TOUCHPAD_HH |
| 2 |
#define TOUCHPAD_HH |
| 3 |
|
| 4 |
#include "EmuTime.hh" |
| 5 |
#include "JoystickDevice.hh" |
| 6 |
#include "MSXEventListener.hh" |
| 7 |
#include "StateChangeListener.hh" |
| 8 |
#include "StringSetting.hh" |
| 9 |
#include "gl_mat.hh" |
| 10 |
|
| 11 |
namespace openmsx { |
| 12 |
|
| 13 |
class MSXEventDistributor; |
| 14 |
class StateChangeDistributor; |
| 15 |
class Display; |
| 16 |
class CommandController; |
| 17 |
class TclObject; |
| 18 |
class Interpreter; |
| 19 |
|
| 20 |
class Touchpad final : public JoystickDevice, private MSXEventListener |
| 21 |
, private StateChangeListener |
| 22 |
{ |
| 23 |
public: |
| 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 |
|
| 33 |
private: |
| 34 |
void createTouchpadStateChange(EmuTime 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 |
|
| 40 |
[[nodiscard]] zstring_view getName() const override; |
| 41 |
[[nodiscard]] zstring_view getDescription() const override; |
| 42 |
void plugHelper(Connector& connector, EmuTime time) override; |
| 43 |
void unplugHelper(EmuTime time) override; |
| 44 |
|
| 45 |
|
| 46 |
[[nodiscard]] uint8_t read(EmuTime time) override; |
| 47 |
void write(uint8_t value, EmuTime time) override; |
| 48 |
|
| 49 |
|
| 50 |
void signalMSXEvent(const Event& event, |
| 51 |
EmuTime time) noexcept override; |
| 52 |
|
| 53 |
void signalStateChange(const StateChange& event) override; |
| 54 |
void stopReplay(EmuTime time) noexcept override; |
| 55 |
|
| 56 |
private: |
| 57 |
MSXEventDistributor& eventDistributor; |
| 58 |
StateChangeDistributor& stateChangeDistributor; |
| 59 |
Display& display; |
| 60 |
|
| 61 |
StringSetting transformSetting; |
| 62 |
gl::matMxN<2, 3, float> m; |
| 63 |
|
| 64 |
EmuTime start = EmuTime::zero(); |
| 65 |
gl::ivec2 hostPos; |
| 66 |
uint8_t hostButtons = 0; |
| 67 |
uint8_t x = 0, y = 0; |
| 68 |
bool touch = false, button = false; |
| 69 |
uint8_t shift = 0; |
| 70 |
uint8_t channel = 0; |
| 71 |
uint8_t last = 0; |
| 72 |
}; |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
#endif |