MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / UpdateInputEvents

Method UpdateInputEvents

TheForceEngine/TFE_Ui/imGUI/imgui.cpp:9546–9674  ·  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

9544// - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost)
9545// - 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)
9546void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
9547{
9548 ImGuiContext& g = *GImGui;
9549 ImGuiIO& io = g.IO;
9550
9551 // Only trickle chars<>key when working with InputText()
9552 // FIXME: InputText() could parse event trail?
9553 // FIXME: Could specialize chars<>keys trickling rules for control keys (those not typically associated to characters)
9554 const bool trickle_interleaved_keys_and_text = (trickle_fast_inputs && g.WantTextInputNextFrame == 1);
9555
9556 bool mouse_moved = false, mouse_wheeled = false, key_changed = false, text_inputted = false;
9557 int mouse_button_changed = 0x00;
9558 ImBitArray<ImGuiKey_KeysData_SIZE> key_changed_mask;
9559
9560 int event_n = 0;
9561 for (; event_n < g.InputEventsQueue.Size; event_n++)
9562 {
9563 ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
9564 if (e->Type == ImGuiInputEventType_MousePos)
9565 {
9566 if (g.IO.WantSetMousePos)
9567 continue;
9568 // Trickling Rule: Stop processing queued events if we already handled a mouse button change
9569 ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
9570 if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
9571 break;
9572 io.MousePos = event_pos;
9573 io.MouseSource = e->MousePos.MouseSource;
9574 mouse_moved = true;
9575 }
9576 else if (e->Type == ImGuiInputEventType_MouseButton)
9577 {
9578 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
9579 const ImGuiMouseButton button = e->MouseButton.Button;
9580 IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
9581 if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
9582 break;
9583 if (trickle_fast_inputs && e->MouseButton.MouseSource == ImGuiMouseSource_TouchScreen && mouse_moved) // #2702: TouchScreen have no initial hover.
9584 break;
9585 io.MouseDown[button] = e->MouseButton.Down;
9586 io.MouseSource = e->MouseButton.MouseSource;
9587 mouse_button_changed |= (1 << button);
9588 }
9589 else if (e->Type == ImGuiInputEventType_MouseWheel)
9590 {
9591 // Trickling Rule: Stop processing queued events if we got multiple action on the event
9592 if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0))
9593 break;
9594 io.MouseWheelH += e->MouseWheel.WheelX;
9595 io.MouseWheel += e->MouseWheel.WheelY;
9596 io.MouseSource = e->MouseWheel.MouseSource;
9597 mouse_wheeled = true;
9598 }
9599 else if (e->Type == ImGuiInputEventType_Key)
9600 {
9601 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
9602 if (io.ConfigFlags & ImGuiConfigFlags_NoKeyboard)
9603 continue;

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected