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
| 8419 | // - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost) |
| 8420 | // - 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) |
| 8421 | void ImGui::UpdateInputEvents(bool trickle_fast_inputs) |
| 8422 | { |
| 8423 | ImGuiContext& g = *GImGui; |
| 8424 | ImGuiIO& io = g.IO; |
| 8425 | |
| 8426 | // Only trickle chars<>key when working with InputText() |
| 8427 | // FIXME: InputText() could parse event trail? |
| 8428 | // FIXME: Could specialize chars<>keys trickling rules for control keys (those not typically associated to characters) |
| 8429 | const bool trickle_interleaved_keys_and_text = (trickle_fast_inputs && g.WantTextInputNextFrame == 1); |
| 8430 | |
| 8431 | bool mouse_moved = false, mouse_wheeled = false, key_changed = false, text_inputted = false; |
| 8432 | int mouse_button_changed = 0x00; |
| 8433 | ImBitArray<ImGuiKey_KeysData_SIZE> key_changed_mask; |
| 8434 | |
| 8435 | int event_n = 0; |
| 8436 | for (; event_n < g.InputEventsQueue.Size; event_n++) |
| 8437 | { |
| 8438 | ImGuiInputEvent* e = &g.InputEventsQueue[event_n]; |
| 8439 | if (e->Type == ImGuiInputEventType_MousePos) |
| 8440 | { |
| 8441 | // Trickling Rule: Stop processing queued events if we already handled a mouse button change |
| 8442 | ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY); |
| 8443 | if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted)) |
| 8444 | break; |
| 8445 | io.MousePos = event_pos; |
| 8446 | mouse_moved = true; |
| 8447 | } |
| 8448 | else if (e->Type == ImGuiInputEventType_MouseButton) |
| 8449 | { |
| 8450 | // Trickling Rule: Stop processing queued events if we got multiple action on the same button |
| 8451 | const ImGuiMouseButton button = e->MouseButton.Button; |
| 8452 | IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT); |
| 8453 | if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled)) |
| 8454 | break; |
| 8455 | io.MouseDown[button] = e->MouseButton.Down; |
| 8456 | mouse_button_changed |= (1 << button); |
| 8457 | } |
| 8458 | else if (e->Type == ImGuiInputEventType_MouseWheel) |
| 8459 | { |
| 8460 | // Trickling Rule: Stop processing queued events if we got multiple action on the event |
| 8461 | if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0)) |
| 8462 | break; |
| 8463 | io.MouseWheelH += e->MouseWheel.WheelX; |
| 8464 | io.MouseWheel += e->MouseWheel.WheelY; |
| 8465 | mouse_wheeled = true; |
| 8466 | } |
| 8467 | else if (e->Type == ImGuiInputEventType_Key) |
| 8468 | { |
| 8469 | // Trickling Rule: Stop processing queued events if we got multiple action on the same button |
| 8470 | ImGuiKey key = e->Key.Key; |
| 8471 | IM_ASSERT(key != ImGuiKey_None); |
| 8472 | ImGuiKeyData* key_data = GetKeyData(key); |
| 8473 | const int key_data_index = (int)(key_data - g.IO.KeysData); |
| 8474 | if (trickle_fast_inputs && key_data->Down != e->Key.Down && (key_changed_mask.TestBit(key_data_index) || text_inputted || mouse_button_changed != 0)) |
| 8475 | break; |
| 8476 | key_data->Down = e->Key.Down; |
| 8477 | key_data->AnalogValue = e->Key.AnalogValue; |
| 8478 | key_changed = true; |
nothing calls this directly
no test coverage detected