| e8555c89 Andy McCall |
1 |
#ifndef PADDLE_HH |
| 2 |
#define PADDLE_HH |
| 3 |
|
| 4 |
#include "EmuTime.hh" |
| 5 |
#include "JoystickDevice.hh" |
| 6 |
#include "MSXEventListener.hh" |
| 7 |
#include "StateChangeListener.hh" |
| 8 |
#include <cstdint> |
| 9 |
|
| 10 |
namespace openmsx { |
| 11 |
|
| 12 |
class MSXEventDistributor; |
| 13 |
class StateChangeDistributor; |
| 14 |
|
| 15 |
class Paddle final : public JoystickDevice, private MSXEventListener |
| 16 |
, private StateChangeListener |
| 17 |
{ |
| 18 |
public: |
| 19 |
Paddle(MSXEventDistributor& eventDistributor, |
| 20 |
StateChangeDistributor& stateChangeDistributor); |
| 21 |
~Paddle() override; |
| 22 |
|
| 23 |
template<typename Archive> |
| 24 |
void serialize(Archive& ar, unsigned version); |
| 25 |
|
| 26 |
private: |
| 27 |
|
| 28 |
[[nodiscard]] zstring_view getName() const override; |
| 29 |
[[nodiscard]] zstring_view getDescription() const override; |
| 30 |
void plugHelper(Connector& connector, EmuTime time) override; |
| 31 |
void unplugHelper(EmuTime time) override; |
| 32 |
|
| 33 |
|
| 34 |
[[nodiscard]] uint8_t read(EmuTime time) override; |
| 35 |
void write(uint8_t value, EmuTime time) override; |
| 36 |
|
| 37 |
|
| 38 |
void signalMSXEvent(const Event& event, |
| 39 |
EmuTime time) noexcept override; |
| 40 |
|
| 41 |
void signalStateChange(const StateChange& event) override; |
| 42 |
void stopReplay(EmuTime time) noexcept override; |
| 43 |
|
| 44 |
private: |
| 45 |
MSXEventDistributor& eventDistributor; |
| 46 |
StateChangeDistributor& stateChangeDistributor; |
| 47 |
|
| 48 |
EmuTime lastPulse = EmuTime::zero(); |
| 49 |
uint8_t analogValue = 128; |
| 50 |
uint8_t lastInput = 0; |
| 51 |
}; |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
#endif |