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
005// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_hids.py. DO NOT MODIFY
006
007package edu.wpi.first.wpilibj.simulation;
008
009import edu.wpi.first.wpilibj.XboxController;
010
011/** Class to control a simulated Xbox controller. */
012public class XboxControllerSim extends GenericHIDSim {
013  /**
014   * Constructs from a XboxController object.
015   *
016   * @param joystick controller to simulate
017   */
018  @SuppressWarnings("this-escape")
019  public XboxControllerSim(XboxController joystick) {
020    super(joystick);
021    setAxisCount(6);
022    setButtonCount(10);
023    setPOVCount(1);
024  }
025
026  /**
027   * Constructs from a joystick port number.
028   *
029   * @param port port number
030   */
031  @SuppressWarnings("this-escape")
032  public XboxControllerSim(int port) {
033    super(port);
034    setAxisCount(6);
035    setButtonCount(10);
036    setPOVCount(1);
037  }
038
039  /**
040   * Change the left X value of the controller's joystick.
041   *
042   * @param value the new value
043   */
044  public void setLeftX(double value) {
045    setRawAxis(XboxController.Axis.kLeftX.value, value);
046  }
047
048  /**
049   * Change the right X value of the controller's joystick.
050   *
051   * @param value the new value
052   */
053  public void setRightX(double value) {
054    setRawAxis(XboxController.Axis.kRightX.value, value);
055  }
056
057  /**
058   * Change the left Y value of the controller's joystick.
059   *
060   * @param value the new value
061   */
062  public void setLeftY(double value) {
063    setRawAxis(XboxController.Axis.kLeftY.value, value);
064  }
065
066  /**
067   * Change the right Y value of the controller's joystick.
068   *
069   * @param value the new value
070   */
071  public void setRightY(double value) {
072    setRawAxis(XboxController.Axis.kRightY.value, value);
073  }
074
075  /**
076   * Change the value of the left trigger axis on the controller.
077   *
078   * @param value the new value
079   */
080  public void setLeftTriggerAxis(double value) {
081    setRawAxis(XboxController.Axis.kLeftTrigger.value, value);
082  }
083
084  /**
085   * Change the value of the right trigger axis on the controller.
086   *
087   * @param value the new value
088   */
089  public void setRightTriggerAxis(double value) {
090    setRawAxis(XboxController.Axis.kRightTrigger.value, value);
091  }
092
093  /**
094   * Change the value of the A button on the controller.
095   *
096   * @param value the new value
097   */
098  public void setAButton(boolean value) {
099    setRawButton(XboxController.Button.kA.value, value);
100  }
101
102  /**
103   * Change the value of the B button on the controller.
104   *
105   * @param value the new value
106   */
107  public void setBButton(boolean value) {
108    setRawButton(XboxController.Button.kB.value, value);
109  }
110
111  /**
112   * Change the value of the X button on the controller.
113   *
114   * @param value the new value
115   */
116  public void setXButton(boolean value) {
117    setRawButton(XboxController.Button.kX.value, value);
118  }
119
120  /**
121   * Change the value of the Y button on the controller.
122   *
123   * @param value the new value
124   */
125  public void setYButton(boolean value) {
126    setRawButton(XboxController.Button.kY.value, value);
127  }
128
129  /**
130   * Change the value of the left bumper button on the controller.
131   *
132   * @param value the new value
133   */
134  public void setLeftBumperButton(boolean value) {
135    setRawButton(XboxController.Button.kLeftBumper.value, value);
136  }
137
138  /**
139   * Change the value of the right bumper button on the controller.
140   *
141   * @param value the new value
142   */
143  public void setRightBumperButton(boolean value) {
144    setRawButton(XboxController.Button.kRightBumper.value, value);
145  }
146
147  /**
148   * Change the value of the back button on the controller.
149   *
150   * @param value the new value
151   */
152  public void setBackButton(boolean value) {
153    setRawButton(XboxController.Button.kBack.value, value);
154  }
155
156  /**
157   * Change the value of the start button on the controller.
158   *
159   * @param value the new value
160   */
161  public void setStartButton(boolean value) {
162    setRawButton(XboxController.Button.kStart.value, value);
163  }
164
165  /**
166   * Change the value of the left stick button on the controller.
167   *
168   * @param value the new value
169   */
170  public void setLeftStickButton(boolean value) {
171    setRawButton(XboxController.Button.kLeftStick.value, value);
172  }
173
174  /**
175   * Change the value of the right stick button on the controller.
176   *
177   * @param value the new value
178   */
179  public void setRightStickButton(boolean value) {
180    setRawButton(XboxController.Button.kRightStick.value, value);
181  }
182
183  /**
184   * Change the value of the left bumper on the joystick.
185   *
186   * @param state the new value
187   * @deprecated Use {@link setLeftBumperButton} instead. This function is deprecated for removal
188   *     to make function names consistent to allow the HID classes to be automatically generated.
189   */
190  @Deprecated(since = "2025", forRemoval = true)
191  public void setLeftBumper(boolean state) {
192    setRawButton(XboxController.Button.kLeftBumper.value, state);
193  }
194
195  /**
196   * Change the value of the right bumper on the joystick.
197   *
198   * @param state the new value
199   * @deprecated Use {@link setRightBumperButton} instead. This function is deprecated for removal
200   *     to make function names consistent to allow the HID classes to be automatically generated.
201   */
202  @Deprecated(since = "2025", forRemoval = true)
203  public void setRightBumper(boolean state) {
204    setRawButton(XboxController.Button.kRightBumper.value, state);
205  }
206}