public static void MapStick(InputKeys key, ThumbStick stick, float direction, float hysteresis) { _stickMap.Add(new ThumbStickMap() { Key = key, ThumbStick = stick, Hysteresis = hysteresis, Direction = direction }); }
public XBoxCtrlGraphic() { InitializeComponent(); rightThumbstick = new ThumbStick("Right", RightStickHat, RightStickLeftPosition, RightStickTopPosition, RightStickMove); leftThumbstick = new ThumbStick("Left", LeftStickHat, LeftStickLeftPosition, LeftStickTopPosition, LeftStickMove); }
public void Update(AnalogState state, ThumbStick thumbStick, FrameDetails frame) { // Speed is pixels per second var speed = MovementConfiguration.Speed * frame.TimeDelta / 1000d; var accel = MovementConfiguration.Acceleration; double x, y; if (accel != 0d && accel != 1d) { var angle = state.Angle; var distance = Math.Pow(1d + state.Distance, accel) - 1d; x = distance * Math.Cos(angle); y = -distance *Math.Sin(angle); } else { x = state.X; y = -state.Y; } if (MovementConfiguration.InvertX) { x = -x; } if (MovementConfiguration.InvertY) { y = -y; } MovementActuator.Move(x * speed, y * speed); }
public InputAction(ThumbStick myThumbStick, ThumbStickDirection myDirection, int myPlayerIndex, bool myNewPressOnly) { thumbStick = myThumbStick; direction = myDirection; playerIndex = myPlayerIndex; newStickPressOnly = myNewPressOnly; inputType = InputType.thumbstick; }
public GamePadThumbStickCondition(string name,PlayerIndex playerIndex, ThumbStick thumbStick, Coords coordsType, Operator inputOperator, float compareValue) { Name = name; Player = playerIndex; ThumbStick = thumbStick; CoordsType = coordsType; Operator = inputOperator; CompareValue = compareValue; }
private void ThrottleChanged(ThumbStick sender, float position) { if (null != this.connectedCar) { if (true == this.AppSettings.InvertThrottle) { this.connectedCar.Throttle = -position; } else { this.connectedCar.Throttle = position; } } }
private void SteeringChanged(ThumbStick sender, float position) { if ((false == Accelerometer.IsSupported) || (false == AppSettings.UseAccelerometer)) { if (null != this.connectedCar) { if (true == this.AppSettings.InvertSteering) { this.connectedCar.Steering = -position; } else { this.connectedCar.Steering = position; } } } }
/// <summary> /// Returns a value from 0 to 1 how much a thumbstick is pressed in one direction. /// </summary> public float GetThumbStickDirection(PlayerIndex playerIndex, ThumbStick thumbStick, InputDirection direction) { Vector2 v; var result = 0f; var index = (int)playerIndex; if (thumbStick == ThumbStick.Left) { v = _currentStates[index].ThumbSticks.Left; } else { v = _currentStates[index].ThumbSticks.Right; } switch (direction) { case InputDirection.Up: result = v.Y; break; case InputDirection.Left: result = v.X * -1f; break; case InputDirection.Down: result = v.Y * -1f; break; case InputDirection.Right: result = v.X; break; } if (result < 0f) { result = 0f; } return(result); }
public void Update(AnalogState state, ThumbStick thumbStick, FrameDetails frame) { var x = Configuration.InvertX ? -state.X : state.X; var y = Configuration.InvertY ? state.Y : -state.Y; var distance = Math.Sqrt(x * x + y * y); if (distance <= Configuration.MinRadius) { memory.Clear(); distance = 0d; } else { distance = (distance - Configuration.MinRadius) / (1d - Configuration.MinRadius); } var angle = Math.Atan2(y, x); memory.Enqueue(new AngleData(angle)); var avgCos = 0d; var avgSin = 0d; foreach (var item in memory) { avgCos += item.Cos; avgSin += item.Sin; } avgCos /= memory.Count; avgSin /= memory.Count; var avgAngle = Math.Atan2(avgSin, avgCos); while (memory.Count > Configuration.Smoothing / frame.FrameTime) { memory.Dequeue(); } RadialActuator.Update((avgAngle * 180d / Math.PI + 90d) % 360d, distance); }
/// <summary> /// Returns a core assigned description of the specified thumbstick, if any is assigned. /// </summary> /// <param name="port">The port of the analog joypad.</param> /// <param name="thumbstick">The thumbstick to query.</param> /// <param name="direction">The direction to query.</param> /// <returns>If a description is assigned, the description, otherwise "".</returns> public string GetAnalogJoypadDescription(int port, ThumbStick thumbstick, ThumbStickDirection direction) { string desc = ""; inputDescriptors.TryGetValue(DeviceType.Joypad + "," + port + "," + ((int)thumbstick) + "," + ((int)direction), out desc); return desc; }
public override void _Ready() { thumbStick = (ThumbStick)GetTree().Root.FindNode("ThumbStick", true, false); }
public ScrollMapping(ThumbStick thumbStick) : base(thumbStick) { }
public WhileThumbStickPositionNotZeroEventArgs(ThumbStick thumbStick) { ThumbStick = thumbStick; }
// Use this for initialization void Start() { instance = this; Base = transform.GetComponent <SmartUI>(); Stick = transform.Find("Stick").GetComponent <SmartUI>(); }
protected AnalogBinding(ThumbStick thumbStick) { ThumbStick = thumbStick; }
public static bool IsThumbStickNewlyMoved(ThumbStick myThumbStick, ThumbStickDirection myDirection, int myPlayer) { if (newGamePads[myPlayer].IsConnected) { if (myThumbStick == ThumbStick.Left) { switch (myDirection) { case ThumbStickDirection.up: if (newGamePads[myPlayer].ThumbSticks.Left.Y > deadZone && oldGamePads[myPlayer].ThumbSticks.Left.Y < deadZone) { return true; } break; case ThumbStickDirection.down: if (newGamePads[myPlayer].ThumbSticks.Left.Y < -deadZone && oldGamePads[myPlayer].ThumbSticks.Left.Y > -deadZone) { return true; } break; case ThumbStickDirection.left: if (newGamePads[myPlayer].ThumbSticks.Left.X < -deadZone && oldGamePads[myPlayer].ThumbSticks.Left.X > -deadZone) { return true; } break; case ThumbStickDirection.right: if (newGamePads[myPlayer].ThumbSticks.Left.X > deadZone && oldGamePads[myPlayer].ThumbSticks.Left.X < deadZone) { return true; } break; } } if (myThumbStick == ThumbStick.Right) { switch (myDirection) { case ThumbStickDirection.up: if (newGamePads[myPlayer].ThumbSticks.Right.Y > deadZone && oldGamePads[myPlayer].ThumbSticks.Right.Y < deadZone) { return true; } break; case ThumbStickDirection.down: if (newGamePads[myPlayer].ThumbSticks.Right.Y < -deadZone && oldGamePads[myPlayer].ThumbSticks.Right.Y > -deadZone) { return true; } break; case ThumbStickDirection.left: if (newGamePads[myPlayer].ThumbSticks.Right.X < -deadZone && oldGamePads[myPlayer].ThumbSticks.Right.X > -deadZone) { return true; } break; case ThumbStickDirection.right: if (newGamePads[myPlayer].ThumbSticks.Right.X > deadZone && oldGamePads[myPlayer].ThumbSticks.Right.X < deadZone) { return true; } break; } } } return false; }
public GamePadThumbStickBinding(string alias, ThumbStick tStick, AnalogEvent aEvent, AnalogData aData, AnalogBindingDelegate aDel) : base(alias, aEvent, aData, aDel) { Stick = tStick; }
public MouseMapping(ThumbStick thumbStick) : base(thumbStick) { }
public ThumbStickPositionChangedEventArgs(ThumbStick thumbStick) { ThumbStick = thumbStick; }
public RadialMenuMapping(ThumbStick thumbStick) : base(thumbStick) { }
public GamePadThumbStickBinding(string alias, ThumbStick tStick, AnalogEvent aEvent, AnalogData aData) : this(alias, tStick, aEvent, aData, null) { }