diff --git a/MLEM/Input/InputHandler.cs b/MLEM/Input/InputHandler.cs index f930fcf..09d710f 100644 --- a/MLEM/Input/InputHandler.cs +++ b/MLEM/Input/InputHandler.cs @@ -371,7 +371,7 @@ namespace MLEM.Input { /// The key to query. /// If the key is pressed and the press is not consumed yet. public bool IsKeyPressedAvailable(Keys key) { - return this.IsKeyPressed(key) && !this.consumedPresses.Contains((key, -1)); + return this.IsKeyPressed(key) && !this.IsPressConsumed(key); } /// @@ -457,7 +457,7 @@ namespace MLEM.Input { /// The button to query. /// If the button is pressed and the press is not consumed yet. public bool IsMouseButtonPressedAvailable(MouseButton button) { - return this.IsMouseButtonPressed(button) && !this.consumedPresses.Contains((button, -1)); + return this.IsMouseButtonPressed(button) && !this.IsPressConsumed(button); } /// @@ -567,7 +567,7 @@ namespace MLEM.Input { /// The zero-based index of the gamepad, or -1 for any gamepad. /// Whether the given button is pressed and the press is not consumed yet. public bool IsGamepadButtonPressedAvailable(Buttons button, int index = -1) { - return this.IsGamepadButtonPressed(button) && !this.consumedPresses.Contains((button, index)) && (index < 0 || !this.consumedPresses.Contains((button, -1))); + return this.IsGamepadButtonPressed(button) && !this.IsPressConsumed(button, index) && (index < 0 || !this.IsPressConsumed(button)); } /// @@ -749,6 +749,15 @@ namespace MLEM.Input { return false; } + /// + public bool IsAnyPressedAvailable(params GenericInput[] controls) { + foreach (var control in controls) { + if (this.IsPressedAvailable(control)) + return true; + } + return false; + } + /// /// Tries to retrieve the amount of time that a given has been held down for. /// If the input is currently down, this method returns true and the amount of time that it has been down for is stored in . @@ -777,6 +786,17 @@ namespace MLEM.Input { return time; } + /// + /// Returns whether the given 's press state has been consumed using . + /// If an input has been consumed, and will always return false for that input. + /// + /// The input to query. + /// The index of the gamepad to query (if applicable), or -1 for any gamepad. + /// Whether a press has been consumed for the given input. + public bool IsPressConsumed(GenericInput input, int index = -1) { + return this.consumedPresses.Contains((input, index)); + } + private void AccumulateDown(GenericInput input, int index) { this.inputsDownAccum.Add((input, index), this.inputsDown.TryGetValue((input, index), out var start) ? start : DateTime.UtcNow); }