001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj.simulation;
006
007import edu.wpi.first.wpilibj.PS4Controller;
008
009/** Class to control a simulated PS4 controller. */
010public class PS4ControllerSim extends GenericHIDSim {
011  /**
012   * Constructs from a PS4Controller object.
013   *
014   * @param joystick controller to simulate
015   */
016  public PS4ControllerSim(PS4Controller joystick) {
017    super(joystick);
018    setAxisCount(6);
019    setButtonCount(14);
020  }
021
022  /**
023   * Constructs from a joystick port number.
024   *
025   * @param port port number
026   */
027  public PS4ControllerSim(int port) {
028    super(port);
029    setAxisCount(6);
030    setButtonCount(14);
031  }
032
033  /**
034   * Change the X axis value of the controller's left stick.
035   *
036   * @param value the new value
037   */
038  public void setLeftX(double value) {
039    setRawAxis(PS4Controller.Axis.kLeftX.value, value);
040  }
041
042  /**
043   * Change the X axis value of the controller's right stick.
044   *
045   * @param value the new value
046   */
047  public void setRightX(double value) {
048    setRawAxis(PS4Controller.Axis.kRightX.value, value);
049  }
050
051  /**
052   * Change the Y axis value of the controller's left stick.
053   *
054   * @param value the new value
055   */
056  public void setLeftY(double value) {
057    setRawAxis(PS4Controller.Axis.kLeftY.value, value);
058  }
059
060  /**
061   * Change the Y axis value of the controller's right stick.
062   *
063   * @param value the new value
064   */
065  public void setRightY(double value) {
066    setRawAxis(PS4Controller.Axis.kRightY.value, value);
067  }
068
069  /**
070   * Change the L2 axis axis value of the controller.
071   *
072   * @param value the new value
073   */
074  public void setL2Axis(double value) {
075    setRawAxis(PS4Controller.Axis.kL2.value, value);
076  }
077
078  /**
079   * Change the R2 axis value of the controller.
080   *
081   * @param value the new value
082   */
083  public void setR2Axis(double value) {
084    setRawAxis(PS4Controller.Axis.kR2.value, value);
085  }
086
087  /**
088   * Change the value of the Square button on the controller.
089   *
090   * @param value the new value
091   */
092  public void setSquareButton(boolean value) {
093    setRawButton(PS4Controller.Button.kSquare.value, value);
094  }
095
096  /**
097   * Change the value of the Cross button on the controller.
098   *
099   * @param value the new value
100   */
101  public void setCrossButton(boolean value) {
102    setRawButton(PS4Controller.Button.kCross.value, value);
103  }
104
105  /**
106   * Change the value of the Circle button on the controller.
107   *
108   * @param value the new value
109   */
110  public void setCircleButton(boolean value) {
111    setRawButton(PS4Controller.Button.kCircle.value, value);
112  }
113
114  /**
115   * Change the value of the Triangle button on the controller.
116   *
117   * @param value the new value
118   */
119  public void setTriangleButton(boolean value) {
120    setRawButton(PS4Controller.Button.kTriangle.value, value);
121  }
122
123  /**
124   * Change the value of the L1 button on the controller.
125   *
126   * @param value the new value
127   */
128  public void setL1Button(boolean value) {
129    setRawButton(PS4Controller.Button.kL1.value, value);
130  }
131
132  /**
133   * Change the value of the R1 button on the controller.
134   *
135   * @param value the new value
136   */
137  public void setR1Button(boolean value) {
138    setRawButton(PS4Controller.Button.kR1.value, value);
139  }
140
141  /**
142   * Change the value of the L2 button on the controller.
143   *
144   * @param value the new value
145   */
146  public void setL2Button(boolean value) {
147    setRawButton(PS4Controller.Button.kL2.value, value);
148  }
149
150  /**
151   * Change the value of the R2 button on the controller.
152   *
153   * @param value the new value
154   */
155  public void setR2Button(boolean value) {
156    setRawButton(PS4Controller.Button.kR2.value, value);
157  }
158
159  /**
160   * Change the value of the Share button on the controller.
161   *
162   * @param value the new value
163   */
164  public void setShareButton(boolean value) {
165    setRawButton(PS4Controller.Button.kShare.value, value);
166  }
167
168  /**
169   * Change the value of the Options button on the controller.
170   *
171   * @param value the new value
172   */
173  public void setOptionsButton(boolean value) {
174    setRawButton(PS4Controller.Button.kOptions.value, value);
175  }
176
177  /**
178   * Change the value of the L3 (left stick) button on the controller.
179   *
180   * @param value the new value
181   */
182  public void setL3Button(boolean value) {
183    setRawButton(PS4Controller.Button.kL3.value, value);
184  }
185
186  /**
187   * Change the value of the R3 (right stick) button on the controller.
188   *
189   * @param value the new value
190   */
191  public void setR3Button(boolean value) {
192    setRawButton(PS4Controller.Button.kR3.value, value);
193  }
194
195  /**
196   * Change the value of the PS button on the controller.
197   *
198   * @param value the new value
199   */
200  public void setPSButton(boolean value) {
201    setRawButton(PS4Controller.Button.kPS.value, value);
202  }
203
204  /**
205   * Change the value of the touchpad button on the controller.
206   *
207   * @param value the new value
208   */
209  public void setTouchpad(boolean value) {
210    setRawButton(PS4Controller.Button.kTouchpad.value, value);
211  }
212}