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.PS4Controller; 010 011/** Class to control a simulated PS4 controller. */ 012public class PS4ControllerSim extends GenericHIDSim { 013 /** 014 * Constructs from a PS4Controller object. 015 * 016 * @param joystick controller to simulate 017 */ 018 @SuppressWarnings("this-escape") 019 public PS4ControllerSim(PS4Controller joystick) { 020 super(joystick); 021 setAxisCount(6); 022 setButtonCount(14); 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 PS4ControllerSim(int port) { 033 super(port); 034 setAxisCount(6); 035 setButtonCount(14); 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(PS4Controller.Axis.kLeftX.value, value); 046 } 047 048 /** 049 * Change the left Y value of the controller's joystick. 050 * 051 * @param value the new value 052 */ 053 public void setLeftY(double value) { 054 setRawAxis(PS4Controller.Axis.kLeftY.value, value); 055 } 056 057 /** 058 * Change the right X value of the controller's joystick. 059 * 060 * @param value the new value 061 */ 062 public void setRightX(double value) { 063 setRawAxis(PS4Controller.Axis.kRightX.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(PS4Controller.Axis.kRightY.value, value); 073 } 074 075 /** 076 * Change the value of the left trigger 2 axis on the controller. 077 * 078 * @param value the new value 079 */ 080 public void setL2Axis(double value) { 081 setRawAxis(PS4Controller.Axis.kL2.value, value); 082 } 083 084 /** 085 * Change the value of the right trigger 2 axis on the controller. 086 * 087 * @param value the new value 088 */ 089 public void setR2Axis(double value) { 090 setRawAxis(PS4Controller.Axis.kR2.value, value); 091 } 092 093 /** 094 * Change the value of the square button on the controller. 095 * 096 * @param value the new value 097 */ 098 public void setSquareButton(boolean value) { 099 setRawButton(PS4Controller.Button.kSquare.value, value); 100 } 101 102 /** 103 * Change the value of the cross button on the controller. 104 * 105 * @param value the new value 106 */ 107 public void setCrossButton(boolean value) { 108 setRawButton(PS4Controller.Button.kCross.value, value); 109 } 110 111 /** 112 * Change the value of the circle button on the controller. 113 * 114 * @param value the new value 115 */ 116 public void setCircleButton(boolean value) { 117 setRawButton(PS4Controller.Button.kCircle.value, value); 118 } 119 120 /** 121 * Change the value of the triangle button on the controller. 122 * 123 * @param value the new value 124 */ 125 public void setTriangleButton(boolean value) { 126 setRawButton(PS4Controller.Button.kTriangle.value, value); 127 } 128 129 /** 130 * Change the value of the left trigger 1 button on the controller. 131 * 132 * @param value the new value 133 */ 134 public void setL1Button(boolean value) { 135 setRawButton(PS4Controller.Button.kL1.value, value); 136 } 137 138 /** 139 * Change the value of the right trigger 1 button on the controller. 140 * 141 * @param value the new value 142 */ 143 public void setR1Button(boolean value) { 144 setRawButton(PS4Controller.Button.kR1.value, value); 145 } 146 147 /** 148 * Change the value of the left trigger 2 button on the controller. 149 * 150 * @param value the new value 151 */ 152 public void setL2Button(boolean value) { 153 setRawButton(PS4Controller.Button.kL2.value, value); 154 } 155 156 /** 157 * Change the value of the right trigger 2 button on the controller. 158 * 159 * @param value the new value 160 */ 161 public void setR2Button(boolean value) { 162 setRawButton(PS4Controller.Button.kR2.value, value); 163 } 164 165 /** 166 * Change the value of the share button on the controller. 167 * 168 * @param value the new value 169 */ 170 public void setShareButton(boolean value) { 171 setRawButton(PS4Controller.Button.kShare.value, value); 172 } 173 174 /** 175 * Change the value of the options button on the controller. 176 * 177 * @param value the new value 178 */ 179 public void setOptionsButton(boolean value) { 180 setRawButton(PS4Controller.Button.kOptions.value, value); 181 } 182 183 /** 184 * Change the value of the L3 (left stick) button on the controller. 185 * 186 * @param value the new value 187 */ 188 public void setL3Button(boolean value) { 189 setRawButton(PS4Controller.Button.kL3.value, value); 190 } 191 192 /** 193 * Change the value of the R3 (right stick) button on the controller. 194 * 195 * @param value the new value 196 */ 197 public void setR3Button(boolean value) { 198 setRawButton(PS4Controller.Button.kR3.value, value); 199 } 200 201 /** 202 * Change the value of the PlayStation button on the controller. 203 * 204 * @param value the new value 205 */ 206 public void setPSButton(boolean value) { 207 setRawButton(PS4Controller.Button.kPS.value, value); 208 } 209 210 /** 211 * Change the value of the touchpad button on the controller. 212 * 213 * @param value the new value 214 */ 215 public void setTouchpadButton(boolean value) { 216 setRawButton(PS4Controller.Button.kTouchpad.value, value); 217 } 218 219 /** 220 * Change the value of the touchpad button on the controller. 221 * 222 * @param value the new value 223 * @deprecated Use {@link setTouchpadButton} instead. This function is deprecated for removal to 224 * make function names consistent to allow the HID classes to be automatically generated. 225 */ 226 @Deprecated(since = "2025", forRemoval = true) 227 public void setTouchpad(boolean value) { 228 setRawButton(PS4Controller.Button.kTouchpad.value, value); 229 } 230}