MCPcopy Create free account
hub / github.com/clementgallet/libTAS / sleepSendPreview

Method sleepSendPreview

src/program/GameLoop.cpp:611–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

609}
610
611void GameLoop::sleepSendPreview()
612{
613 /* Sleep a bit to not surcharge the processor */
614 struct timespec tim = {0, 33L*1000L*1000L};
615 nanosleep(&tim, NULL);
616
617 /* Send marker text if it has changed */
618 static std::string old_marker_text;
619 std::string text;
620 emit getMarkerText(text);
621 if (old_marker_text != text) {
622 old_marker_text = text;
623 sendMessage(MSGN_MARKER);
624 sendString(text);
625 }
626
627 /* Send a preview of inputs so that the game can display them
628 * on the HUD */
629
630 /* Don't preview when reading inputs */
631 if (context->config.sc.recording == SharedConfig::RECORDING_READ) {
632 sendMessage(MSGN_EXPOSE);
633 return;
634 }
635
636 static AllInputs preview_ai, last_preview_ai;
637 if (gameEvents->haveFocus()) {
638 /* Format the keyboard and mouse state and save it in the AllInputs struct */
639 context->config.km->buildAllInputs(preview_ai, context->game_window, context->config.sc, false);
640 }
641
642 /* Fill controller inputs from the controller input window. */
643 for (int j = 0; j < AllInputs::MAXJOYS; j++) {
644 if (preview_ai.controllers[j]) {
645 emit fillControllerInputs(*preview_ai.controllers[j], j);
646 }
647 }
648
649 /* Send inputs if changed */
650 if (!(preview_ai == last_preview_ai)) {
651 preview_ai.send(true);
652 last_preview_ai = preview_ai;
653 }
654
655 sendMessage(MSGN_EXPOSE);
656}
657
658
659void GameLoop::processInputs(AllInputs &ai)

Callers

nothing calls this directly

Calls 6

nanosleepFunction · 0.85
sendMessageFunction · 0.85
sendStringFunction · 0.85
haveFocusMethod · 0.80
buildAllInputsMethod · 0.80
sendMethod · 0.80

Tested by

no test coverage detected