public void UpdateKeyboard(float fDeltaTime) { m_PrevKey = m_CurrKey; m_CurrKey = Keyboard.GetState(); m_ActiveBinds.Clear(); // Build the list of bindings which were triggered this frame foreach (KeyValuePair <eBindings, BindInfo> k in m_Bindings) { Keys Key = k.Value.m_Key; eBindType Type = k.Value.m_Type; switch (Type) { case (eBindType.Held): if ((m_PrevKey.IsKeyDown(Key) && m_CurrKey.IsKeyDown(Key)) || (!m_PrevKey.IsKeyDown(Key) && m_CurrKey.IsKeyDown(Key))) { m_ActiveBinds.Add(k.Key, k.Value); } break; case (eBindType.JustPressed): if (!m_PrevKey.IsKeyDown(Key) && m_CurrKey.IsKeyDown(Key)) { m_ActiveBinds.Add(k.Key, k.Value); } break; case (eBindType.JustReleased): if (m_PrevKey.IsKeyDown(Key) && !m_CurrKey.IsKeyDown(Key)) { m_ActiveBinds.Add(k.Key, k.Value); } break; } } if (m_ActiveBinds.Count > 0) { // Send the list to the UI first, then any remnants to the game if (GameState.Get().UICount != 0) { GameState.Get().GetCurrentUI().KeyboardInput(m_ActiveBinds); } GameState.Get().KeyboardInput(m_ActiveBinds, fDeltaTime); } }
public BindInfo(Keys Key, eBindType Type) { m_Key = Key; m_Type = Type; }