private bool SetTypeXbox(ButtonAlias button) { button.Pressed = PressType.XboxController; //_pressedButtons.Add(button.GetAssociation()); _buttonLocks.Add(button.GetAssociation(), button); return(true); }
private bool buttonNotHeldEnough(ButtonAlias button) { if (button.GetHoldable() > 0 && _holdTimes.ContainsKey(button.GetAssociation()) && _holdTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) > 0 && !_repeatHoldTimes.ContainsKey(button.GetAssociation())) { return(false); } return(true); }
private bool isHoldable(ButtonAlias button) { if (button.GetHoldable() == 0) { return(true); } return(false); }
private bool buttonNotHeldLongEnough(ButtonAlias button) { if (!_repeatHoldTimes.ContainsKey(button.GetAssociation()) && button.GetHoldableRepeat() >= 0) { _repeatHoldTimes.Add(button.GetAssociation(), SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds + button.GetHoldableRepeat()); return(false); } return(true); }
private bool isHoldableButNotHeldEnough(ButtonAlias button) { if (button.GetHoldable() > 0 && !_holdTimes.ContainsKey(button.GetAssociation())) { _holdTimes.Add(button.GetAssociation(), SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds + button.GetHoldable()); return(false); } return(true); }
private bool checkCommandButtonUp(ButtonAlias button) { if (_gamePadState.IsButtonUp(button.GetButton()) && _buttonLocks.ContainsValue(button)) { RemoveLocksAndHolds(button); return(false); } return(true); }
private bool setupNewKeyAssociation(ButtonAlias button) { if (_keyState.IsKeyDown(button.GetKey()) && !_buttonLocks.ContainsKey(button.GetAssociation())) { button.Pressed = PressType.Key; _buttonLocks.Add(button.GetAssociation(), button); return(true); } return(false); }
private bool buttonHeldEnoughRepeat(ButtonAlias button) { if (_repeatHoldTimes.ContainsKey(button.GetAssociation()) && _repeatHoldTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0) { _repeatHoldTimes.Remove(button.GetAssociation()); _advances++; return(true); } return(false); }
private bool allowOneButtonPress(ButtonAlias button) { if (_holdTimes.ContainsKey(button.GetAssociation()) && _holdTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0 && !_repeatHoldTimes.ContainsKey(button.GetAssociation()) && button.GetHoldableRepeat() >= 0) { // Remove, re-add, rinse, repeat! _repeatHoldTimes.Add(button.GetAssociation(), SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds + button.GetHoldableRepeat()); return(false); } return(true); }
private void RemoveLocksAndHolds(ButtonAlias button) { if (_holdTimes.ContainsKey(button.GetAssociation()) && button.GetHoldable() > 0 && _holdTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0 && !_repeatHoldTimes.ContainsKey(button.GetAssociation())) { _holdTimes.Remove(button.GetAssociation()); _buttonLocks.Remove(button.GetAssociation()); } else if (_repeatHoldTimes.ContainsKey(button.GetAssociation()) && _repeatHoldTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0) { _repeatHoldTimes.Remove(button.GetAssociation()); _buttonLocks.Remove(button.GetAssociation()); } else if (!_holdTimes.ContainsKey(button.GetAssociation())) { _buttonLocks.Remove(button.GetAssociation()); } }
private bool checkCommandKeyUp(ButtonAlias button) { if (_keyState.IsKeyUp(button.GetKey()) && _buttonLocks.ContainsValue(button)) { if (_holdTimes.ContainsKey(button.GetAssociation()) && button.GetHoldable() > 0 && _holdTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0 && !_repeatHoldTimes.ContainsKey(button.GetAssociation())) { _holdTimes.Remove(button.GetAssociation()); _buttonLocks.Remove(button.GetAssociation()); } else if (_repeatHoldTimes.ContainsKey(button.GetAssociation()) && _repeatHoldTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0) { _repeatHoldTimes.Remove(button.GetAssociation()); } else if (!_holdTimes.ContainsKey(button.GetAssociation())) { _buttonLocks.Remove(button.GetAssociation()); } return(false); } return(true); }
public void TestAddingToSuperButtonArray() { var handler = new InputHandler(); //var keystate = new KeyboardState(); var aliasAButton = new ButtonAlias(Buttons.A, -1, -1, "TestAlias"); var aliasAKey = new ButtonAlias(Keys.Up, -1, -1, "TestAlias"); var dictionary = new Dictionary<ButtonAction, List<ButtonAlias>>(); var listOfAliases = new List<ButtonAlias> { aliasAButton, aliasAKey }; dictionary.Add(ButtonAction.MenuUp, listOfAliases); var buttonsetter = typeof(InputHandler).GetField("_superButton", BindingFlags.Static | BindingFlags.NonPublic); buttonsetter.SetValue(handler, dictionary); var keystate = typeof(InputHandler).GetField("_keyState", BindingFlags.NonPublic | BindingFlags.Instance); var keystatev = keystate.GetValue(handler); var test = typeof(KeyboardState).GetField("currentState1", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); test.SetValue(keystatev, UInt32.Parse("64")); keystate.SetValue(handler, keystatev); Assert.IsTrue(handler.IsButtonPressed(ButtonAction.MenuUp)); }
private bool checkButtonDynamics(ButtonAlias button) { if (button.IsHoldable()) { if (isHoldable(button)) { return(true); } if (!isHoldableButNotHeldEnough(button)) { return(false); } if (!buttonNotHeldEnough(button)) { return(false); } if (!allowOneButtonPress(button)) { return(false); } if (buttonHeldEnoughRepeat(button)) { return(true); } if (!buttonNotHeldLongEnough(button)) { return(false); } } return(false); }
private bool isHoldableButNotHeldEnough(ButtonAlias button) { if (button.GetHoldable() > 0 && !_holdTimes.ContainsKey(button.GetAssociation())) { _holdTimes.Add(button.GetAssociation(), SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds + button.GetHoldable()); return false; } return true; }
private bool checkCommandKeyUp(ButtonAlias button) { if (_keyState.IsKeyUp(button.GetKey()) && _buttonLocks.ContainsValue(button)) { if (_holdTimes.ContainsKey(button.GetAssociation()) && button.GetHoldable() > 0 && _holdTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0 && !_repeatHoldTimes.ContainsKey(button.GetAssociation())) { _holdTimes.Remove(button.GetAssociation()); _buttonLocks.Remove(button.GetAssociation()); } else if (_repeatHoldTimes.ContainsKey(button.GetAssociation()) && _repeatHoldTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0) { _repeatHoldTimes.Remove(button.GetAssociation()); } else if (!_holdTimes.ContainsKey(button.GetAssociation())) { _buttonLocks.Remove(button.GetAssociation()); } return false; } return true; }
private bool isHoldable(ButtonAlias button) { if (button.GetHoldable() == 0) { return true; } return false; }
private bool checkButtonDynamics(ButtonAlias button) { if (button.IsHoldable()) { if (isHoldable(button)) return true; if (!isHoldableButNotHeldEnough(button)) return false; if (!buttonNotHeldEnough(button)) return false; if (!allowOneButtonPress(button)) return false; if (buttonHeldEnoughRepeat(button)) return true; if (!buttonNotHeldLongEnough(button)) return false; } return false; }
private bool checkCommandButtonUp(ButtonAlias button) { if (_gamePadState.IsButtonUp(button.GetButton()) && _buttonLocks.ContainsValue(button)) { RemoveLocksAndHolds(button); return false; } return true; }
private bool buttonNotHeldLongEnough(ButtonAlias button) { if (!_repeatHoldTimes.ContainsKey(button.GetAssociation()) && button.GetHoldableRepeat() >= 0) { _repeatHoldTimes.Add(button.GetAssociation(), SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds + button.GetHoldableRepeat()); return false; } return true; }
private bool buttonNotHeldEnough(ButtonAlias button) { if (button.GetHoldable() > 0 && _holdTimes.ContainsKey(button.GetAssociation()) && _holdTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) > 0 && !_repeatHoldTimes.ContainsKey(button.GetAssociation())) { return false; } return true; }
private bool buttonHeldEnoughRepeat(ButtonAlias button) { if (_repeatHoldTimes.ContainsKey(button.GetAssociation()) && _repeatHoldTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0) { _repeatHoldTimes.Remove(button.GetAssociation()); _advances++; return true; } return false; }
private bool allowOneButtonPress(ButtonAlias button) { if (_holdTimes.ContainsKey(button.GetAssociation()) && _holdTimes[button.GetAssociation()].CompareTo(SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds) < 0 && !_repeatHoldTimes.ContainsKey(button.GetAssociation()) && button.GetHoldableRepeat() >= 0) { // Remove, re-add, rinse, repeat! _repeatHoldTimes.Add(button.GetAssociation(), SystemMain.CurrentGameTime.TotalRealTime.TotalSeconds + button.GetHoldableRepeat()); return false; } return true; }
private bool SetTypeXbox(ButtonAlias button) { button.Pressed = PressType.XboxController; //_pressedButtons.Add(button.GetAssociation()); _buttonLocks.Add(button.GetAssociation(), button); return true; }
private bool setupNewKeyAssociation(ButtonAlias button) { if (_keyState.IsKeyDown(button.GetKey()) && !_buttonLocks.ContainsKey(button.GetAssociation())) { button.Pressed = PressType.Key; _buttonLocks.Add(button.GetAssociation(), button); return true; } return false; }
public void TestAliasCreationForKey() { var alias = new ButtonAlias(Keys.A, -1, -1, "TestAlias"); Assert.IsNotNull(alias); }