1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-26 14:38:34 +01:00

fixed new InputHandler deadzone querying equality being inverted

This commit is contained in:
Ell 2022-03-14 15:18:01 +01:00
parent 5d97ab033f
commit 35e3896dc1

View file

@ -61,7 +61,7 @@ namespace MLEM.Input {
public bool StoreAllActiveInputs; public bool StoreAllActiveInputs;
/// <summary> /// <summary>
/// This field represents the deadzone that gamepad <see cref="Buttons"/> have when input is queried for them using this input handler. /// This field represents the deadzone that gamepad <see cref="Buttons"/> have when input is queried for them using this input handler.
/// A deadzone is the percentage (between 0 and 1) that an analog value has to reach for it to be considered down (<see cref="IsGamepadButtonDown"/>) or pressed (<see cref="IsGamepadButtonPressed"/>). /// A deadzone is the percentage (between 0 and 1) that an analog value has to exceed for it to be considered down (<see cref="IsGamepadButtonDown"/>) or pressed (<see cref="IsGamepadButtonPressed"/>).
/// Querying of analog values is done using <see cref="GamepadExtensions.GetAnalogValue"/>. /// Querying of analog values is done using <see cref="GamepadExtensions.GetAnalogValue"/>.
/// </summary> /// </summary>
public float GamepadButtonDeadzone; public float GamepadButtonDeadzone;
@ -451,48 +451,48 @@ namespace MLEM.Input {
public bool IsGamepadButtonDown(Buttons button, int index = -1) { public bool IsGamepadButtonDown(Buttons button, int index = -1) {
if (index < 0) { if (index < 0) {
for (var i = 0; i < this.ConnectedGamepads; i++) { for (var i = 0; i < this.ConnectedGamepads; i++) {
if (this.GetGamepadState(i).GetAnalogValue(button) >= this.GamepadButtonDeadzone) if (this.GetGamepadState(i).GetAnalogValue(button) > this.GamepadButtonDeadzone)
return true; return true;
} }
return false; return false;
} }
return this.GetGamepadState(index).GetAnalogValue(button) >= this.GamepadButtonDeadzone; return this.GetGamepadState(index).GetAnalogValue(button) > this.GamepadButtonDeadzone;
} }
/// <inheritdoc cref="GamePadState.IsButtonUp"/> /// <inheritdoc cref="GamePadState.IsButtonUp"/>
public bool IsGamepadButtonUp(Buttons button, int index = -1) { public bool IsGamepadButtonUp(Buttons button, int index = -1) {
if (index < 0) { if (index < 0) {
for (var i = 0; i < this.ConnectedGamepads; i++) { for (var i = 0; i < this.ConnectedGamepads; i++) {
if (this.GetGamepadState(i).GetAnalogValue(button) < this.GamepadButtonDeadzone) if (this.GetGamepadState(i).GetAnalogValue(button) <= this.GamepadButtonDeadzone)
return true; return true;
} }
return false; return false;
} }
return this.GetGamepadState(index).GetAnalogValue(button) < this.GamepadButtonDeadzone; return this.GetGamepadState(index).GetAnalogValue(button) <= this.GamepadButtonDeadzone;
} }
/// <inheritdoc cref="GamePadState.IsButtonDown"/> /// <inheritdoc cref="GamePadState.IsButtonDown"/>
public bool WasGamepadButtonDown(Buttons button, int index = -1) { public bool WasGamepadButtonDown(Buttons button, int index = -1) {
if (index < 0) { if (index < 0) {
for (var i = 0; i < this.ConnectedGamepads; i++) { for (var i = 0; i < this.ConnectedGamepads; i++) {
if (this.GetLastGamepadState(i).GetAnalogValue(button) >= this.GamepadButtonDeadzone) if (this.GetLastGamepadState(i).GetAnalogValue(button) > this.GamepadButtonDeadzone)
return true; return true;
} }
return false; return false;
} }
return this.GetLastGamepadState(index).GetAnalogValue(button) >= this.GamepadButtonDeadzone; return this.GetLastGamepadState(index).GetAnalogValue(button) > this.GamepadButtonDeadzone;
} }
/// <inheritdoc cref="GamePadState.IsButtonUp"/> /// <inheritdoc cref="GamePadState.IsButtonUp"/>
public bool WasGamepadButtonUp(Buttons button, int index = -1) { public bool WasGamepadButtonUp(Buttons button, int index = -1) {
if (index < 0) { if (index < 0) {
for (var i = 0; i < this.ConnectedGamepads; i++) { for (var i = 0; i < this.ConnectedGamepads; i++) {
if (this.GetLastGamepadState(i).GetAnalogValue(button) < this.GamepadButtonDeadzone) if (this.GetLastGamepadState(i).GetAnalogValue(button) <= this.GamepadButtonDeadzone)
return true; return true;
} }
return false; return false;
} }
return this.GetLastGamepadState(index).GetAnalogValue(button) < this.GamepadButtonDeadzone; return this.GetLastGamepadState(index).GetAnalogValue(button) <= this.GamepadButtonDeadzone;
} }
/// <summary> /// <summary>