private static bool TryGetCheckedKey(KeyCode key, out VirtualButton button) { return(TryGetCheckedFrom(m_Keys, key, out button)); }
private static bool TryGetCheckedButton(string buttonName, out VirtualButton button) { return(TryGetCheckedFrom(m_Buttons, buttonName, out button)); }
private static bool TryGetCheckedFrom <TKey>(Dictionary <TKey, VirtualButton> dictionary, TKey key, out VirtualButton button) { button = default; if (dictionary.TryGetValue(key, out button)) { if (!button.IsPressed && !button.IsUp) { dictionary.Remove(key); button = default; } } return(button != default); }