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 ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
006
007package edu.wpi.first.wpilibj2.command.button;
008
009import edu.wpi.first.wpilibj.PS5Controller;
010import edu.wpi.first.wpilibj.event.EventLoop;
011import edu.wpi.first.wpilibj2.command.CommandScheduler;
012
013/**
014 * A version of {@link PS5Controller} with {@link Trigger} factories for command-based.
015 *
016 * @see PS5Controller
017 */
018@SuppressWarnings("MethodName")
019public class CommandPS5Controller extends CommandGenericHID {
020  private final PS5Controller m_hid;
021
022  /**
023   * Construct an instance of a controller.
024   *
025   * @param port The port index on the Driver Station that the controller is plugged into.
026   */
027  public CommandPS5Controller(int port) {
028    super(port);
029    m_hid = new PS5Controller(port);
030  }
031
032  /**
033   * Get the underlying GenericHID object.
034   *
035   * @return the wrapped GenericHID object
036   */
037  @Override
038  public PS5Controller getHID() {
039    return m_hid;
040  }
041
042  /**
043   * Constructs a Trigger instance around the square button's digital signal.
044   *
045   * @return a Trigger instance representing the square button's digital signal attached
046   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
047   * @see #square(EventLoop)
048   */
049  public Trigger square() {
050    return square(CommandScheduler.getInstance().getDefaultButtonLoop());
051  }
052
053  /**
054   * Constructs a Trigger instance around the square button's digital signal.
055   *
056   * @param loop the event loop instance to attach the event to.
057   * @return a Trigger instance representing the square button's digital signal attached
058   *     to the given loop.
059   */
060  public Trigger square(EventLoop loop) {
061    return button(PS5Controller.Button.kSquare.value, loop);
062  }
063
064  /**
065   * Constructs a Trigger instance around the cross button's digital signal.
066   *
067   * @return a Trigger instance representing the cross button's digital signal attached
068   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
069   * @see #cross(EventLoop)
070   */
071  public Trigger cross() {
072    return cross(CommandScheduler.getInstance().getDefaultButtonLoop());
073  }
074
075  /**
076   * Constructs a Trigger instance around the cross button's digital signal.
077   *
078   * @param loop the event loop instance to attach the event to.
079   * @return a Trigger instance representing the cross button's digital signal attached
080   *     to the given loop.
081   */
082  public Trigger cross(EventLoop loop) {
083    return button(PS5Controller.Button.kCross.value, loop);
084  }
085
086  /**
087   * Constructs a Trigger instance around the circle button's digital signal.
088   *
089   * @return a Trigger instance representing the circle button's digital signal attached
090   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
091   * @see #circle(EventLoop)
092   */
093  public Trigger circle() {
094    return circle(CommandScheduler.getInstance().getDefaultButtonLoop());
095  }
096
097  /**
098   * Constructs a Trigger instance around the circle button's digital signal.
099   *
100   * @param loop the event loop instance to attach the event to.
101   * @return a Trigger instance representing the circle button's digital signal attached
102   *     to the given loop.
103   */
104  public Trigger circle(EventLoop loop) {
105    return button(PS5Controller.Button.kCircle.value, loop);
106  }
107
108  /**
109   * Constructs a Trigger instance around the triangle button's digital signal.
110   *
111   * @return a Trigger instance representing the triangle button's digital signal attached
112   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
113   * @see #triangle(EventLoop)
114   */
115  public Trigger triangle() {
116    return triangle(CommandScheduler.getInstance().getDefaultButtonLoop());
117  }
118
119  /**
120   * Constructs a Trigger instance around the triangle button's digital signal.
121   *
122   * @param loop the event loop instance to attach the event to.
123   * @return a Trigger instance representing the triangle button's digital signal attached
124   *     to the given loop.
125   */
126  public Trigger triangle(EventLoop loop) {
127    return button(PS5Controller.Button.kTriangle.value, loop);
128  }
129
130  /**
131   * Constructs a Trigger instance around the left trigger 1 button's digital signal.
132   *
133   * @return a Trigger instance representing the left trigger 1 button's digital signal attached
134   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
135   * @see #L1(EventLoop)
136   */
137  public Trigger L1() {
138    return L1(CommandScheduler.getInstance().getDefaultButtonLoop());
139  }
140
141  /**
142   * Constructs a Trigger instance around the left trigger 1 button's digital signal.
143   *
144   * @param loop the event loop instance to attach the event to.
145   * @return a Trigger instance representing the left trigger 1 button's digital signal attached
146   *     to the given loop.
147   */
148  public Trigger L1(EventLoop loop) {
149    return button(PS5Controller.Button.kL1.value, loop);
150  }
151
152  /**
153   * Constructs a Trigger instance around the right trigger 1 button's digital signal.
154   *
155   * @return a Trigger instance representing the right trigger 1 button's digital signal attached
156   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
157   * @see #R1(EventLoop)
158   */
159  public Trigger R1() {
160    return R1(CommandScheduler.getInstance().getDefaultButtonLoop());
161  }
162
163  /**
164   * Constructs a Trigger instance around the right trigger 1 button's digital signal.
165   *
166   * @param loop the event loop instance to attach the event to.
167   * @return a Trigger instance representing the right trigger 1 button's digital signal attached
168   *     to the given loop.
169   */
170  public Trigger R1(EventLoop loop) {
171    return button(PS5Controller.Button.kR1.value, loop);
172  }
173
174  /**
175   * Constructs a Trigger instance around the left trigger 2 button's digital signal.
176   *
177   * @return a Trigger instance representing the left trigger 2 button's digital signal attached
178   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
179   * @see #L2(EventLoop)
180   */
181  public Trigger L2() {
182    return L2(CommandScheduler.getInstance().getDefaultButtonLoop());
183  }
184
185  /**
186   * Constructs a Trigger instance around the left trigger 2 button's digital signal.
187   *
188   * @param loop the event loop instance to attach the event to.
189   * @return a Trigger instance representing the left trigger 2 button's digital signal attached
190   *     to the given loop.
191   */
192  public Trigger L2(EventLoop loop) {
193    return button(PS5Controller.Button.kL2.value, loop);
194  }
195
196  /**
197   * Constructs a Trigger instance around the right trigger 2 button's digital signal.
198   *
199   * @return a Trigger instance representing the right trigger 2 button's digital signal attached
200   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
201   * @see #R2(EventLoop)
202   */
203  public Trigger R2() {
204    return R2(CommandScheduler.getInstance().getDefaultButtonLoop());
205  }
206
207  /**
208   * Constructs a Trigger instance around the right trigger 2 button's digital signal.
209   *
210   * @param loop the event loop instance to attach the event to.
211   * @return a Trigger instance representing the right trigger 2 button's digital signal attached
212   *     to the given loop.
213   */
214  public Trigger R2(EventLoop loop) {
215    return button(PS5Controller.Button.kR2.value, loop);
216  }
217
218  /**
219   * Constructs a Trigger instance around the create button's digital signal.
220   *
221   * @return a Trigger instance representing the create button's digital signal attached
222   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
223   * @see #create(EventLoop)
224   */
225  public Trigger create() {
226    return create(CommandScheduler.getInstance().getDefaultButtonLoop());
227  }
228
229  /**
230   * Constructs a Trigger instance around the create button's digital signal.
231   *
232   * @param loop the event loop instance to attach the event to.
233   * @return a Trigger instance representing the create button's digital signal attached
234   *     to the given loop.
235   */
236  public Trigger create(EventLoop loop) {
237    return button(PS5Controller.Button.kCreate.value, loop);
238  }
239
240  /**
241   * Constructs a Trigger instance around the options button's digital signal.
242   *
243   * @return a Trigger instance representing the options button's digital signal attached
244   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
245   * @see #options(EventLoop)
246   */
247  public Trigger options() {
248    return options(CommandScheduler.getInstance().getDefaultButtonLoop());
249  }
250
251  /**
252   * Constructs a Trigger instance around the options button's digital signal.
253   *
254   * @param loop the event loop instance to attach the event to.
255   * @return a Trigger instance representing the options button's digital signal attached
256   *     to the given loop.
257   */
258  public Trigger options(EventLoop loop) {
259    return button(PS5Controller.Button.kOptions.value, loop);
260  }
261
262  /**
263   * Constructs a Trigger instance around the L3 (left stick) button's digital signal.
264   *
265   * @return a Trigger instance representing the L3 (left stick) button's digital signal attached
266   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
267   * @see #L3(EventLoop)
268   */
269  public Trigger L3() {
270    return L3(CommandScheduler.getInstance().getDefaultButtonLoop());
271  }
272
273  /**
274   * Constructs a Trigger instance around the L3 (left stick) button's digital signal.
275   *
276   * @param loop the event loop instance to attach the event to.
277   * @return a Trigger instance representing the L3 (left stick) button's digital signal attached
278   *     to the given loop.
279   */
280  public Trigger L3(EventLoop loop) {
281    return button(PS5Controller.Button.kL3.value, loop);
282  }
283
284  /**
285   * Constructs a Trigger instance around the R3 (right stick) button's digital signal.
286   *
287   * @return a Trigger instance representing the R3 (right stick) button's digital signal attached
288   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
289   * @see #R3(EventLoop)
290   */
291  public Trigger R3() {
292    return R3(CommandScheduler.getInstance().getDefaultButtonLoop());
293  }
294
295  /**
296   * Constructs a Trigger instance around the R3 (right stick) button's digital signal.
297   *
298   * @param loop the event loop instance to attach the event to.
299   * @return a Trigger instance representing the R3 (right stick) button's digital signal attached
300   *     to the given loop.
301   */
302  public Trigger R3(EventLoop loop) {
303    return button(PS5Controller.Button.kR3.value, loop);
304  }
305
306  /**
307   * Constructs a Trigger instance around the PlayStation button's digital signal.
308   *
309   * @return a Trigger instance representing the PlayStation button's digital signal attached
310   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
311   * @see #PS(EventLoop)
312   */
313  public Trigger PS() {
314    return PS(CommandScheduler.getInstance().getDefaultButtonLoop());
315  }
316
317  /**
318   * Constructs a Trigger instance around the PlayStation button's digital signal.
319   *
320   * @param loop the event loop instance to attach the event to.
321   * @return a Trigger instance representing the PlayStation button's digital signal attached
322   *     to the given loop.
323   */
324  public Trigger PS(EventLoop loop) {
325    return button(PS5Controller.Button.kPS.value, loop);
326  }
327
328  /**
329   * Constructs a Trigger instance around the touchpad button's digital signal.
330   *
331   * @return a Trigger instance representing the touchpad button's digital signal attached
332   *     to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
333   * @see #touchpad(EventLoop)
334   */
335  public Trigger touchpad() {
336    return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop());
337  }
338
339  /**
340   * Constructs a Trigger instance around the touchpad button's digital signal.
341   *
342   * @param loop the event loop instance to attach the event to.
343   * @return a Trigger instance representing the touchpad button's digital signal attached
344   *     to the given loop.
345   */
346  public Trigger touchpad(EventLoop loop) {
347    return button(PS5Controller.Button.kTouchpad.value, loop);
348  }
349
350  /**
351   * Get the X axis value of left side of the controller.
352   *
353   * @return The axis value.
354   */
355  public double getLeftX() {
356    return m_hid.getLeftX();
357  }
358
359  /**
360   * Get the Y axis value of left side of the controller.
361   *
362   * @return The axis value.
363   */
364  public double getLeftY() {
365    return m_hid.getLeftY();
366  }
367
368  /**
369   * Get the X axis value of right side of the controller.
370   *
371   * @return The axis value.
372   */
373  public double getRightX() {
374    return m_hid.getRightX();
375  }
376
377  /**
378   * Get the Y axis value of right side of the controller.
379   *
380   * @return The axis value.
381   */
382  public double getRightY() {
383    return m_hid.getRightY();
384  }
385
386  /**
387   * Get the left trigger 2 axis value of the controller. Note that this axis is bound to the
388   * range of [0, 1] as opposed to the usual [-1, 1].
389   *
390   * @return The axis value.
391   */
392  public double getL2Axis() {
393    return m_hid.getL2Axis();
394  }
395
396  /**
397   * Get the right trigger 2 axis value of the controller. Note that this axis is bound to the
398   * range of [0, 1] as opposed to the usual [-1, 1].
399   *
400   * @return The axis value.
401   */
402  public double getR2Axis() {
403    return m_hid.getR2Axis();
404  }
405}