feat: l geminada working
This commit is contained in:
parent
1869a92580
commit
30ca50fb35
15 changed files with 189 additions and 29 deletions
|
@ -3,7 +3,7 @@ using System.Linq;
|
|||
|
||||
namespace Domain.Input {
|
||||
public class GeminadaReader : InputReader {
|
||||
protected override int Key { get; } = 0x33;
|
||||
protected sealed override int Key { get; } = 0x33;
|
||||
private int LKey { get; } = 76;
|
||||
|
||||
private bool _lPressed;
|
||||
|
@ -11,22 +11,24 @@ namespace Domain.Input {
|
|||
private bool _dotPressed;
|
||||
private bool _dotWasPressed;
|
||||
|
||||
private List<int> _lastPresses;
|
||||
private readonly KeyHistory _history;
|
||||
private readonly List<int> _desiredSequence;
|
||||
|
||||
public override void UpdateInput() {
|
||||
if (UpdateLInput()) {
|
||||
if (_lastPresses.Count == 0) {
|
||||
_lastPresses.Add(LKey);
|
||||
} else if (_lastPresses.Count >= 2) {
|
||||
if (_lastPresses[^1] == Key && _lastPresses[^2] == LKey) {
|
||||
IsPressed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateDotInput();
|
||||
public GeminadaReader(KeyHistory history) {
|
||||
_history = history;
|
||||
_desiredSequence = new List<int> { LKey, Key, LKey };
|
||||
}
|
||||
|
||||
private bool UpdateDotInput() {
|
||||
public override void UpdateInput() {
|
||||
if (UpdateDotInputDown()) {
|
||||
_history.KeyPressed(Key);
|
||||
}
|
||||
|
||||
WasPressed = IsPressed;
|
||||
IsPressed = _history.ContainsSequence(_desiredSequence);
|
||||
}
|
||||
|
||||
private bool UpdateDotInputDown() {
|
||||
_dotWasPressed = _dotPressed;
|
||||
short dotState = Win32API.GetAsyncKeyState(Key);
|
||||
|
||||
|
@ -40,7 +42,7 @@ namespace Domain.Input {
|
|||
return false;
|
||||
}
|
||||
|
||||
private bool UpdateLInput() {
|
||||
private bool UpdateLInputDown() {
|
||||
_lWasPressed = _lPressed;
|
||||
short lState = Win32API.GetAsyncKeyState(LKey);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue