feat: most sequential characters working
This commit is contained in:
parent
77ee7a844e
commit
61c18429a2
20 changed files with 140 additions and 55 deletions
|
@ -5,8 +5,9 @@ namespace Domain {
|
|||
public class KeyHistory {
|
||||
private readonly LimitedSizeList<int> _lastPresses = new(10);
|
||||
|
||||
private readonly bool[] _isPressed = new bool[26];
|
||||
private readonly bool[] _wasPressed = new bool[26];
|
||||
private readonly int[] _customKeys = { 191, 51, 222, 186 };
|
||||
private readonly bool[] _isPressed = new bool[26 + 5];
|
||||
private readonly bool[] _wasPressed = new bool[26 + 5];
|
||||
|
||||
public void KeyPressed(int key) => _lastPresses.Add(key);
|
||||
|
||||
|
@ -25,6 +26,19 @@ namespace Domain {
|
|||
_isPressed[j] = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _customKeys.Length; i++) {
|
||||
int pressIndex = 26 + i;
|
||||
_wasPressed[pressIndex] = _isPressed[pressIndex];
|
||||
short state = Win32API.GetAsyncKeyState(_customKeys[i]);
|
||||
|
||||
if (!_wasPressed[pressIndex] && state != 0) {
|
||||
_isPressed[pressIndex] = true;
|
||||
KeyPressed(_customKeys[i]);
|
||||
}else if (_isPressed[pressIndex] && state == 0) {
|
||||
_isPressed[pressIndex] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ContainsSequence(List<int> sequence) {
|
||||
|
@ -43,6 +57,7 @@ namespace Domain {
|
|||
}
|
||||
}
|
||||
|
||||
_lastPresses.List.Clear();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue