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 org.wpilib.simulation;
006
007import org.wpilib.driverstation.Gamepad;
008
009/** Class to control a simulated Gamepad controller. */
010public class GamepadSim extends GenericHIDSim {
011  /**
012   * Constructs from a Gamepad object.
013   *
014   * @param joystick controller to simulate
015   */
016  @SuppressWarnings("this-escape")
017  public GamepadSim(Gamepad joystick) {
018    super(joystick);
019    setAxesMaximumIndex(6);
020    setButtonsMaximumIndex(26);
021    setPOVsMaximumIndex(1);
022  }
023
024  /**
025   * Constructs from a joystick port number.
026   *
027   * @param port port number
028   */
029  @SuppressWarnings("this-escape")
030  public GamepadSim(int port) {
031    super(port);
032    setAxesMaximumIndex(6);
033    setButtonsMaximumIndex(26);
034    setPOVsMaximumIndex(1);
035  }
036
037  /**
038   * Change the left X value of the controller's joystick.
039   *
040   * @param value the new value
041   */
042  public void setLeftX(double value) {
043    setRawAxis(Gamepad.Axis.kLeftX.value, value);
044  }
045
046  /**
047   * Change the left Y value of the controller's joystick.
048   *
049   * @param value the new value
050   */
051  public void setLeftY(double value) {
052    setRawAxis(Gamepad.Axis.kLeftY.value, value);
053  }
054
055  /**
056   * Change the right X value of the controller's joystick.
057   *
058   * @param value the new value
059   */
060  public void setRightX(double value) {
061    setRawAxis(Gamepad.Axis.kRightX.value, value);
062  }
063
064  /**
065   * Change the right Y value of the controller's joystick.
066   *
067   * @param value the new value
068   */
069  public void setRightY(double value) {
070    setRawAxis(Gamepad.Axis.kRightY.value, value);
071  }
072
073  /**
074   * Change the value of the left trigger axis on the controller.
075   *
076   * @param value the new value
077   */
078  public void setLeftTriggerAxis(double value) {
079    setRawAxis(Gamepad.Axis.kLeftTrigger.value, value);
080  }
081
082  /**
083   * Change the value of the right trigger axis on the controller.
084   *
085   * @param value the new value
086   */
087  public void setRightTriggerAxis(double value) {
088    setRawAxis(Gamepad.Axis.kRightTrigger.value, value);
089  }
090
091  /**
092   * Change the value of the South Face button on the controller.
093   *
094   * @param value the new value
095   */
096  public void setSouthFaceButton(boolean value) {
097    setRawButton(Gamepad.Button.kSouthFace.value, value);
098  }
099
100  /**
101   * Change the value of the East Face button on the controller.
102   *
103   * @param value the new value
104   */
105  public void setEastFaceButton(boolean value) {
106    setRawButton(Gamepad.Button.kEastFace.value, value);
107  }
108
109  /**
110   * Change the value of the West Face button on the controller.
111   *
112   * @param value the new value
113   */
114  public void setWestFaceButton(boolean value) {
115    setRawButton(Gamepad.Button.kWestFace.value, value);
116  }
117
118  /**
119   * Change the value of the North Face button on the controller.
120   *
121   * @param value the new value
122   */
123  public void setNorthFaceButton(boolean value) {
124    setRawButton(Gamepad.Button.kNorthFace.value, value);
125  }
126
127  /**
128   * Change the value of the Back button on the controller.
129   *
130   * @param value the new value
131   */
132  public void setBackButton(boolean value) {
133    setRawButton(Gamepad.Button.kBack.value, value);
134  }
135
136  /**
137   * Change the value of the Guide button on the controller.
138   *
139   * @param value the new value
140   */
141  public void setGuideButton(boolean value) {
142    setRawButton(Gamepad.Button.kGuide.value, value);
143  }
144
145  /**
146   * Change the value of the Start button on the controller.
147   *
148   * @param value the new value
149   */
150  public void setStartButton(boolean value) {
151    setRawButton(Gamepad.Button.kStart.value, value);
152  }
153
154  /**
155   * Change the value of the left stick button on the controller.
156   *
157   * @param value the new value
158   */
159  public void setLeftStickButton(boolean value) {
160    setRawButton(Gamepad.Button.kLeftStick.value, value);
161  }
162
163  /**
164   * Change the value of the right stick button on the controller.
165   *
166   * @param value the new value
167   */
168  public void setRightStickButton(boolean value) {
169    setRawButton(Gamepad.Button.kRightStick.value, value);
170  }
171
172  /**
173   * Change the value of the right bumper button on the controller.
174   *
175   * @param value the new value
176   */
177  public void setLeftBumperButton(boolean value) {
178    setRawButton(Gamepad.Button.kLeftBumper.value, value);
179  }
180
181  /**
182   * Change the value of the right bumper button on the controller.
183   *
184   * @param value the new value
185   */
186  public void setRightBumperButton(boolean value) {
187    setRawButton(Gamepad.Button.kRightBumper.value, value);
188  }
189
190  /**
191   * Change the value of the D-pad up button on the controller.
192   *
193   * @param value the new value
194   */
195  public void setDpadUpButton(boolean value) {
196    setRawButton(Gamepad.Button.kDpadUp.value, value);
197  }
198
199  /**
200   * Change the value of the D-pad down button on the controller.
201   *
202   * @param value the new value
203   */
204  public void setDpadDownButton(boolean value) {
205    setRawButton(Gamepad.Button.kDpadDown.value, value);
206  }
207
208  /**
209   * Change the value of the D-pad left button on the controller.
210   *
211   * @param value the new value
212   */
213  public void setDpadLeftButton(boolean value) {
214    setRawButton(Gamepad.Button.kDpadLeft.value, value);
215  }
216
217  /**
218   * Change the value of the D-pad right button on the controller.
219   *
220   * @param value the new value
221   */
222  public void setDpadRightButton(boolean value) {
223    setRawButton(Gamepad.Button.kDpadRight.value, value);
224  }
225
226  /**
227   * Change the value of the Miscellaneous 1 button on the controller.
228   *
229   * @param value the new value
230   */
231  public void setMisc1Button(boolean value) {
232    setRawButton(Gamepad.Button.kMisc1.value, value);
233  }
234
235  /**
236   * Change the value of the Right Paddle 1 button on the controller.
237   *
238   * @param value the new value
239   */
240  public void setRightPaddle1Button(boolean value) {
241    setRawButton(Gamepad.Button.kRightPaddle1.value, value);
242  }
243
244  /**
245   * Change the value of the Left Paddle 1 button on the controller.
246   *
247   * @param value the new value
248   */
249  public void setLeftPaddle1Button(boolean value) {
250    setRawButton(Gamepad.Button.kLeftPaddle1.value, value);
251  }
252
253  /**
254   * Change the value of the Right Paddle 2 button on the controller.
255   *
256   * @param value the new value
257   */
258  public void setRightPaddle2Button(boolean value) {
259    setRawButton(Gamepad.Button.kRightPaddle2.value, value);
260  }
261
262  /**
263   * Change the value of the Left Paddle 2 button on the controller.
264   *
265   * @param value the new value
266   */
267  public void setLeftPaddle2Button(boolean value) {
268    setRawButton(Gamepad.Button.kLeftPaddle2.value, value);
269  }
270
271  /**
272   * Change the value of the Touchpad button on the controller.
273   *
274   * @param value the new value
275   */
276  public void setTouchpadButton(boolean value) {
277    setRawButton(Gamepad.Button.kTouchpad.value, value);
278  }
279
280  /**
281   * Change the value of the Miscellaneous 2 button on the controller.
282   *
283   * @param value the new value
284   */
285  public void setMisc2Button(boolean value) {
286    setRawButton(Gamepad.Button.kMisc2.value, value);
287  }
288
289  /**
290   * Change the value of the Miscellaneous 3 button on the controller.
291   *
292   * @param value the new value
293   */
294  public void setMisc3Button(boolean value) {
295    setRawButton(Gamepad.Button.kMisc3.value, value);
296  }
297
298  /**
299   * Change the value of the Miscellaneous 4 button on the controller.
300   *
301   * @param value the new value
302   */
303  public void setMisc4Button(boolean value) {
304    setRawButton(Gamepad.Button.kMisc4.value, value);
305  }
306
307  /**
308   * Change the value of the Miscellaneous 5 button on the controller.
309   *
310   * @param value the new value
311   */
312  public void setMisc5Button(boolean value) {
313    setRawButton(Gamepad.Button.kMisc5.value, value);
314  }
315
316  /**
317   * Change the value of the Miscellaneous 6 button on the controller.
318   *
319   * @param value the new value
320   */
321  public void setMisc6Button(boolean value) {
322    setRawButton(Gamepad.Button.kMisc6.value, value);
323  }
324}