feat: key history algorithm
This commit is contained in:
parent
5d2da3ddbf
commit
1869a92580
8 changed files with 115 additions and 10 deletions
|
@ -1,17 +1,15 @@
|
|||
namespace Domain.Input {
|
||||
public abstract class InputReader {
|
||||
private bool _wasPressed;
|
||||
private bool _isPressed;
|
||||
protected bool WasPressed;
|
||||
protected bool IsPressed;
|
||||
|
||||
protected abstract int Key { get; }
|
||||
|
||||
public void UpdateInput() {
|
||||
_wasPressed = _isPressed;
|
||||
_isPressed = Win32API.GetAsyncKeyState(Key) != 0;
|
||||
public virtual void UpdateInput() {
|
||||
WasPressed = IsPressed;
|
||||
IsPressed = Win32API.GetAsyncKeyState(Key) != 0;
|
||||
}
|
||||
|
||||
public bool KeyDown() => _isPressed && !_wasPressed;
|
||||
public bool KeyPressed() => _isPressed;
|
||||
public bool KeyUp() => !_isPressed && _wasPressed;
|
||||
public bool KeyDown() => IsPressed && !WasPressed;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue