private void checkHeld(InputHelper.CommandMove command, InputHelper.KeyState currentKeyState) { int held = 0; Debug.WriteLine("HELD KEY: " + currentKeyState.GetState()); currentKeyState = command.GetCurrentMove(); if (command.IsMaxNegativeReached() == true) { command.Reset(); held = 0; } if (releasedState.GetCurrentInputState() != InputHelper.KeyPress.NONE) { if (releasedState.GetCurrentInputState() == currentKeyState.GetKey() || (releasedState.GetCurrentInputState(releasedState.GetCurrentStateStep()-2) == currentKeyState.GetKey() && releasedState.GetCurrentInputState() != currentKeyState.GetKey())) { command.Reset(); } } for (int i = 0; i < heldState.GetBuffer().Count - 1; i++) { bool reset = (releasedState.GetBuffer().Count >= i + 2 && releasedState.GetBuffer()[i + 1] == currentKeyState.GetKey()); if (reset) { held = 0; command.IncrementNegativeCount(); break; } if (heldState.GetBuffer()[i + 1] == currentKeyState.GetKey()) { held++; command.ResetNegativeEdge(); } else { held = 0; command.Reset(); break; } } Debug.WriteLine("HELD COUNT: " + held); Debug.WriteLine("HELD TIME: " + currentKeyState.GetKeyHeldTime()); if (held >= currentKeyState.GetKeyHeldTime()) { command.Next(); } else { command.IncrementNegativeCount(); } }
private InputBuffer GetNextBuffer(InputHelper.KeyState currentKeyPress) { InputBuffer currentBuffer = null; if (currentKeyPress.GetState() == InputHelper.ButtonState.Pressed) { currentBuffer = pressedState; } else if (currentKeyPress.GetState() == InputHelper.ButtonState.Released) { currentBuffer = releasedState; } else if (currentKeyPress.GetState() == InputHelper.ButtonState.Held) { currentBuffer = heldState; } return currentBuffer; }