/// <summary> /// Checks for keyboard input and fires events based on that input. /// </summary> public void Update() { KeyboardState ks = Keyboard.GetState(); m_callbackcache.Clear(); foreach (KeyValuePair <Keys, ButtonWrapper> mapvalue in m_keymap) { if (ks[mapvalue.Key] == m_previousstate[mapvalue.Key]) { continue; } ButtonMap buttonmap = CurrentInput[mapvalue.Value.MapIndex]; Boolean pressed = ks[mapvalue.Key] == KeyState.Down; Action <Boolean> callback = buttonmap.GetCallback(mapvalue.Value.ButtonIndex); if (callback != null && m_callbackcache.Contains(callback) == false) { callback(pressed); m_callbackcache.Add(callback); } } m_previousstate = ks; }
/// <summary> /// Copies the input callback in the given buttonmap. /// </summary> /// <param name="map">The ButtonMap to copy from.</param> public void Set(ButtonMap map) { if (map == null) { throw new ArgumentNullException("map"); } Clear(); foreach (var iter in map.m_buttonmap) { m_buttonmap.Add(iter.Key, iter.Value); } }
/// <summary> /// Copies the input callback in the given buttonmap. /// </summary> /// <param name="map">The ButtonMap to copy from.</param> public void Set(ButtonMap map) { if (map == null) throw new ArgumentNullException("map"); Clear(); foreach (var iter in map.m_buttonmap) m_buttonmap.Add(iter.Key, iter.Value); }