private ChangePredicate <GamePadState> MakeTriggerRule(AnalogControl control, double moveTrigger) { switch (control) { case AnalogControl.LeftStick: return(delegate(GamePadState prev, GamePadState curr) { double xdist = curr.ThumbSticks.Left.X - prev.ThumbSticks.Left.X; double ydist = curr.ThumbSticks.Left.Y - prev.ThumbSticks.Left.Y; return xdist * xdist + ydist * ydist > moveTrigger * moveTrigger; }); case AnalogControl.RightStick: return(delegate(GamePadState prev, GamePadState curr) { double xdist = curr.ThumbSticks.Right.X - prev.ThumbSticks.Right.X; double ydist = curr.ThumbSticks.Right.Y - prev.ThumbSticks.Right.Y; return xdist * xdist + ydist * ydist > moveTrigger * moveTrigger; }); case AnalogControl.LeftTrigger: return(delegate(GamePadState prev, GamePadState curr) { return Math.Abs(curr.Triggers.Left - prev.Triggers.Left) > moveTrigger; }); case AnalogControl.RightTrigger: return(delegate(GamePadState prev, GamePadState curr) { return Math.Abs(curr.Triggers.Right - prev.Triggers.Right) > moveTrigger; }); } throw new ArgumentException(control.ToString() + " is not a valid analog control for a GamePad"); }
private GamePadAnalogState GenerateAnalogState(AnalogControl control) { switch (control) { case AnalogControl.LeftStick: return(new GamePadAnalogState(LeftThumbDirection.Magnitude, LeftThumbChange.Magnitude, LeftThumbDirection, LeftThumbChange)); case AnalogControl.RightStick: return(new GamePadAnalogState(RightThumbDirection.Magnitude, RightThumbChange.Magnitude, RightThumbDirection, RightThumbChange)); default: throw new NotImplementedException("Unsupported Controller / GamePad control for ListenAnalog: " + control.ToString()); } }
private string GetAnalogName(AnalogControl a) { return(String.Format("GamePad{0} {1}", playerIndex.ToString(), a.ToString())); }
/// <summary> /// Set the control state of a ped /// </summary> public bool SetControlState(AnalogControl control, bool state) { return(MtaClient.SetPedControlState(element, control.ToString(), state)); }
/// <summary> /// Checks wheter a ped has a certain control pressed /// </summary> public bool GetControlState(AnalogControl control) { return(MtaClient.GetPedControlState(element, control.ToString())); }
/// <summary> /// Retrieve the analog control state of a certain control /// </summary> public float GetAnalogControlState(AnalogControl control) { return(MtaClient.GetPedAnalogControlState(element, control.ToString())); }