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) noexcept override;
43 
44  // Schedulable
45  void executeUntil(EmuTime::param time) override;
46 
47 private:
48  EventDistributor& eventDistributor;
49  MSXEventDistributor& msxEventDistributor;
50 
51  std::vector<EventPtr> toBeScheduledEvents;
52  std::deque<EventPtr> scheduledEvents;
53 
54 #if PLATFORM_ANDROID
55  std::vector<std::pair<int, EventPtr>> nonMatchedKeyPresses;
56 #endif
57 
58  EmuTime prevEmu;
59  uint64_t prevReal;
60  FloatSetting delaySetting;
61 };
62 
63 } // namespace openmsx
64 
65 #endif
This class is responsible for translating host events into MSX events.
Definition: EventDelay.hh:27
void sync(EmuTime::param curEmu)
Definition: EventDelay.cc:87
EventDelay(Scheduler &scheduler, CommandController &commandController, EventDistributor &eventDistributor, MSXEventDistributor &msxEventDistributor, ReverseManager &reverseManager)
Definition: EventDelay.cc:16
A Setting with a floating point value.
Definition: FloatSetting.hh:11
Every class that wants to get scheduled at some point must inherit from this class.
Definition: Schedulable.hh:34
This file implemented 3 utility functions:
Definition: Autofire.cc:9