diff --git a/MLEM/Input/InputHandler.cs b/MLEM/Input/InputHandler.cs index db55cc8..48ddddc 100644 --- a/MLEM/Input/InputHandler.cs +++ b/MLEM/Input/InputHandler.cs @@ -15,18 +15,74 @@ namespace MLEM.Input { public class InputHandler : GameComponent { /// - /// Contains the keyboard state from the last update call + /// Contains all of the gestures that have finished during the last update call. + /// To easily query these gestures, use /// - public KeyboardState LastKeyboardState { get; private set; } - /// - /// Contains the current keyboard state - /// - public KeyboardState KeyboardState { get; private set; } + public readonly ReadOnlyCollection Gestures; + /// /// Set this field to false to disable keyboard handling for this input handler. /// public bool HandleKeyboard; + /// + /// Set this field to false to disable mouse handling for this input handler. + /// + public bool HandleMouse; + /// + /// Set this field to false to disable keyboard handling for this input handler. + /// + public bool HandleGamepads; + /// + /// Set this field to false to disable touch handling for this input handler. + /// + public bool HandleTouch; + /// + /// This is the amount of time that has to pass before the first keyboard repeat event is triggered. + /// + /// + public TimeSpan KeyRepeatDelay = TimeSpan.FromSeconds(0.65); + /// + /// This is the amount of time that has to pass between keyboard repeat events. + /// + /// + public TimeSpan KeyRepeatRate = TimeSpan.FromSeconds(0.05); + /// + /// Set this field to false to disable keyboard repeat event handling. + /// + public bool HandleKeyboardRepeats = true; + /// + /// Set this field to false to disable gamepad repeat event handling. + /// + public bool HandleGamepadRepeats = true; + /// + /// Set this field to false to enable and being calculated. + /// + public bool StoreAllActiveInputs; + /// + /// An array of all , and values that are currently down. + /// Note that this value only gets set if is true. + /// + public GenericInput[] InputsDown { get; private set; } = Array.Empty(); + /// + /// An array of all , and 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 is true. + /// + public GenericInput[] InputsPressed { get; private set; } = Array.Empty(); + /// + /// Contains the touch state from the last update call + /// + public TouchCollection LastTouchState { get; private set; } + /// + /// Contains the current touch state + /// + public TouchCollection TouchState { get; private set; } + /// + /// Contains the amount of gamepads that are currently connected. + /// This field is automatically updated in + /// + public int ConnectedGamepads { get; private set; } /// /// Contains the mouse state from the last update call /// @@ -52,86 +108,27 @@ namespace MLEM.Input { /// public int LastScrollWheel => this.LastMouseState.ScrollWheelValue; /// - /// Set this field to false to disable mouse handling for this input handler. + /// Contains the keyboard state from the last update call /// - public bool HandleMouse; + public KeyboardState LastKeyboardState { get; private set; } + /// + /// Contains the current keyboard state + /// + public KeyboardState KeyboardState { get; private set; } private readonly GamePadState[] lastGamepads = new GamePadState[GamePad.MaximumGamePadCount]; private readonly GamePadState[] gamepads = new GamePadState[GamePad.MaximumGamePadCount]; - /// - /// Contains the amount of gamepads that are currently connected. - /// This field is automatically updated in - /// - public int ConnectedGamepads { get; private set; } - /// - /// Set this field to false to disable keyboard handling for this input handler. - /// - public bool HandleGamepads; - - /// - /// Contains the touch state from the last update call - /// - public TouchCollection LastTouchState { get; private set; } - /// - /// Contains the current touch state - /// - public TouchCollection TouchState { get; private set; } - /// - /// Contains all of the gestures that have finished during the last update call. - /// To easily query these gestures, use - /// - public readonly ReadOnlyCollection Gestures; - private readonly List gestures = new List(); - /// - /// Set this field to false to disable touch handling for this input handler. - /// - public bool HandleTouch; - - /// - /// This is the amount of time that has to pass before the first keyboard repeat event is triggered. - /// - /// - public TimeSpan KeyRepeatDelay = TimeSpan.FromSeconds(0.65); - /// - /// This is the amount of time that has to pass between keyboard repeat events. - /// - /// - public TimeSpan KeyRepeatRate = TimeSpan.FromSeconds(0.05); - - /// - /// Set this field to false to disable keyboard repeat event handling. - /// - public bool HandleKeyboardRepeats = true; - private DateTime heldKeyStart; - private DateTime lastKeyRepeat; - private bool triggerKeyRepeat; - private Keys heldKey; - - /// - /// Set this field to false to disable gamepad repeat event handling. - /// - public bool HandleGamepadRepeats = true; private readonly DateTime[] heldGamepadButtonStarts = new DateTime[GamePad.MaximumGamePadCount]; private readonly DateTime[] lastGamepadButtonRepeats = new DateTime[GamePad.MaximumGamePadCount]; private readonly bool[] triggerGamepadButtonRepeat = new bool[GamePad.MaximumGamePadCount]; private readonly Buttons?[] heldGamepadButtons = new Buttons?[GamePad.MaximumGamePadCount]; - - /// - /// An array of all , and values that are currently down. - /// Note that this value only gets set if is true. - /// - public GenericInput[] InputsDown { get; private set; } = Array.Empty(); - /// - /// An array of all , and 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 is true. - /// - public GenericInput[] InputsPressed { get; private set; } = Array.Empty(); private readonly List inputsDownAccum = new List(); - /// - /// Set this field to false to enable and being calculated. - /// - public bool StoreAllActiveInputs; + private readonly List gestures = new List(); + + private DateTime heldKeyStart; + private DateTime lastKeyRepeat; + private bool triggerKeyRepeat; + private Keys heldKey; /// /// Creates a new input handler with optional initial values.