MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / UpdateInputEvents

Method UpdateInputEvents

KBotExt/imgui/imgui.cpp:8853–8972  ·  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

8851// - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost)
8852// - 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)
8853void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
8854{
8855 ImGuiContext& g = *GImGui;
8856 ImGuiIO& io = g.IO;
8857
8858 // Only trickle chars<>key when working with InputText()
8859 // FIXME: InputText() could parse event trail?
8860 // FIXME: Could specialize chars<>keys trickling rules for control keys (those not typically associated to characters)
8861 const bool trickle_interleaved_keys_and_text = (trickle_fast_inputs && g.WantTextInputNextFrame == 1);
8862
8863 bool mouse_moved = false, mouse_wheeled = false, key_changed = false, text_inputted = false;
8864 int mouse_button_changed = 0x00;
8865 ImBitArray<ImGuiKey_KeysData_SIZE> key_changed_mask;
8866
8867 int event_n = 0;
8868 for (; event_n < g.InputEventsQueue.Size; event_n++)
8869 {
8870 ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
8871 if (e->Type == ImGuiInputEventType_MousePos)
8872 {
8873 // Trickling Rule: Stop processing queued events if we already handled a mouse button change
8874 ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
8875 if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
8876 break;
8877 io.MousePos = event_pos;
8878 io.MouseSource = e->MousePos.MouseSource;
8879 mouse_moved = true;
8880 }
8881 else if (e->Type == ImGuiInputEventType_MouseButton)
8882 {
8883 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
8884 const ImGuiMouseButton button = e->MouseButton.Button;
8885 IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
8886 if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
8887 break;
8888 if (trickle_fast_inputs && e->MouseButton.MouseSource == ImGuiMouseSource_TouchScreen && mouse_moved) // #2702: TouchScreen have no initial hover.
8889 break;
8890 io.MouseDown[button] = e->MouseButton.Down;
8891 io.MouseSource = e->MouseButton.MouseSource;
8892 mouse_button_changed |= (1 << button);
8893 }
8894 else if (e->Type == ImGuiInputEventType_MouseWheel)
8895 {
8896 // Trickling Rule: Stop processing queued events if we got multiple action on the event
8897 if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0))
8898 break;
8899 io.MouseWheelH += e->MouseWheel.WheelX;
8900 io.MouseWheel += e->MouseWheel.WheelY;
8901 io.MouseSource = e->MouseWheel.MouseSource;
8902 mouse_wheeled = true;
8903 }
8904 else if (e->Type == ImGuiInputEventType_Key)
8905 {
8906 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
8907 ImGuiKey key = e->Key.Key;
8908 IM_ASSERT(key != ImGuiKey_None);
8909 ImGuiKeyData* key_data = GetKeyData(key);
8910 const int key_data_index = (int)(key_data - g.IO.KeysData);

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected