feat: most sequential characters working
This commit is contained in:
parent
77ee7a844e
commit
61c18429a2
20 changed files with 140 additions and 55 deletions
|
@ -2,58 +2,7 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace Domain.Input {
|
||||
public class GeminadaReader : InputReader {
|
||||
protected sealed override int Key { get; } = 0x33;
|
||||
private int LKey { get; } = 76;
|
||||
|
||||
private bool _lPressed;
|
||||
private bool _lWasPressed;
|
||||
private bool _dotPressed;
|
||||
private bool _dotWasPressed;
|
||||
|
||||
private readonly KeyHistory _history;
|
||||
private readonly List<int> _desiredSequence;
|
||||
|
||||
public GeminadaReader(KeyHistory history) {
|
||||
_history = history;
|
||||
_desiredSequence = new List<int> { LKey, Key, LKey };
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!_dotWasPressed && dotState != 0) {
|
||||
_dotPressed = true;
|
||||
return true;
|
||||
}
|
||||
if (_dotPressed && dotState == 0) {
|
||||
_dotPressed = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool UpdateLInputDown() {
|
||||
_lWasPressed = _lPressed;
|
||||
short lState = Win32API.GetAsyncKeyState(LKey);
|
||||
|
||||
if (!_lWasPressed && lState != 0) {
|
||||
_lPressed = true;
|
||||
return true;
|
||||
}
|
||||
if (_lPressed && lState == 0) {
|
||||
_lPressed = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public class GeminadaReader : SequentialInputReader {
|
||||
public GeminadaReader(KeyHistory history) : base(history, new List<int>{ 76, 0x33, 76 }) { }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue