MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / UpdateControls

Method UpdateControls

Source/Main/engine.cpp:659–922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657}
658
659void Engine::UpdateControls(float timestep, bool loading_screen) {
660 if (scenegraph_ && scenegraph_->map_editor && scenegraph_->map_editor->state_ != MapEditor::kInGame && !paused) {
661 Input::Instance()->AllowControllerInput(false);
662 } else {
663 Input::Instance()->AllowControllerInput(true);
664 }
665
666 if (loading_screen == true || waiting_for_input_) {
667 SDL_Event event;
668 // We want to poll events during load screen to allow SDL to handle basic window drag/resize events
669 while (SDL_PollEvent(&event)) {
670 if (event.type == SDL_QUIT) {
671 {
672 loading_mutex_.lock();
673 LOGE << "User requested interrupt, shutting down loading" << std::endl;
674 interrupt_loading = true;
675 loading_mutex_.unlock();
676 }
677 }
678
679 if (SDL_GetWindowFlags(Graphics::Instance()->sdl_window_) & SDL_WINDOW_INPUT_FOCUS) {
680 switch (event.type) {
681 case SDL_MOUSEBUTTONDOWN:
682 case SDL_KEYDOWN:
683 case SDL_JOYBUTTONDOWN:
684 if (Online::Instance()->IsActive()) {
685 if (Online::Instance()->IsHosting() && Online::Instance()->AllClientsReady()) {
686 last_loading_input_time = SDL_TS_GetTicks();
687 Online::Instance()->SessionStarted(true);
688 }
689 } else {
690 last_loading_input_time = SDL_TS_GetTicks();
691 Online::Instance()->SessionStarted(true);
692 }
693 break;
694 }
695 }
696
697 queued_events.push(event);
698 }
699 } else {
700 Input* input = Input::Instance();
701 Graphics* graphics = Graphics::Instance();
702
703 // reset deltas on userinterfaces
704 input->getMouse().Update();
705
706 if (loading_screen == false) {
707 PROFILER_ZONE(g_profiler_ctx, "UpdateKeyboardFocus");
708 input->UpdateKeyboardFocus();
709 }
710
711 input->getKeyboard().clearKeyPresses();
712 KeyCommand::ClearKeyPresses();
713
714 // Process all the events queued during the loading screen if necessary.
715 // We never want to miss events because our keyboard/mouse state would get out of sync
716 if (!queued_events.empty()) {

Callers 1

DrawMethod · 0.45

Calls 15

SDL_TS_GetTicksFunction · 0.85
ProcessEventImGuiFunction · 0.85
RequestLiveUpdateFunction · 0.85
ivec2Class · 0.85
WantMouseImGuiFunction · 0.85
WantKeyboardImGuiFunction · 0.85
LoadLevelFunction · 0.85
ProcessVREventFunction · 0.85
AllowControllerInputMethod · 0.80
IsHostingMethod · 0.80
AllClientsReadyMethod · 0.80
SessionStartedMethod · 0.80

Tested by

no test coverage detected