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
| 11071 | // - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost) |
| 11072 | // - 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) |
| 11073 | void ImGui::UpdateInputEvents(bool trickle_fast_inputs) |
| 11074 | { |
| 11075 | ImGuiContext& g = *GImGui; |
| 11076 | ImGuiIO& io = g.IO; |
| 11077 | |
| 11078 | // Only trickle chars<>key when working with InputText() |
| 11079 | // FIXME: InputText() could parse event trail? |
| 11080 | // FIXME: Could specialize chars<>keys trickling rules for control keys (those not typically associated to characters) |
| 11081 | const bool trickle_interleaved_nonchar_keys_and_text = (trickle_fast_inputs && g.WantTextInputNextFrame == 1); |
| 11082 | |
| 11083 | bool mouse_moved = false, mouse_wheeled = false, key_changed = false, key_changed_nonchar = false, text_inputted = false; |
| 11084 | int mouse_button_changed = 0x00; |
| 11085 | ImBitArray<ImGuiKey_NamedKey_COUNT> key_changed_mask; |
| 11086 | |
| 11087 | int event_n = 0; |
| 11088 | for (; event_n < g.InputEventsQueue.Size; event_n++) |
| 11089 | { |
| 11090 | ImGuiInputEvent* e = &g.InputEventsQueue[event_n]; |
| 11091 | if (e->Type == ImGuiInputEventType_MousePos) |
| 11092 | { |
| 11093 | if (g.IO.WantSetMousePos) |
| 11094 | continue; |
| 11095 | // Trickling Rule: Stop processing queued events if we already handled a mouse button change |
| 11096 | ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY); |
| 11097 | if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted)) |
| 11098 | break; |
| 11099 | io.MousePos = event_pos; |
| 11100 | io.MouseSource = e->MousePos.MouseSource; |
| 11101 | mouse_moved = true; |
| 11102 | } |
| 11103 | else if (e->Type == ImGuiInputEventType_MouseButton) |
| 11104 | { |
| 11105 | // Trickling Rule: Stop processing queued events if we got multiple action on the same button |
| 11106 | const ImGuiMouseButton button = e->MouseButton.Button; |
| 11107 | IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT); |
| 11108 | if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled)) |
| 11109 | break; |
| 11110 | if (trickle_fast_inputs && e->MouseButton.MouseSource == ImGuiMouseSource_TouchScreen && mouse_moved) // #2702: TouchScreen have no initial hover. |
| 11111 | break; |
| 11112 | io.MouseDown[button] = e->MouseButton.Down; |
| 11113 | io.MouseSource = e->MouseButton.MouseSource; |
| 11114 | mouse_button_changed |= (1 << button); |
| 11115 | } |
| 11116 | else if (e->Type == ImGuiInputEventType_MouseWheel) |
| 11117 | { |
| 11118 | // Trickling Rule: Stop processing queued events if we got multiple action on the event |
| 11119 | if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0)) |
| 11120 | break; |
| 11121 | io.MouseWheelH += e->MouseWheel.WheelX; |
| 11122 | io.MouseWheel += e->MouseWheel.WheelY; |
| 11123 | io.MouseSource = e->MouseWheel.MouseSource; |
| 11124 | mouse_wheeled = true; |
| 11125 | } |
| 11126 | else if (e->Type == ImGuiInputEventType_MouseViewport) |
| 11127 | { |
| 11128 | io.MouseHoveredViewport = e->MouseViewport.HoveredViewportID; |
| 11129 | } |
| 11130 | else if (e->Type == ImGuiInputEventType_Key) |
nothing calls this directly
no test coverage detected