MCPcopy Create free account
hub / github.com/Raais/ImStudio / UpdateKeyboardInputs

Method UpdateKeyboardInputs

src/third-party/imgui/imgui.cpp:3910–3974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3908}
3909
3910static void ImGui::UpdateKeyboardInputs()
3911{
3912 ImGuiContext& g = *GImGui;
3913 ImGuiIO& io = g.IO;
3914
3915 // Synchronize io.KeyMods with individual modifiers io.KeyXXX bools
3916 io.KeyMods = GetMergedKeyModFlags();
3917
3918 // Import legacy keys or verify they are not used
3919#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
3920 if (io.BackendUsingLegacyKeyArrays == 0)
3921 {
3922 // Backend used new io.AddKeyEvent() API: Good! Verify that old arrays are never written too.
3923 for (int n = 0; n < IM_ARRAYSIZE(io.KeysDown); n++)
3924 IM_ASSERT(io.KeysDown[n] == false && "Backend needs to either only use io.AddKeyEvent(), either only fill legacy io.KeysDown[] + io.KeyMap[]. Not both!");
3925 }
3926 else
3927 {
3928 if (g.FrameCount == 0)
3929 for (int n = ImGuiKey_LegacyNativeKey_BEGIN; n < ImGuiKey_LegacyNativeKey_END; n++)
3930 IM_ASSERT(g.IO.KeyMap[n] == -1 && "Backend is not allowed to write to io.KeyMap[0..511]!");
3931
3932 // Build reverse KeyMap (Named -> Legacy)
3933 for (int n = ImGuiKey_NamedKey_BEGIN; n < ImGuiKey_NamedKey_END; n++)
3934 if (io.KeyMap[n] != -1)
3935 {
3936 IM_ASSERT(IsLegacyKey((ImGuiKey)io.KeyMap[n]));
3937 io.KeyMap[io.KeyMap[n]] = n;
3938 }
3939
3940 // Import legacy keys into new ones
3941 for (int n = ImGuiKey_LegacyNativeKey_BEGIN; n < ImGuiKey_LegacyNativeKey_END; n++)
3942 if (io.KeysDown[n] || io.BackendUsingLegacyKeyArrays == 1)
3943 {
3944 const ImGuiKey key = (ImGuiKey)(io.KeyMap[n] != -1 ? io.KeyMap[n] : n);
3945 IM_ASSERT(io.KeyMap[n] == -1 || IsNamedKey(key));
3946 io.KeysData[key].Down = io.KeysDown[n];
3947 io.BackendUsingLegacyKeyArrays = 1;
3948 }
3949 if (io.BackendUsingLegacyKeyArrays == 1)
3950 {
3951 io.KeysData[ImGuiKey_ModCtrl].Down = io.KeyCtrl;
3952 io.KeysData[ImGuiKey_ModShift].Down = io.KeyShift;
3953 io.KeysData[ImGuiKey_ModAlt].Down = io.KeyAlt;
3954 io.KeysData[ImGuiKey_ModSuper].Down = io.KeySuper;
3955 }
3956 }
3957#endif
3958
3959 // Clear gamepad data if disabled
3960 if ((io.BackendFlags & ImGuiBackendFlags_HasGamepad) == 0)
3961 for (int i = ImGuiKey_Gamepad_BEGIN; i < ImGuiKey_Gamepad_END; i++)
3962 {
3963 io.KeysData[i - ImGuiKey_KeysData_OFFSET].Down = false;
3964 io.KeysData[i - ImGuiKey_KeysData_OFFSET].AnalogValue = 0.0f;
3965 }
3966
3967 // Update keys

Callers

nothing calls this directly

Calls 2

IsLegacyKeyFunction · 0.85
IsNamedKeyFunction · 0.85

Tested by

no test coverage detected