MCPcopy Create free account
hub / github.com/cinder/Cinder / UpdateInputEvents

Method UpdateInputEvents

src/imgui/imgui.cpp:10250–10384  ·  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

10248// - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost)
10249// - 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)
10250void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
10251{
10252 ImGuiContext& g = *GImGui;
10253 ImGuiIO& io = g.IO;
10254
10255 // Only trickle chars<>key when working with InputText()
10256 // FIXME: InputText() could parse event trail?
10257 // FIXME: Could specialize chars<>keys trickling rules for control keys (those not typically associated to characters)
10258 const bool trickle_interleaved_nonchar_keys_and_text = (trickle_fast_inputs && g.WantTextInputNextFrame == 1);
10259
10260 bool mouse_moved = false, mouse_wheeled = false, key_changed = false, key_changed_nonchar = false, text_inputted = false;
10261 int mouse_button_changed = 0x00;
10262 ImBitArray<ImGuiKey_NamedKey_COUNT> key_changed_mask;
10263
10264 int event_n = 0;
10265 for (; event_n < g.InputEventsQueue.Size; event_n++)
10266 {
10267 ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
10268 if (e->Type == ImGuiInputEventType_MousePos)
10269 {
10270 if (g.IO.WantSetMousePos)
10271 continue;
10272 // Trickling Rule: Stop processing queued events if we already handled a mouse button change
10273 ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
10274 if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
10275 break;
10276 io.MousePos = event_pos;
10277 io.MouseSource = e->MousePos.MouseSource;
10278 mouse_moved = true;
10279 }
10280 else if (e->Type == ImGuiInputEventType_MouseButton)
10281 {
10282 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
10283 const ImGuiMouseButton button = e->MouseButton.Button;
10284 IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
10285 if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
10286 break;
10287 if (trickle_fast_inputs && e->MouseButton.MouseSource == ImGuiMouseSource_TouchScreen && mouse_moved) // #2702: TouchScreen have no initial hover.
10288 break;
10289 io.MouseDown[button] = e->MouseButton.Down;
10290 io.MouseSource = e->MouseButton.MouseSource;
10291 mouse_button_changed |= (1 << button);
10292 }
10293 else if (e->Type == ImGuiInputEventType_MouseWheel)
10294 {
10295 // Trickling Rule: Stop processing queued events if we got multiple action on the event
10296 if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0))
10297 break;
10298 io.MouseWheelH += e->MouseWheel.WheelX;
10299 io.MouseWheel += e->MouseWheel.WheelY;
10300 io.MouseSource = e->MouseWheel.MouseSource;
10301 mouse_wheeled = true;
10302 }
10303 else if (e->Type == ImGuiInputEventType_Key)
10304 {
10305 // Trickling Rule: Stop processing queued events if we got multiple action on the same button
10306 if (io.ConfigFlags & ImGuiConfigFlags_NoKeyboard)
10307 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