| 10151 | } |
| 10152 | |
| 10153 | static void ImGui::UpdateKeyboardInputs() |
| 10154 | { |
| 10155 | ImGuiContext& g = *GImGui; |
| 10156 | ImGuiIO& io = g.IO; |
| 10157 | |
| 10158 | if (io.ConfigFlags & ImGuiConfigFlags_NoKeyboard) |
| 10159 | io.ClearInputKeys(); |
| 10160 | |
| 10161 | // Update aliases |
| 10162 | for (int n = 0; n < ImGuiMouseButton_COUNT; n++) |
| 10163 | UpdateAliasKey(MouseButtonToKey(n), io.MouseDown[n], io.MouseDown[n] ? 1.0f : 0.0f); |
| 10164 | UpdateAliasKey(ImGuiKey_MouseWheelX, io.MouseWheelH != 0.0f, io.MouseWheelH); |
| 10165 | UpdateAliasKey(ImGuiKey_MouseWheelY, io.MouseWheel != 0.0f, io.MouseWheel); |
| 10166 | |
| 10167 | // Synchronize io.KeyMods and io.KeyCtrl/io.KeyShift/etc. values. |
| 10168 | // - New backends (1.87+): send io.AddKeyEvent(ImGuiMod_XXX) -> -> (here) deriving io.KeyMods + io.KeyXXX from key array. |
| 10169 | // - Legacy backends: set io.KeyXXX bools -> (above) set key array from io.KeyXXX -> (here) deriving io.KeyMods + io.KeyXXX from key array. |
| 10170 | // So with legacy backends the 4 values will do a unnecessary back-and-forth but it makes the code simpler and future facing. |
| 10171 | const ImGuiKeyChord prev_key_mods = io.KeyMods; |
| 10172 | io.KeyMods = GetMergedModsFromKeys(); |
| 10173 | io.KeyCtrl = (io.KeyMods & ImGuiMod_Ctrl) != 0; |
| 10174 | io.KeyShift = (io.KeyMods & ImGuiMod_Shift) != 0; |
| 10175 | io.KeyAlt = (io.KeyMods & ImGuiMod_Alt) != 0; |
| 10176 | io.KeySuper = (io.KeyMods & ImGuiMod_Super) != 0; |
| 10177 | if (prev_key_mods != io.KeyMods) |
| 10178 | g.LastKeyModsChangeTime = g.Time; |
| 10179 | if (prev_key_mods != io.KeyMods && prev_key_mods == 0) |
| 10180 | g.LastKeyModsChangeFromNoneTime = g.Time; |
| 10181 | |
| 10182 | // Clear gamepad data if disabled |
| 10183 | if ((io.BackendFlags & ImGuiBackendFlags_HasGamepad) == 0) |
| 10184 | for (int key = ImGuiKey_Gamepad_BEGIN; key < ImGuiKey_Gamepad_END; key++) |
| 10185 | { |
| 10186 | io.KeysData[key - ImGuiKey_NamedKey_BEGIN].Down = false; |
| 10187 | io.KeysData[key - ImGuiKey_NamedKey_BEGIN].AnalogValue = 0.0f; |
| 10188 | } |
| 10189 | |
| 10190 | // Update keys |
| 10191 | for (int key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key++) |
| 10192 | { |
| 10193 | ImGuiKeyData* key_data = &io.KeysData[key - ImGuiKey_NamedKey_BEGIN]; |
| 10194 | key_data->DownDurationPrev = key_data->DownDuration; |
| 10195 | key_data->DownDuration = key_data->Down ? (key_data->DownDuration < 0.0f ? 0.0f : key_data->DownDuration + io.DeltaTime) : -1.0f; |
| 10196 | if (key_data->DownDuration == 0.0f) |
| 10197 | { |
| 10198 | if (IsKeyboardKey((ImGuiKey)key)) |
| 10199 | g.LastKeyboardKeyPressTime = g.Time; |
| 10200 | else if (key == ImGuiKey_ReservedForModCtrl || key == ImGuiKey_ReservedForModShift || key == ImGuiKey_ReservedForModAlt || key == ImGuiKey_ReservedForModSuper) |
| 10201 | g.LastKeyboardKeyPressTime = g.Time; |
| 10202 | } |
| 10203 | } |
| 10204 | |
| 10205 | // Update keys/input owner (named keys only): one entry per key |
| 10206 | for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1)) |
| 10207 | { |
| 10208 | ImGuiKeyData* key_data = &io.KeysData[key - ImGuiKey_NamedKey_BEGIN]; |
| 10209 | ImGuiKeyOwnerData* owner_data = &g.KeysOwnerData[key - ImGuiKey_NamedKey_BEGIN]; |
| 10210 | owner_data->OwnerCurr = owner_data->OwnerNext; |
nothing calls this directly
no test coverage detected