openMSX
EventDelay.hh
Go to the documentation of this file.
1 #ifndef EVENTDELAY_HH
2 #define EVENTDELAY_HH
3 
4 #include "EventListener.hh"
5 #include "Schedulable.hh"
6 #include "EmuTime.hh"
7 #include "FloatSetting.hh"
8 #include "build-info.hh"
9 #include <vector>
10 #include <deque>
11 #include <cstdint>
12 
13 namespace openmsx {
14 
15 class Scheduler;
16 class CommandController;
17 class Event;
18 class EventDistributor;
19 class MSXEventDistributor;
20 class ReverseManager;
21 
26 class EventDelay final : private EventListener, private Schedulable
27 {
28 public:
29  EventDelay(Scheduler& scheduler, CommandController& commandController,
30  EventDistributor& eventDistributor,
31  MSXEventDistributor& msxEventDistributor,
32  ReverseManager& reverseManager);
33  ~EventDelay();
34 
35  void sync(EmuTime::param curEmu);
36  void flush();
37 
38 private:
39  using EventPtr = std::shared_ptr<const Event>;
40 
41  // EventListener
42  int signalEvent(const EventPtr& event) override;
43 
44  // Schedulable
45  void executeUntil(EmuTime::param time) override;
46 
47  EventDistributor& eventDistributor;
48  MSXEventDistributor& msxEventDistributor;
49 
50  std::vector<EventPtr> toBeScheduledEvents;
51  std::deque<EventPtr> scheduledEvents;
52 
53 #if PLATFORM_ANDROID
54  std::vector<std::pair<int, EventPtr>> nonMatchedKeyPresses;
55 #endif
56 
57  EmuTime prevEmu;
58  uint64_t prevReal;
59  FloatSetting delaySetting;
60 };
61 
62 } // namespace openmsx
63 
64 #endif
openmsx::EventDelay::EventDelay
EventDelay(Scheduler &scheduler, CommandController &commandController, EventDistributor &eventDistributor, MSXEventDistributor &msxEventDistributor, ReverseManager &reverseManager)
Definition: EventDelay.cc:16
openmsx::Scheduler
Definition: Scheduler.hh:33
openmsx::CommandController
Definition: CommandController.hh:17
openmsx::MSXEventDistributor
Definition: MSXEventDistributor.hh:13
openmsx::FloatSetting
A Setting with a floating point value.
Definition: FloatSetting.hh:10
EventListener.hh
openmsx::Schedulable
Every class that wants to get scheduled at some point must inherit from this class.
Definition: Schedulable.hh:33
Schedulable.hh
openmsx::EventDistributor
Definition: EventDistributor.hh:16
openmsx::EventDelay
This class is responsible for translating host events into MSX events.
Definition: EventDelay.hh:26
build-info.hh
openmsx::EventListener
Definition: EventListener.hh:10
openmsx::EventDelay::sync
void sync(EmuTime::param curEmu)
Definition: EventDelay.cc:87
openmsx::EventDelay::~EventDelay
~EventDelay()
Definition: EventDelay.cc:54
EmuTime.hh
openmsx::ReverseManager
Definition: ReverseManager.hh:27
openmsx::Scheduler
Scheduler
Definition: Scheduler.cc:133
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
FloatSetting.hh
openmsx::EventDelay::flush
void flush()
Definition: EventDelay.cc:185