} // OnKeyPressed public void OnKeyReleased(Keys key, GameTime gameTime, CurrentKeyState currentKeyState) { foreach (var kvp in _keyboardControls) { var controlFound = false; var gameControls = kvp.Value; for (var i = 0; i < gameControls.Count && !controlFound; i++) { var gameControl = gameControls[i]; if (gameControl.State != KeyboardControlState.Released) { continue; } var releasedKeyFound = false; var containsControlKey = gameControl.ControlKeys.Length > 0 ? true : false; for (var c = 0; c < gameControl.ControlKeys.Length; c++) { var findKey = gameControl.ControlKeys[c]; var keyFound = false; if (findKey == key) { releasedKeyFound = true; keyFound = true; } else { for (var k = 0; k < currentKeyState.HeldKeys.Count && !keyFound; k++) { if (currentKeyState.HeldKeys[k] == findKey) { keyFound = true; } } } containsControlKey = containsControlKey && keyFound; } if (containsControlKey && releasedKeyFound) { controlFound = true; OnGameKeyControl?.Invoke(gameControl.Name, gameTime, KeyboardControlState.Released); } } } } // OnKeyReleased
public virtual void OnKeyDown(Keys key, GameTime gameTime, CurrentKeyState currentKeyState) { }
public virtual void OnKeyReleased(Keys key, GameTime gameTime, CurrentKeyState currentKeyState) { }
public KeyboardManager() { CurrentKeyState = new CurrentKeyState(); }