private void HandlerMouse_LeftButton(MouseState mouse) { // check if a mouse click occured if (mouse.LeftButton == ButtonState.Released && _oldMouseState.LeftButton == ButtonState.Pressed) { int?i = DetermineInventorySlotClickedBackpack(); int?j = DetermineInventorySlotClickedEquipped(); sbyte?k = HoveredSpell(); Buttons?clickType = DetermineIfButtonIsClicked(); // Button clicked if (clickType != null) { HandlerMouse_LeftButton_Button(clickType.Value); } // Inventory area clicked else if ((i != null || j != null) && IsBoxOpen(Buttons.Inventory)) { HandlerMouse_LeftButton_InventoryArea(mouse, i, j); } // Spells area clicked else if ((k != null) && IsBoxOpen(Buttons.Spells)) { HandlerMouse_LeftButton_SpellsArea(k.Value); } // General area clicked else { HandlerMouse_LeftButton_GeneralArea(mouse); } } }
public Input(Buttons button) { Type = InputTypes.Controller; Key = Keys.None; MouseInput = MouseInputs.None; ControllerButton = button; }
public KeyMapping(Keys?key, Buttons?button, bool singlePressOnly = false, int pressCooldown = 0) { Key = key; this.Button = button; SinglePressOnly = singlePressOnly; PressCooldown = pressCooldown; }
public Input(InputTypes t) { Type = t; Key = Keys.None; MouseInput = MouseInputs.None; ControllerButton = null; }
public Input(MouseInputs mouseIn) { Type = InputTypes.Mouse; Key = Keys.None; MouseInput = mouseIn; ControllerButton = null; }
public Input(Keys key) { Type = InputTypes.Keyboard; Key = key; MouseInput = MouseInputs.None; ControllerButton = null; }
protected override void Parse(ref BitStreamReader bsr) { Cmd = bsr.ReadUInt(); uint byteSize = bsr.ReadUInt(); int indexBeforeData = bsr.CurrentBitIndex; CommandNumber = bsr.ReadUIntIfExists(); TickCount = bsr.ReadUIntIfExists(); ViewAngleX = bsr.ReadFloatIfExists(); ViewAngleY = bsr.ReadFloatIfExists(); ViewAngleZ = bsr.ReadFloatIfExists(); SidewaysMovement = bsr.ReadFloatIfExists(); ForwardMovement = bsr.ReadFloatIfExists(); VerticalMovement = bsr.ReadFloatIfExists(); Buttons = (Buttons?)bsr.ReadUIntIfExists(); Impulse = bsr.ReadByteIfExists(); if (bsr.ReadBool()) { WeaponSelect = bsr.ReadUInt(11); WeaponSubtype = bsr.ReadUIntIfExists(6); } MouseDx = (short?)bsr.ReadUShortIfExists(); MouseDy = (short?)bsr.ReadUShortIfExists(); bsr.CurrentBitIndex = indexBeforeData + (int)(byteSize << 3); }
private GamePadEventArgs MakeArgs(Buttons?button, float triggerstate = 0, Vector2?thumbStickState = null) { var elapsedTime = _gameTime.TotalGameTime - _previousGameTime.TotalGameTime; return(new GamePadEventArgs(_previousState, _currentState, elapsedTime, PlayerIndex, button, triggerstate, thumbStickState)); }
internal ControllerButtonReceiver() { string configString = ModEntry.Config.ControllerButton; if (Enum.TryParse <Buttons>(configString, out Buttons _controllerButton)) { ControllerButton = _controllerButton; } }
public void Update(Buttons button) { switch (Controls.Scheme) { case ControlScheme.GamePad: GamePad = button; break; } }
public IInputService RegisterInput(InputAction Action, Keys?Key = null, Buttons?Button = null) { if (Key.HasValue) { actionToKey[Action] = (Keys)Key; } if (Button.HasValue) { actionToButton[Action] = (Buttons)Button; } return(this); }
private void AddControllerSetting(Mappings mappingType, Buttons?button) { Setting setting = new Setting(ButtonInfos[mappingType].GetLabel(), Keys.None); setting.Pressed(() => Remap(mappingType)); if (button != null) { setting.Set(new List <Buttons> { (Buttons)button }); } Add(setting); }
public Action(string name, Keys primaryKey, Keys secondaryKey, Buttons?primaryButton, Buttons?secondaryButton) { Name = name; PrimaryKey = primaryKey; SecondaryKey = secondaryKey; PrimaryButton = primaryButton; SecondaryButton = secondaryButton; IsDown = false; IsPressed = false; IsUp = true; IsToggled = false; }
public static bool IsAnyButtonPressed(out Buttons?pressed) { pressed = null; var t = ControllerState.Where(c => c.Any(b => b.Value == InputState.PRESSED)); if (!t.Any()) { return(false); } pressed = t.First().First(b => b.Value == InputState.PRESSED).Key; return(true); }
public GamePadEventArgs(GamePadState previousState, GamePadState currentState, TimeSpan elapsedTime, PlayerIndex playerIndex, Buttons?button = null, float triggerState = 0, Vector2?thumbStickState = null) { PlayerIndex = playerIndex; PreviousState = previousState; CurrentState = currentState; ElapsedTime = elapsedTime; if (button != null) { Button = button.Value; } TriggerState = triggerState; ThumbStickState = thumbStickState ?? Vector2.Zero; }
public static IEnumerable <(int tick, string repr)> GetUserInputs(SourceDemo demo, InputDisplayMode mode) { Buttons?prevButtons = null; int prevTick = int.MinValue; foreach (UserCmd u in demo.FilterForPacket <UserCmd>()) { Buttons?b = u.Buttons; // don't want pauses taking up all the space if (prevButtons == b && prevTick == u.Tick) { continue; } prevButtons = b; prevTick = u.Tick; yield return(mode switch { InputDisplayMode.Text => (u.Tick, b?.ToString() ?? "none"), InputDisplayMode.Int => (u.Tick, b.HasValue ? ((uint)b.Value).ToString() : "0"), InputDisplayMode.Flags => (u.Tick, Convert.ToString(b.HasValue ? (uint)b.Value : 0, 2).PadLeft(32, '0')), _ => throw new ArgProcessProgrammerException($"invalid input display mode: \"{mode}\"") });
public IInputService RegisterInput(InputAction Action, Keys?Key = null, Buttons?Button = null) { throw new NotImplementedException(); }
public void Update() { if (ControlsDisabled) { foreach (Keys key in pressedKeys.Keys.ToList()) { pressedKeys[key] = false; } foreach (Buttons button in pressedButtons.Keys.ToList()) { pressedButtons[button] = false; } prevGamepadState = null; prevKeyboardState = null; return; } currentKeyboardState = Keyboard.GetState(); mouseState = Mouse.GetState(); currentGamepadState = GamePad.GetState(PlayerIndex.One); foreach (KeyValuePair <KeyMapping, Action <Vector2> > mapping in keyPressActions) { Keys?key = mapping.Key.Key; if (key.HasValue) { if (currentKeyboardState.IsKeyDown(key.Value)) { if (Timer.IsSet("INPUTPRESSED_" + key.Value.ToString())) { continue; } if (mapping.Key.PressCooldown != 0) { Timer.SetTimer("INPUTPRESSED_" + key.Value.ToString(), mapping.Key.PressCooldown); } if (mapping.Key.SinglePressOnly && (prevKeyboardState != null && (prevKeyboardState == currentKeyboardState || pressedKeys[key.Value]))) { continue; } pressedKeys[key.Value] = true; mapping.Value.Invoke(Vector2.Zero); } else { if (pressedKeys[key.Value] && keyReleaseActions.ContainsKey(key.Value)) { keyReleaseActions[key.Value].Invoke(); } pressedKeys[key.Value] = false; } } Buttons?button = mapping.Key.Button; if (button.HasValue) { if (currentGamepadState.IsButtonDown(button.Value)) { if (mapping.Key.SinglePressOnly && (prevGamepadState != null && (prevGamepadState == currentGamepadState || pressedButtons[button.Value]))) { continue; } if (Timer.IsSet("INPUTPRESSED_" + button.Value.ToString())) { continue; } if (mapping.Key.PressCooldown != 0) { Timer.SetTimer("INPUTPRESSED_" + button.Value.ToString(), mapping.Key.PressCooldown); } pressedButtons[button.Value] = true; if (button.Value == Buttons.LeftThumbstickLeft || button.Value == Buttons.LeftThumbstickRight) { leftThumbstick.X = currentGamepadState.ThumbSticks.Left.X; mapping.Value.Invoke(leftThumbstick); } else if (button.Value == Buttons.LeftThumbstickUp || button.Value == Buttons.LeftThumbstickDown) { leftThumbstick.Y = currentGamepadState.ThumbSticks.Left.Y; mapping.Value.Invoke(leftThumbstick); } else if (button.Value == Buttons.RightThumbstickLeft || button.Value == Buttons.RightThumbstickRight) { rightThumbStick.X = currentGamepadState.ThumbSticks.Right.X; mapping.Value.Invoke(rightThumbStick); } else if (button.Value == Buttons.RightThumbstickUp || button.Value == Buttons.RightThumbstickDown) { rightThumbStick.Y = currentGamepadState.ThumbSticks.Right.Y; mapping.Value.Invoke(rightThumbStick); } else { mapping.Value.Invoke(Vector2.Zero); } } else { if (pressedButtons[button.Value] && buttonReleaseActions.ContainsKey(button.Value)) { buttonReleaseActions[button.Value].Invoke(); } pressedButtons[button.Value] = false; } } } if (mouseState.ScrollWheelValue > prevMouseScrollWheelValue) { if (mouseWheelUpAction != null && (mouseState.ScrollWheelValue - prevMouseScrollWheelValue) >= scrollThreshold) { mouseWheelUpAction.Invoke(); prevMouseScrollWheelValue = mouseState.ScrollWheelValue; } } else if (mouseState.ScrollWheelValue < prevMouseScrollWheelValue) { if (mouseWheelDownAction != null && (prevMouseScrollWheelValue - mouseState.ScrollWheelValue) >= scrollThreshold) { mouseWheelDownAction.Invoke(); prevMouseScrollWheelValue = mouseState.ScrollWheelValue; } } if (prevMouseState?.LeftButton != ButtonState.Pressed && mouseState.LeftButton == ButtonState.Pressed) { LeftClickDownAction?.Invoke(mouseState.Position.ToVector2()); } else if (prevMouseState?.LeftButton == ButtonState.Pressed && mouseState.LeftButton != ButtonState.Pressed) { LeftClickUpAction?.Invoke(mouseState.Position.ToVector2()); } if (mouseState.LeftButton == ButtonState.Pressed) { LeftClickPressedAction?.Invoke(mouseState.Position.ToVector2()); } if (prevMouseState?.RightButton != ButtonState.Pressed && mouseState.RightButton == ButtonState.Pressed) { RightClickDownAction?.Invoke(mouseState.Position.ToVector2()); } else if (prevMouseState?.RightButton == ButtonState.Pressed && mouseState.RightButton != ButtonState.Pressed) { RightClickUpAction?.Invoke(mouseState.Position.ToVector2()); } if (mouseState.RightButton == ButtonState.Pressed) { RightClickPressedAction?.Invoke(mouseState.Position.ToVector2()); } if (prevMouseState != null && prevMouseState?.Position != mouseState.Position) { MouseMovedAction?.Invoke(prevMouseState.Value.Position.ToVector2(), mouseState.Position.ToVector2()); } prevKeyboardState = currentKeyboardState; prevGamepadState = currentGamepadState; prevMouseState = mouseState; }
private void UpdateGamePads(float deltaTime) { for (int player = 0; player < MaxPlayers; player++) { PlayerIndex playerIndex = (PlayerIndex)player; //Update the current and previous states of the controllers... prevGamePadStates[player] = currGamePadStates[player]; currGamePadStates[player] = GamePad.GetState(playerIndex, inputConfiguration.AnalogDeadZone); GamePadState newGamePadState = currGamePadStates[player]; GamePadState previousGamePadState = prevGamePadStates[player]; LastButtonInfo <Buttons> lastGamePadButton = lastButtonPressed[player]; if (!newGamePadState.IsConnected) { lastGamePadButton.TimePressed = 0; } else { //Record a button if it was pressed. Buttons?pressedButton = null; foreach (Buttons button in buttons) { if (IsDown(ref newGamePadState, button) && !IsDown(ref previousGamePadState, button)) { //Found a new button press! pressedButton = button; break; } } lastGamePadButton.IsRepetitionPress = false; //If we didn't find a new button press, then figure out if we need to add a button //repetition if a button has been held... if (!pressedButton.HasValue) { //If the last button pressed is still pressed then add to the timers and consider whether or //not we have to generate a repetition press. if (IsDown(lastGamePadButton.Button, playerIndex)) { lastGamePadButton.TimePressed += deltaTime; //Generate a repetition press if the button has been pressed for long enough. if (lastGamePadButton.TimePressed >= inputConfiguration.RepetitionTimeDelay) { lastGamePadButton.IsRepetitionPress = true; lastGamePadButton.TimePressed -= inputConfiguration.RepetitionTimeInterval; } } else //Last pressed button is no longer down, just reset the timer. { lastGamePadButton.TimePressed = 0; } } else { lastGamePadButton.Button = pressedButton.Value; lastGamePadButton.TimePressed = 0; } } } }
public void Unset() { _value = null; }
public Buttons?Update(GamePadState gamepadstate, int playerNum) //returns button if button that was just pressed { Buttons?returnVal = null; setKeys(playerNum); KeyboardState kbstate = Keyboard.GetState(); newRightTrigger = gamepadstate.IsButtonDown(Buttons.RightTrigger) || kbstate.IsKeyDown(righttrigger); newStart = gamepadstate.IsButtonDown(Buttons.Start) || kbstate.IsKeyDown(start); newA = gamepadstate.IsButtonDown(Buttons.A) || kbstate.IsKeyDown(a); newB = gamepadstate.IsButtonDown(Buttons.B) || kbstate.IsKeyDown(b); newX = gamepadstate.IsButtonDown(Buttons.X) || kbstate.IsKeyDown(x); newY = gamepadstate.IsButtonDown(Buttons.Y) || kbstate.IsKeyDown(y); newLeft = gamepadstate.IsButtonDown(Buttons.DPadLeft) || kbstate.IsKeyDown(left); newRight = gamepadstate.IsButtonDown(Buttons.DPadRight) || kbstate.IsKeyDown(right); newDown = gamepadstate.IsButtonDown(Buttons.DPadDown) || kbstate.IsKeyDown(down); newUp = gamepadstate.IsButtonDown(Buttons.DPadUp) || kbstate.IsKeyDown(Up); //return buttons so combos can equal true if (newA == true && oldA == false) { returnVal = Buttons.A; } else if (newStart == true && oldStart == false) { returnVal = Buttons.Start; } else if (newRightTrigger == true && oldRightTrigger == false) { returnVal = Buttons.RightTrigger; } else if (newB == true && oldB == false) { returnVal = Buttons.B; } else if (newX == true && oldX == false) { returnVal = Buttons.X; } else if (newY == true && oldY == false) { returnVal = Buttons.Y; } else if (newLeft == true && oldLeft == false) { returnVal = Buttons.DPadLeft; } else if (newRight == true && oldRight == false) { returnVal = Buttons.DPadRight; } else if (newDown == true && oldDown == false) { returnVal = Buttons.DPadDown; } else if (newUp == true && oldUp == false) { returnVal = Buttons.DPadUp; } oldA = newA; oldB = newB; oldX = newX; oldRight = newRight; oldLeft = newLeft; oldY = newY; oldDown = newDown; oldUp = newUp; oldStart = newStart; oldRightTrigger = newRightTrigger; return(returnVal); }
protected override void Update(GameTime gameTime) { var gst1 = GamePad.GetState(PlayerIndex.One); GamePadState gst2 = GamePad.GetState(PlayerIndex.Two); //creates and loads in the character while the person is still on the title screen if (Screen.titleScreen.Bool == true) { Screen.Update(gameTime); titan = new Titan(0, 500); titan.LoadContent(Content); mystic = new Mystic(800, 500); mystic.LoadContent(Content); } else if (Screen.selectScreen.Bool == true) { Screen.Update(gameTime); titan.mana = 500; } else if (Screen.tutorialScreen.Bool == true) { Screen.Update(gameTime); titan.Update(gameTime, Lines, gst1, mystic); } else if (Screen.pauseScreen.Bool == true) { Screen.Update(gameTime); } //gives the person the option to save volume else if (Screen.settingsScreen.Bool == true) { Buttons?button = gamePadButtons.Update(gst1, 1); if (button == Buttons.DPadLeft) { MediaPlayer.Volume = MediaPlayer.Volume - .05f; saveFile(null); } if (button == Buttons.DPadRight) { MediaPlayer.Volume = MediaPlayer.Volume + .05f; } if (button == Buttons.B) { Screen.music = false; Screen.settingsScreen.Bool = false; Screen.Play = true; Screen.selectScreen.Bool = true; } } //once they leave titlescreen players update and can fight else { loadGame(); loadWins(); titan.Update(gameTime, Lines, gst1, mystic); mystic.Update(gameTime, Lines, gst2, titan); if (gst1.IsButtonDown(Buttons.Start) || gst2.IsButtonDown(Buttons.Start)) { Screen.pauseScreen.Bool = true; Screen.continuePlay = true; } } //creates a health bar that can be taken away from titan.healthRectangle = new Rectangle(0, -40, titan.health, 100); titan.manabox = new Rectangle(5, 20, (int)titan.mana, 40); mystic.healthRectangle = new Rectangle(500, -40, mystic.health, 100); mystic.manabox = new Rectangle(500, 20, (int)mystic.mana, 40); base.Update(gameTime); }
public virtual void Update(GameTime gameTime, List <Line> Lines, GamePadState gamepadstate, Character enemy) { //how the attacks do damage to the other character if (attackBox.Intersects(enemy.hitbox)) { enemy.TakeDamage(damage); } if (attackBox.Intersects(enemy.hitbox) && enemy.block == true) { enemy.BlockDamage(blockDamage); } velocity.Y += .8f; //default gravity KeyboardState ks = Keyboard.GetState(); Buttons? button = gamePadButtons.Update(gamepadstate, playerNum); //if no button is pressed then the timer will go off and the list clears if (button != null) { //reset timer combosReset.Stop(); combosReset.Start(); //puts combos to the front of the list Combos.Insert(0, (Buttons)button); //start countdown to clear combos if (Combos.Count >= 5) { Combos.RemoveAt(4); } } //cresates interaction for lines and characters for (int l = 0; l < Lines.Count; l++) { if (hitbox.Intersects(Lines[l].rectangle)) { hitbox.Y--; velocity.Y = 0; } } //makes ther character able to jump when he reaches the bottom of the screen if (hitbox.Y + hitbox.Height >= 599) { velocity.Y = 0f; Jumped = false; } SomeKeyPressed = false; if (button == (Buttons.DPadUp) && Jumped == false && canWalk == true) { animation.Update(gameTime, hitbox); if (facingRight == true) { animation.SetTexture(JumpAnimation, 0); animation.movetexture(); } else { animation.SetTexture(JumpLeft, 0); animation.movetexture(); } velocity.Y -= 19; Jumped = true; SomeKeyPressed = true; } if (button == (Buttons.DPadRight) && canWalk == true) { facingRight = true; facingLeft = false; Direction = 1; for (int i = 0; i < speed; i++) { WalkRight(gameTime); animation.movetexture(); hitbox.X++; } SomeKeyPressed = true; } if (button == (Buttons.DPadLeft) && canWalk == true) { facingLeft = true; facingRight = false; Direction = -1; for (int i = 0; i < speed; i++) { WalkLeft(gameTime); animation.movetexture(); hitbox.X--; } SomeKeyPressed = true; } //if no button is being pressed reset animation if (SomeKeyPressed == false) { if (facingRight == true) { animation.ResetFrames(RightWalk); } else { animation.ResetFrames(LeftWalk); } } animation.Update(gameTime, hitbox); hitbox.Y += (int)velocity.Y; POnScreen(); //make a text file to check varaibeles using (var stream = File.Create("Debugging_VariablesCharacter")) { } using (StreamWriter sw = new StreamWriter("Debugging_VariablesCharacter")) { sw.WriteLine("Combo reset = " + combosReset.Interval); //nf.WriteLine("block = " + block); //nf.WriteLine("can shoot = " + canshoot); //nf.WriteLine("can walk = " + canWalk); //nf.WriteLine("health = " + health); //nf.WriteLine("mana = " + mana); } }
public Control(Buttons button_) { key = null; button = button_; mouse = null; }
public Control(MouseButton mouse_) { key = null; button = null; mouse = mouse_; }
public Control(Keys key_) { key = key_; button = null; mouse = null; }
public void Update(GameTime gameTime) { titleScreen.Update(); FirstLevel.Update(); selectScreen.Update(); pauseScreen.Update(); tutorialScreen.Update(); settingsScreen.Update(); var gst1 = GamePad.GetState(PlayerIndex.One); Buttons?button = gamePadButtons.Update(gst1, 1); //makes sure combos are all set for the tutorial if (button != null) { Combos.Insert(0, (Buttons)button); } if (Combos.Count >= 5) { Combos.RemoveAt(4); } if (titleScreen.Bool == true) { if (button == Buttons.Start) { glassSound.Play(); titleScreen.Bool = false; selectScreen.Bool = true; } } //select screen lets player choose between four options , play , settings, tutorial , quit else if (selectScreen.Bool == true) { if (button == Buttons.DPadDown && Play == true) { waterSound.Play(); Tutorial = true; Play = false; } else if (button == Buttons.DPadDown && Tutorial == true) { waterSound.Play(); settings = true; Tutorial = false; } else if (button == Buttons.DPadDown && settings == true) { waterSound.Play(); settings = false; Quit = true; } else if (button == Buttons.DPadUp && Tutorial == true) { waterSound.Play(); Play = true; Tutorial = false; } else if (button == Buttons.DPadUp && Quit == true) { waterSound.Play(); settings = true; Quit = false; } else if (button == Buttons.DPadUp && settings == true) { waterSound.Play(); settings = false; Tutorial = true; } } if (Play == true) { LinePosition = new Rectangle(250, 70, 50, 50); if (button == Buttons.A) { glassSound.Play(); FirstLevel.Bool = true; selectScreen.Bool = false; tutorialScreen.Bool = false; } } else if (Tutorial == true) { LinePosition = new Rectangle(250, 205, 50, 50); if (button == Buttons.A) { glassSound.Play(); tutorialScreen.Bool = true; selectScreen.Bool = false; } } else if (settings == true) { LinePosition = new Rectangle(250, 330, 50, 50); if (button == Buttons.A) { glassSound.Play(); settingsScreen.Bool = true; selectScreen.Bool = false; music = true; } } else if (Quit == true) { LinePosition = new Rectangle(250, 470, 50, 50); if (button == Buttons.A) { glassSound.Play(); System.Environment.Exit(0); } } if (music == true) { LinePosition = new Rectangle(200, 220, 100, 100); } //goes to tutorial and runs through diffrent types of things player needs to know if (tutorialScreen.Bool == true) { if (tutorialone == true) { if (gst1.IsButtonDown(Buttons.DPadRight)) { tutorialone = false; tutorialtwo = true; } } else if (tutorialtwo == true) { if (gst1.IsButtonDown(Buttons.DPadUp)) { tutorialtwo = false; tutorialthree = true; } } else if (tutorialthree == true) { if (button == Buttons.X) { tutorialfour = true; tutorialthree = false; } } else if (tutorialfour == true) { if (button == Buttons.Y) { tutorialfour = false; tutorialfive = true; } } else if (tutorialfive == true) { try { if (comboOne[0] == Combos[0] && comboOne[1] == Combos[1] && comboOne[2] == Combos[2]) { tutorialsix = true; tutorialfive = false; } } catch (ArgumentOutOfRangeException ex) { //logging system errors var errorfile = File.Create("C:\\TemptFate\\TemptFate\\Tempt Fate\\Files\\errorTemptFateScreenManager"); errorfile.Close(); File.WriteAllText("C:\\TemptFate\\TemptFate\\Tempt Fate\\Files\\errorTemptFateScreenManager", ex.Message); } } else if (tutorialsix == true) { try { if (Shot[0] == Combos[0] && Shot[1] == Combos[1] && Shot[2] == Combos[2]) { tutorialsix = false; tutorialseven = true; } } catch (ArgumentOutOfRangeException ex) { var errorfile = File.Create("C:\\TemptFate\\TemptFate\\Tempt Fate\\Files\\errorTemptFate"); errorfile.Close(); File.WriteAllText("C:\\TemptFate\\TemptFate\\Tempt Fate\\Files\\errorTemptFate", ex.Message); } } else if (tutorialseven == true) { if (gst1.IsButtonDown(Buttons.B)) { tutorialseven = false; tutorialeight = true; } } else if (tutorialeight == true) { if (gst1.IsButtonDown(Buttons.RightTrigger)) { tutorialeight = false; tutorialdone = true; } } } if (tutorialdone == true) { selectScreen.Bool = true; tutorialdone = false; tutorialone = true; Play = true; } else if (pauseScreen.Bool == true) { if (gst1.IsButtonDown(Buttons.DPadDown)) { continuePlay = false; exit = true; } else if (gst1.IsButtonDown(Buttons.DPadUp)) { exit = false; continuePlay = true; } } if (continuePlay == true) { LinePosition = new Rectangle(200, 300, 100, 100); if (button == Buttons.A) { FirstLevel.Bool = true; pauseScreen.Bool = false; continuePlay = false; } } else if (exit == true) { LinePosition = new Rectangle(200, 450, 100, 100); if (button == Buttons.A) { glassSound.Play(); selectScreen.Bool = true; pauseScreen.Bool = false; exit = false; Play = true; } } }
public void Reset() { _value = Default; }
internal static bool HandleNavigationButtons(IGamepadControllable Instance, Buttons?PressedButtons, Rectangle?CurrentSlotPosition) { bool IsFocused = true; foreach (NavigationDirection Direction in Enum.GetValues(typeof(NavigationDirection)).Cast <NavigationDirection>()) { // Handle navigating a single slot at a time bool HandleSingleSlotNavigation; if (PressedButtons.HasValue) { HandleSingleSlotNavigation = IsMatch(PressedButtons.Value, NavigateSingleButtons[Direction]); } else { HandleSingleSlotNavigation = InputHandler.IsNavigationButtonPressed(Direction) && DateTime.Now.Subtract(InputHandler.NavigationButtonsPressedTime[Direction]).TotalMilliseconds >= Current.NavigationRepeatInitialDelay; } if (HandleSingleSlotNavigation) { NavigationWrappingMode HorizontalWrapping = NavigationWrappingMode.AllowWrapToSame; NavigationWrappingMode VerticalWrapping = NavigationWrappingMode.AllowWrapToSame; bool HasNeighbor = Instance.TryGetMenuNeighbor(Direction, out IGamepadControllable Neighbor); if (HasNeighbor) { if (Direction == NavigationDirection.Left || Direction == NavigationDirection.Right) { HorizontalWrapping = NavigationWrappingMode.NoWrap; } else { VerticalWrapping = NavigationWrappingMode.NoWrap; } } if (!Instance.TryNavigate(Direction, HorizontalWrapping, VerticalWrapping)) { // If we're unable to continue moving the cursor in the desired direction, // then focus the gamepad controls on the appropriate neighboring UI element if (HasNeighbor) { NavigationDirection StartingSide = GetOppositeDirection(Direction); if (Neighbor.TryNavigateEnter(StartingSide, CurrentSlotPosition)) { IsFocused = false; } } } } // Handle navigating across an entire UI element, or to the end of the current element's boundary if (PressedButtons.HasValue && IsMatch(PressedButtons.Value, NavigateMultipleButtons[Direction])) { bool Handled = false; // Try to change focus to the neighboring UI element in this direction bool HasNeighbor = Instance.TryGetMenuNeighbor(Direction, out IGamepadControllable Neighbor); if (HasNeighbor) { NavigationDirection StartingSide = GetOppositeDirection(Direction); if (Neighbor.TryNavigateEnter(StartingSide, CurrentSlotPosition)) { Handled = true; IsFocused = false; } } // Navigate to the end of this element's boundary if (!Handled) { while (Instance.TryNavigate(Direction, NavigationWrappingMode.NoWrap, NavigationWrappingMode.NoWrap)) { } } } } return(IsFocused); }
public Button(Buttons defaultKey, Buttons? value = null) { Default = defaultKey; _value = value; }
public InputBinding(string name, Keys?keyboardKey = null, MouseButton?mouseButton = null, Buttons?gamepadButton = null, Axis?gamepadAxis = null) { Name = name; KeyboardKeys = new(); if (keyboardKey != null) { KeyboardKeys.Add(new() { keyboardKey.Value }); } MouseButtons = new(); if (mouseButton != null) { MouseButtons.Add(mouseButton.Value); } GamepadButtons = new(); if (gamepadButton != null) { GamepadButtons.Add(gamepadButton.Value); } GamepadAxis = new(); if (gamepadAxis != null) { GamepadAxis.Add(gamepadAxis.Value); } }
public GamePadConfigurationTarget(Buttons button) : this() { Type = ConfigurationType.Button; map_button = button; }
private void UpdateGamePads(TimeSpan deltaTime) { // Same as for mouse and keyboard, except for all gamepads. for (int player = 0; player < MaxNumberOfPlayers; player++) { PlayerIndex playerIndex = (PlayerIndex)player; // ----- Update gamepad states. _previousGamePadStates[player] = _newGamePadStates[player]; _newGamePadStates[player] = GamePad.GetState(playerIndex, Settings.GamePadDeadZone); var newGamePadState = _newGamePadStates[player]; var previousGamePadState = _previousGamePadStates[player]; var lastGamePadButton = _lastGamePadButtons[player]; var isConnected = newGamePadState.IsConnected; if (GlobalSettings.PlatformID == PlatformID.WindowsPhone7 || GlobalSettings.PlatformID == PlatformID.WindowsPhone8) { // In WP7 the first gamepad is never connected but it is used for the Back button. // In MonoGame/WP8 the first gamepad is connected when the back button is down. // To detect Back double-clicks, we treat the first gamepad as connected. if (playerIndex == PlayerIndex.One) { isConnected = true; } } // ---- Reset state and skip rest of loop if this gamepad is not connected. if (!isConnected) { lastGamePadButton.IsDoubleClick = false; lastGamePadButton.DownDuration = TimeSpan.Zero; lastGamePadButton.TimeSinceLastClick = TimeSpan.MaxValue; continue; } // ----- Find pressed button. Buttons?pressedButton = null; foreach (Buttons button in _gamePadButtons) { if (IsDown(ref newGamePadState, button) && !IsDown(ref previousGamePadState, button)) { // A new button press. pressedButton = button; break; } } // ----- Handle key double clicks and key repetition. lastGamePadButton.IsDoubleClick = false; lastGamePadButton.IsVirtualPress = false; if (!pressedButton.HasValue) { // No gamepad button pressed. // Increase or reset down duration. if (IsDown(lastGamePadButton.Button, playerIndex)) { // Previously pressed gamepad button is still down. // Increase down duration. lastGamePadButton.DownDuration += deltaTime; // If the start interval is exceeded, we generate a virtual button press. if (lastGamePadButton.DownDuration >= Settings.RepetitionDelay) { // Generate virtual button press. lastGamePadButton.IsVirtualPress = true; // Subtract repetition interval from down duration. This way the repetition interval // must pass until the if condition is true again. lastGamePadButton.DownDuration -= Settings.RepetitionInterval; } } else { // Reset down duration. lastGamePadButton.DownDuration = TimeSpan.Zero; } // Measure time between clicks. if (lastGamePadButton.TimeSinceLastClick != TimeSpan.MaxValue) { lastGamePadButton.TimeSinceLastClick += deltaTime; } } else { // A key was pressed. // Check for double-click. if (pressedButton.Value == lastGamePadButton.Button && lastGamePadButton.TimeSinceLastClick < Settings.DoubleClickTime - deltaTime) { // Double-click detected. lastGamePadButton.IsDoubleClick = true; // The current click cannot be used for another double-click. lastGamePadButton.TimeSinceLastClick = TimeSpan.MaxValue; } else { // Wrong button pressed or button pressed too late. // Restart double-click logic. lastGamePadButton.TimeSinceLastClick = TimeSpan.Zero; } lastGamePadButton.Button = pressedButton.Value; lastGamePadButton.DownDuration = TimeSpan.Zero; } } }
public void Set(Buttons value) { _value = value; }