1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-09 19:18:44 +02:00

Set default values for InputHandler held and pressed keys to avoid an exception if buttons are held in the very first frame

This commit is contained in:
Ell 2021-06-30 19:40:43 +02:00
parent 25efa0bd50
commit 58bd076e2a
2 changed files with 8 additions and 3 deletions

View file

@ -1,13 +1,18 @@
# Changelog
MLEM uses [semantic versioning](https://semver.org/).
This changelog also contains information on versions that have yet to be released. The changelog for unreleased versions might be edited over time as new features get added, changed or removed. To see the newest released version's code, check out the [release branch](https://github.com/Ellpeck/MLEM/tree/release).
This changelog also contains information on versions that have yet to be released. The changelog for unreleased versions might be edited over time as new features get added, changed or removed.
You can get prerelease builds of unreleased versions on [BaGet](https://nuget.ellpeck.de). To see the newest released version's code, check out the [release branch](https://github.com/Ellpeck/MLEM/tree/release).
Jump to version:
- [5.1.0 (Unreleased)](#510-unreleased)
- [5.0.0](#500)
## 5.1.0 (Unreleased)
### MLEM
Fixes
- Set default values for InputHandler held and pressed keys to avoid an exception if buttons are held in the very first frame
## 5.0.0
### MLEM

View file

@ -120,13 +120,13 @@ namespace MLEM.Input {
/// An array of all <see cref="Keys"/>, <see cref="Buttons"/> and <see cref="MouseButton"/> values that are currently down.
/// Note that this value only gets set if <see cref="StoreAllActiveInputs"/> is true.
/// </summary>
public GenericInput[] InputsDown { get; private set; }
public GenericInput[] InputsDown { get; private set; } = Array.Empty<GenericInput>();
/// <summary>
/// An array of all <see cref="Keys"/>, <see cref="Buttons"/> and <see cref="MouseButton"/> that are currently considered pressed.
/// An input is considered pressed if it was up in the last update, and is up in the current one.
/// Note that this value only gets set if <see cref="StoreAllActiveInputs"/> is true.
/// </summary>
public GenericInput[] InputsPressed { get; private set; }
public GenericInput[] InputsPressed { get; private set; } = Array.Empty<GenericInput>();
private readonly List<GenericInput> inputsDownAccum = new List<GenericInput>();
/// <summary>
/// Set this field to false to enable <see cref="InputsDown"/> and <see cref="InputsPressed"/> being calculated.