MCPcopy Create free account
hub / github.com/Wemino/MarkerPatch / UpdateInputEvents

Method UpdateInputEvents

include/imgui/imgui.cpp:10496–10632  ·  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

10494// - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost)
10495// - 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)
10496void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
10497{
10498 ImGuiContext& g = *GImGui;
10499 ImGuiIO& io = g.IO;
10500
10501 // Only trickle chars<>key when working with InputText()
10502 // FIXME: InputText() could parse event trail?
10503 // FIXME: Could specialize chars<>keys trickling rules for control keys (those not typically associated to characters)
10504 const bool trickle_interleaved_nonchar_keys_and_text = (trickle_fast_inputs && g.WantTextInputNextFrame == 1);
10505
10506 bool mouse_moved = false, mouse_wheeled = false, key_changed = false, key_changed_nonchar = false, text_inputted = false;
10507 int mouse_button_changed = 0x00;
10508 ImBitArray<ImGuiKey_NamedKey_COUNT> key_changed_mask;
10509
10510 int event_n = 0;
10511 for (; event_n < g.InputEventsQueue.Size; event_n++)
10512 {
10513 ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
10514 if (e->Type == ImGuiInputEventType_MousePos)
10515 {
10516 if (g.IO.WantSetMousePos)
10517 continue;
10518 // Trickling Rule: Stop processing queued events if we already handled a mouse button change
10519 ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
10520 if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
10521 break;
10522 io.MousePos = event_pos;
10523 io.MouseSource = e->MousePos.MouseSource;
10524 mouse_moved = true;
10525 }
10526 else if (e->Type == ImGuiInputEventType_MouseButton)
10527 {
10528 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
10529 const ImGuiMouseButton button = e->MouseButton.Button;
10530 IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
10531 if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
10532 break;
10533 if (trickle_fast_inputs && e->MouseButton.MouseSource == ImGuiMouseSource_TouchScreen && mouse_moved) // #2702: TouchScreen have no initial hover.
10534 break;
10535 io.MouseDown[button] = e->MouseButton.Down;
10536 io.MouseSource = e->MouseButton.MouseSource;
10537 mouse_button_changed |= (1 << button);
10538 }
10539 else if (e->Type == ImGuiInputEventType_MouseWheel)
10540 {
10541 // Trickling Rule: Stop processing queued events if we got multiple action on the event
10542 if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0))
10543 break;
10544 io.MouseWheelH += e->MouseWheel.WheelX;
10545 io.MouseWheel += e->MouseWheel.WheelY;
10546 io.MouseSource = e->MouseWheel.MouseSource;
10547 mouse_wheeled = true;
10548 }
10549 else if (e->Type == ImGuiInputEventType_Key)
10550 {
10551 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
10552 if (io.ConfigFlags & ImGuiConfigFlags_NoKeyboard)
10553 continue;

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected