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

Method UpdateInputEvents

src/external/imgui/imgui.cpp:9038–9159  ·  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

9036// - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost)
9037// - 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)
9038void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
9039{
9040 ImGuiContext& g = *GImGui;
9041 ImGuiIO& io = g.IO;
9042
9043 // Only trickle chars<>key when working with InputText()
9044 // FIXME: InputText() could parse event trail?
9045 // FIXME: Could specialize chars<>keys trickling rules for control keys (those not typically associated to characters)
9046 const bool trickle_interleaved_keys_and_text = (trickle_fast_inputs && g.WantTextInputNextFrame == 1);
9047
9048 bool mouse_moved = false, mouse_wheeled = false, key_changed = false, text_inputted = false;
9049 int mouse_button_changed = 0x00;
9050 ImBitArray<ImGuiKey_KeysData_SIZE> key_changed_mask;
9051
9052 int event_n = 0;
9053 for (; event_n < g.InputEventsQueue.Size; event_n++)
9054 {
9055 ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
9056 if (e->Type == ImGuiInputEventType_MousePos)
9057 {
9058 if (g.IO.WantSetMousePos)
9059 continue;
9060 // Trickling Rule: Stop processing queued events if we already handled a mouse button change
9061 ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
9062 if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
9063 break;
9064 io.MousePos = event_pos;
9065 io.MouseSource = e->MousePos.MouseSource;
9066 mouse_moved = true;
9067 }
9068 else if (e->Type == ImGuiInputEventType_MouseButton)
9069 {
9070 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
9071 const ImGuiMouseButton button = e->MouseButton.Button;
9072 IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
9073 if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
9074 break;
9075 if (trickle_fast_inputs && e->MouseButton.MouseSource == ImGuiMouseSource_TouchScreen && mouse_moved) // #2702: TouchScreen have no initial hover.
9076 break;
9077 io.MouseDown[button] = e->MouseButton.Down;
9078 io.MouseSource = e->MouseButton.MouseSource;
9079 mouse_button_changed |= (1 << button);
9080 }
9081 else if (e->Type == ImGuiInputEventType_MouseWheel)
9082 {
9083 // Trickling Rule: Stop processing queued events if we got multiple action on the event
9084 if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0))
9085 break;
9086 io.MouseWheelH += e->MouseWheel.WheelX;
9087 io.MouseWheel += e->MouseWheel.WheelY;
9088 io.MouseSource = e->MouseWheel.MouseSource;
9089 mouse_wheeled = true;
9090 }
9091 else if (e->Type == ImGuiInputEventType_Key)
9092 {
9093 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
9094 ImGuiKey key = e->Key.Key;
9095 IM_ASSERT(key != ImGuiKey_None);

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected