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

Method UpdateKeyboardInputs

src/imgui/imgui.cpp:9915–9980  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9913}
9914
9915static void ImGui::UpdateKeyboardInputs()
9916{
9917 ImGuiContext& g = *GImGui;
9918 ImGuiIO& io = g.IO;
9919
9920 if (io.ConfigFlags & ImGuiConfigFlags_NoKeyboard)
9921 io.ClearInputKeys();
9922
9923 // Update aliases
9924 for (int n = 0; n < ImGuiMouseButton_COUNT; n++)
9925 UpdateAliasKey(MouseButtonToKey(n), io.MouseDown[n], io.MouseDown[n] ? 1.0f : 0.0f);
9926 UpdateAliasKey(ImGuiKey_MouseWheelX, io.MouseWheelH != 0.0f, io.MouseWheelH);
9927 UpdateAliasKey(ImGuiKey_MouseWheelY, io.MouseWheel != 0.0f, io.MouseWheel);
9928
9929 // Synchronize io.KeyMods and io.KeyCtrl/io.KeyShift/etc. values.
9930 // - New backends (1.87+): send io.AddKeyEvent(ImGuiMod_XXX) -> -> (here) deriving io.KeyMods + io.KeyXXX from key array.
9931 // - Legacy backends: set io.KeyXXX bools -> (above) set key array from io.KeyXXX -> (here) deriving io.KeyMods + io.KeyXXX from key array.
9932 // So with legacy backends the 4 values will do a unnecessary back-and-forth but it makes the code simpler and future facing.
9933 const ImGuiKeyChord prev_key_mods = io.KeyMods;
9934 io.KeyMods = GetMergedModsFromKeys();
9935 io.KeyCtrl = (io.KeyMods & ImGuiMod_Ctrl) != 0;
9936 io.KeyShift = (io.KeyMods & ImGuiMod_Shift) != 0;
9937 io.KeyAlt = (io.KeyMods & ImGuiMod_Alt) != 0;
9938 io.KeySuper = (io.KeyMods & ImGuiMod_Super) != 0;
9939 if (prev_key_mods != io.KeyMods)
9940 g.LastKeyModsChangeTime = g.Time;
9941 if (prev_key_mods != io.KeyMods && prev_key_mods == 0)
9942 g.LastKeyModsChangeFromNoneTime = g.Time;
9943
9944 // Clear gamepad data if disabled
9945 if ((io.BackendFlags & ImGuiBackendFlags_HasGamepad) == 0)
9946 for (int key = ImGuiKey_Gamepad_BEGIN; key < ImGuiKey_Gamepad_END; key++)
9947 {
9948 io.KeysData[key - ImGuiKey_NamedKey_BEGIN].Down = false;
9949 io.KeysData[key - ImGuiKey_NamedKey_BEGIN].AnalogValue = 0.0f;
9950 }
9951
9952 // Update keys
9953 for (int key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key++)
9954 {
9955 ImGuiKeyData* key_data = &io.KeysData[key - ImGuiKey_NamedKey_BEGIN];
9956 key_data->DownDurationPrev = key_data->DownDuration;
9957 key_data->DownDuration = key_data->Down ? (key_data->DownDuration < 0.0f ? 0.0f : key_data->DownDuration + io.DeltaTime) : -1.0f;
9958 if (key_data->DownDuration == 0.0f)
9959 {
9960 if (IsKeyboardKey((ImGuiKey)key))
9961 g.LastKeyboardKeyPressTime = g.Time;
9962 else if (key == ImGuiKey_ReservedForModCtrl || key == ImGuiKey_ReservedForModShift || key == ImGuiKey_ReservedForModAlt || key == ImGuiKey_ReservedForModSuper)
9963 g.LastKeyboardKeyPressTime = g.Time;
9964 }
9965 }
9966
9967 // Update keys/input owner (named keys only): one entry per key
9968 for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
9969 {
9970 ImGuiKeyData* key_data = &io.KeysData[key - ImGuiKey_NamedKey_BEGIN];
9971 ImGuiKeyOwnerData* owner_data = &g.KeysOwnerData[key - ImGuiKey_NamedKey_BEGIN];
9972 owner_data->OwnerCurr = owner_data->OwnerNext;

Callers

nothing calls this directly

Calls 5

UpdateAliasKeyFunction · 0.85
MouseButtonToKeyFunction · 0.85
GetMergedModsFromKeysFunction · 0.85
IsKeyboardKeyFunction · 0.85
ClearInputKeysMethod · 0.80

Tested by

no test coverage detected