/// <summary> /// Creates a new GamePadThumbstickEventArgs object. /// </summary> /// <param name="gameTime"></param> /// <param name="logicalIndex"></param> /// <param name="thumbstick"></param> /// <param name="position"></param> /// <param name="current"></param> public GamePadThumbstickEventArgs(TimeSpan gameTime, PlayerIndex logicalIndex, Thumbsticks thumbstick, Vector2 position, GamePadState current) : base(gameTime, logicalIndex, current) { Thumbstick = thumbstick; Position = position; PolarCoordinate polar = PolarCoordinate.FromCartesian(position); Angle = polar.Angle; Amount = polar.Distance; }
public Vector2 ThumbStickDelta(Thumbsticks Thumbstick) { if (Thumbstick == Thumbsticks.Left) { return(CurrentState.ThumbSticks.Left - LastState.ThumbSticks.Left); } else { return(CurrentState.ThumbSticks.Right - LastState.ThumbSticks.Right); } }
private GamePadThumbstickEventArgs GetGamePadThumbStickEventArgs(TimeSpan time, PlayerIndex logicalIndex, Thumbsticks stick, Vector2 position, GamePadState state) { GamePadThumbstickEventArgs _arg; if (_freeGPTEventArgs.Count == 0) { //If it doesn't exist _arg = new GamePadThumbstickEventArgs(time, logicalIndex, stick, position, state); _allGPTEventArgs.Add(_arg); return(_arg); } //If it exists _arg = _freeGPTEventArgs[_freeGPTEventArgs.Count - 1]; _freeGPTEventArgs.RemoveAt(_freeGPTEventArgs.Count - 1); _arg.Time = time; _arg.Position = position; _arg.Thumbstick = stick; _arg.LogicalIndex = logicalIndex; _arg.Current = state; return(_arg); }
public GamePadButtonState ThumbstickState(PlayerIndex pi, Thumbsticks t, ThumbstickDirection d, float val) { if (t == Thumbsticks.Left) { if (d == ThumbstickDirection.Left) { if (NewGamePadState[(int)pi].ThumbSticks.Left.X < -val) { if (OldGamePadState[(int)pi].ThumbSticks.Left.X < -val) return GamePadButtonState.Pressed; else return GamePadButtonState.JustPressed; } else { if (OldGamePadState[(int)pi].ThumbSticks.Left.X < -val) return GamePadButtonState.JustReleased; else return GamePadButtonState.Released; } } else if (d == ThumbstickDirection.Right) { if (NewGamePadState[(int)pi].ThumbSticks.Left.X > val) { if (OldGamePadState[(int)pi].ThumbSticks.Left.X > val) return GamePadButtonState.Pressed; else return GamePadButtonState.JustPressed; } else { if (OldGamePadState[(int)pi].ThumbSticks.Left.X > val) return GamePadButtonState.JustReleased; else return GamePadButtonState.Released; } } else if (d == ThumbstickDirection.Down) { if (NewGamePadState[(int)pi].ThumbSticks.Left.Y < -val) { if (OldGamePadState[(int)pi].ThumbSticks.Left.Y < -val) return GamePadButtonState.Pressed; else return GamePadButtonState.JustPressed; } else { if (OldGamePadState[(int)pi].ThumbSticks.Left.Y < -val) return GamePadButtonState.JustReleased; else return GamePadButtonState.Released; } } else { if (NewGamePadState[(int)pi].ThumbSticks.Left.Y > val) { if (OldGamePadState[(int)pi].ThumbSticks.Left.Y > val) return GamePadButtonState.Pressed; else return GamePadButtonState.JustPressed; } else { if (OldGamePadState[(int)pi].ThumbSticks.Left.Y > val) return GamePadButtonState.JustReleased; else return GamePadButtonState.Released; } } } else { if (d == ThumbstickDirection.Left) { if (NewGamePadState[(int)pi].ThumbSticks.Right.X < -val) { if (OldGamePadState[(int)pi].ThumbSticks.Right.X < -val) return GamePadButtonState.Pressed; else return GamePadButtonState.JustPressed; } else { if (OldGamePadState[(int)pi].ThumbSticks.Right.X < -val) return GamePadButtonState.JustReleased; else return GamePadButtonState.Released; } } else if (d == ThumbstickDirection.Right) { if (NewGamePadState[(int)pi].ThumbSticks.Right.X > val) { if (OldGamePadState[(int)pi].ThumbSticks.Right.X > val) return GamePadButtonState.Pressed; else return GamePadButtonState.JustPressed; } else { if (OldGamePadState[(int)pi].ThumbSticks.Right.X > val) return GamePadButtonState.JustReleased; else return GamePadButtonState.Released; } } else if (d == ThumbstickDirection.Down) { if (NewGamePadState[(int)pi].ThumbSticks.Right.Y < -val) { if (OldGamePadState[(int)pi].ThumbSticks.Right.Y < -val) return GamePadButtonState.Pressed; else return GamePadButtonState.JustPressed; } else { if (OldGamePadState[(int)pi].ThumbSticks.Right.Y < -val) return GamePadButtonState.JustReleased; else return GamePadButtonState.Released; } } else { if (NewGamePadState[(int)pi].ThumbSticks.Right.Y > val) { if (OldGamePadState[(int)pi].ThumbSticks.Right.Y > val) return GamePadButtonState.Pressed; else return GamePadButtonState.JustPressed; } else { if (OldGamePadState[(int)pi].ThumbSticks.Right.Y > val) return GamePadButtonState.JustReleased; else return GamePadButtonState.Released; } } } }
public AxisBinding DefineThumbstick(Thumbsticks thumbstick) { Thumbstick = thumbstick; return this; }
/// <summary> /// Gets a Vector of how much the specified Thumbstick is pressed /// in the x and y direction. /// </summary> /// <param name="stick"><see cref="Thumbsticks"/></param> /// <returns>A <see cref="Vector2"/> indicating the current position of the stick</returns> public Vector2 GetThumbstickState(Thumbsticks stick) => stick == Thumbsticks.Left ? GamePadState.ThumbSticks.Left : GamePadState.ThumbSticks.Right;