66 auto realDuration = curRealTime - prevReal;
67 prevReal = curRealTime;
68 auto emuDuration = curEmu - prevEmu;
71 double factor = emuDuration.toDouble() / narrow_cast<double>(realDuration);
93 std::vector<Event> toBeRescheduledEvents;
96 EmuTime time = curEmu + extraDelay;
97 for (
auto& e : toBeScheduledEvents) {
100 const auto& keyEvent = get_event<KeyEvent>(e);
101 int maskedKeyCode = int(keyEvent.getKeyCode()) & int(Keys::K_MASK);
102 auto it =
ranges::find(nonMatchedKeyPresses, maskedKeyCode,
103 [](
const auto& p) {
return p.first; });
105 if (it ==
end(nonMatchedKeyPresses)) {
106 nonMatchedKeyPresses.emplace_back(maskedKeyCode, e);
111 if (it !=
end(nonMatchedKeyPresses)) {
112 const auto& timedPressEvent = get_event<TimedEvent>(it->second);
113 const auto& timedReleaseEvent = get_event<TimedEvent>(e);
114 auto pressRealTime = timedPressEvent.getRealTime();
115 auto releaseRealTime = timedReleaseEvent.getRealTime();
116 auto deltaTime = releaseRealTime - pressRealTime;
117 if (deltaTime <= 2000000 / 50) {
123 toBeRescheduledEvents.push_back(newKeyupEvent);
131 scheduledEvents.push_back(e);
132 const auto& sdlEvent = get_event<SdlEvent>(e);
133 uint32_t eventSdlTime = sdlEvent.getCommonSdlEvent().timestamp;
134 uint32_t sdlNow = SDL_GetTicks();
135 auto sdlOffset = int32_t(sdlNow - eventSdlTime);
136 assert(sdlOffset >= 0);
137 auto offset = 1000 * int64_t(sdlOffset);
138 EmuDuration emuOffset(factor * narrow_cast<double>(offset));
139 auto schedTime = (emuOffset < extraDelay)
142 assert(curEmu <= schedTime);
145 toBeScheduledEvents.clear();
148 append(toBeScheduledEvents, std::move(toBeRescheduledEvents));
EventDelay(Scheduler &scheduler, CommandController &commandController, EventDistributor &eventDistributor, MSXEventDistributor &msxEventDistributor, ReverseManager &reverseManager)
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