MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / UpdateInputEvents

Method UpdateInputEvents

Source/3rdParty/imgui/imgui.cpp:10467–10603  ·  view source on GitHub ↗

Process input queue We always call this with the value of 'bool g.IO.ConfigInputTrickleEventQueue'. - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost) - trickle_fast_inputs = true : process as many events as possible (successive down/up/down/up will be trickled over several frames so nothing is lost) (new feature in 1

Source from the content-addressed store, hash-verified

10465// - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost)
10466// - trickle_fast_inputs = true : process as many events as possible (successive down/up/down/up will be trickled over several frames so nothing is lost) (new feature in 1.87)
10467void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
10468{
10469 ImGuiContext& g = *GImGui;
10470 ImGuiIO& io = g.IO;
10471
10472 // Only trickle chars<>key when working with InputText()
10473 // FIXME: InputText() could parse event trail?
10474 // FIXME: Could specialize chars<>keys trickling rules for control keys (those not typically associated to characters)
10475 const bool trickle_interleaved_nonchar_keys_and_text = (trickle_fast_inputs && g.WantTextInputNextFrame == 1);
10476
10477 bool mouse_moved = false, mouse_wheeled = false, key_changed = false, key_changed_nonchar = false, text_inputted = false;
10478 int mouse_button_changed = 0x00;
10479 ImBitArray<ImGuiKey_NamedKey_COUNT> key_changed_mask;
10480
10481 int event_n = 0;
10482 for (; event_n < g.InputEventsQueue.Size; event_n++)
10483 {
10484 ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
10485 if (e->Type == ImGuiInputEventType_MousePos)
10486 {
10487 if (g.IO.WantSetMousePos)
10488 continue;
10489 // Trickling Rule: Stop processing queued events if we already handled a mouse button change
10490 ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
10491 if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
10492 break;
10493 io.MousePos = event_pos;
10494 io.MouseSource = e->MousePos.MouseSource;
10495 mouse_moved = true;
10496 }
10497 else if (e->Type == ImGuiInputEventType_MouseButton)
10498 {
10499 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
10500 const ImGuiMouseButton button = e->MouseButton.Button;
10501 IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
10502 if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
10503 break;
10504 if (trickle_fast_inputs && e->MouseButton.MouseSource == ImGuiMouseSource_TouchScreen && mouse_moved) // #2702: TouchScreen have no initial hover.
10505 break;
10506 io.MouseDown[button] = e->MouseButton.Down;
10507 io.MouseSource = e->MouseButton.MouseSource;
10508 mouse_button_changed |= (1 << button);
10509 }
10510 else if (e->Type == ImGuiInputEventType_MouseWheel)
10511 {
10512 // Trickling Rule: Stop processing queued events if we got multiple action on the event
10513 if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0))
10514 break;
10515 io.MouseWheelH += e->MouseWheel.WheelX;
10516 io.MouseWheel += e->MouseWheel.WheelY;
10517 io.MouseSource = e->MouseWheel.MouseSource;
10518 mouse_wheeled = true;
10519 }
10520 else if (e->Type == ImGuiInputEventType_Key)
10521 {
10522 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
10523 if (io.ConfigFlags & ImGuiConfigFlags_NoKeyboard)
10524 continue;

Callers

nothing calls this directly

Calls 11

GetKeyDataFunction · 0.85
GetMergedModsFromKeysFunction · 0.85
DebugPrintInputEventFunction · 0.85
TestBitMethod · 0.80
ClearInputKeysMethod · 0.80
ClearInputMouseMethod · 0.80
SetBitMethod · 0.45
push_backMethod · 0.45
resizeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected