MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / GetKeyPressedAmount

Method GetKeyPressedAmount

imgui_tiny_app/imgui/imgui.cpp:10134–10142  ·  view source on GitHub ↗

Return value representing the number of presses in the last time period, for the given repeat rate (most often returns 0 or 1. The result is generally only >1 when RepeatRate is smaller than DeltaTime, aka large DeltaTime or fast RepeatRate)

Source from the content-addressed store, hash-verified

10132// Return value representing the number of presses in the last time period, for the given repeat rate
10133// (most often returns 0 or 1. The result is generally only >1 when RepeatRate is smaller than DeltaTime, aka large DeltaTime or fast RepeatRate)
10134int ImGui::GetKeyPressedAmount(ImGuiKey key, float repeat_delay, float repeat_rate)
10135{
10136 ImGuiContext& g = *GImGui;
10137 const ImGuiKeyData* key_data = GetKeyData(key);
10138 if (!key_data->Down) // In theory this should already be encoded as (DownDuration < 0.0f), but testing this facilitates eating mechanism (until we finish work on key ownership)
10139 return 0;
10140 const float t = key_data->DownDuration;
10141 return CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, repeat_delay, repeat_rate);
10142}
10143
10144// Return 2D vector representing the combination of four cardinal direction, with analog value support (for e.g. ImGuiKey_GamepadLStick* values).
10145ImVec2 ImGui::GetKeyMagnitude2d(ImGuiKey key_left, ImGuiKey key_right, ImGuiKey key_up, ImGuiKey key_down)

Callers

nothing calls this directly

Calls 1

GetKeyDataFunction · 0.85

Tested by

no test coverage detected