/// <summary> /// Removes the keyboard mappings for a given key combo /// </summary> /// <param name="keyCombination">The combo to unmap</param> public void UnmapCombo(KeyCombination keyCombination) { _mappings.Remove(keyCombination); _oneShotMappings.Remove(keyCombination); }
/// <summary> /// Unmaps a key /// </summary> /// <param name="keyCombination">The combo</param> /// <param name="keyHandler">The handler</param> public KeyboardMapper Unmap(KeyCombination keyCombination, KeyHandler keyHandler) { #if DEBUG if (DebugMode) Debug.Log("KeyboardMapper.Unmap: " + keyCombination); #endif if (_mappings.ContainsKey(keyCombination)) { _mappings[keyCombination].Remove(keyHandler); if (_mappings[keyCombination].Count == 0) _mappings.Remove(keyCombination); } if (_oneShotMappings.ContainsKey(keyCombination)) { _oneShotMappings[keyCombination].Remove(keyHandler); if (_oneShotMappings[keyCombination].Count == 0) _oneShotMappings.Remove(keyCombination); } return this; }
/// <summary> /// Returns true if the specified mapping exists /// </summary> /// <param name="keyCombination">The combo to check for</param> /// <param name="keyHandler">The handler to check for</param> /// <returns></returns> public bool Maps(KeyCombination keyCombination, KeyHandler keyHandler) { if (_mappings.ContainsKey(keyCombination)) return _mappings[keyCombination].Contains(keyHandler); return false; }
/// <summary> /// Maps a key /// </summary> /// <param name="keyCombination">The combo</param> /// <param name="keyHandler">The handler</param> public KeyboardMapper Map(KeyCombination keyCombination, KeyHandler keyHandler) { #if DEBUG if (DebugMode) Debug.Log("KeyboardMapper.Map: " + keyCombination); #endif if (!_mappings.ContainsKey(keyCombination)) _mappings.Add(keyCombination, new List<KeyHandler>()); _mappings[keyCombination].Add(keyHandler); return this; }
/// <summary> /// Equality /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(KeyCombination other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.EventType, EventType) && Equals(other.KeyCode, KeyCode) && other.Control.Equals(Control) && other.Shift.Equals(Shift) && other.Alt.Equals(Alt); }