WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
CommandPS4Controller.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY
6
7#pragma once
8#include <frc/PS4Controller.h>
9
13
14namespace frc2 {
15/**
16 * A version of {@link frc::PS4Controller} with {@link Trigger} factories for
17 * command-based.
18 *
19 * @see frc::PS4Controller
20 */
22 public:
23 /**
24 * Construct an instance of a controller.
25 *
26 * @param port The port index on the Driver Station that the controller is
27 * plugged into.
28 */
29 explicit CommandPS4Controller(int port);
30
31 /**
32 * Get the underlying GenericHID object.
33 *
34 * @return the wrapped GenericHID object
35 */
37
38 /**
39 * Constructs a Trigger instance around the square button's
40 * digital signal.
41 *
42 * @param loop the event loop instance to attach the event to. Defaults to the
43 * CommandScheduler's default loop.
44 * @return a Trigger instance representing the square button's
45 * digital signal attached to the given loop.
46 */
48 .GetDefaultButtonLoop()) const;
49
50 /**
51 * Constructs a Trigger instance around the cross button's
52 * digital signal.
53 *
54 * @param loop the event loop instance to attach the event to. Defaults to the
55 * CommandScheduler's default loop.
56 * @return a Trigger instance representing the cross button's
57 * digital signal attached to the given loop.
58 */
60 .GetDefaultButtonLoop()) const;
61
62 /**
63 * Constructs a Trigger instance around the circle button's
64 * digital signal.
65 *
66 * @param loop the event loop instance to attach the event to. Defaults to the
67 * CommandScheduler's default loop.
68 * @return a Trigger instance representing the circle button's
69 * digital signal attached to the given loop.
70 */
72 .GetDefaultButtonLoop()) const;
73
74 /**
75 * Constructs a Trigger instance around the triangle button's
76 * digital signal.
77 *
78 * @param loop the event loop instance to attach the event to. Defaults to the
79 * CommandScheduler's default loop.
80 * @return a Trigger instance representing the triangle button's
81 * digital signal attached to the given loop.
82 */
84 .GetDefaultButtonLoop()) const;
85
86 /**
87 * Constructs a Trigger instance around the left trigger 1 button's
88 * digital signal.
89 *
90 * @param loop the event loop instance to attach the event to. Defaults to the
91 * CommandScheduler's default loop.
92 * @return a Trigger instance representing the left trigger 1 button's
93 * digital signal attached to the given loop.
94 */
96 .GetDefaultButtonLoop()) const;
97
98 /**
99 * Constructs a Trigger instance around the right trigger 1 button's
100 * digital signal.
101 *
102 * @param loop the event loop instance to attach the event to. Defaults to the
103 * CommandScheduler's default loop.
104 * @return a Trigger instance representing the right trigger 1 button's
105 * digital signal attached to the given loop.
106 */
108 .GetDefaultButtonLoop()) const;
109
110 /**
111 * Constructs a Trigger instance around the left trigger 2 button's
112 * digital signal.
113 *
114 * @param loop the event loop instance to attach the event to. Defaults to the
115 * CommandScheduler's default loop.
116 * @return a Trigger instance representing the left trigger 2 button's
117 * digital signal attached to the given loop.
118 */
120 .GetDefaultButtonLoop()) const;
121
122 /**
123 * Constructs a Trigger instance around the right trigger 2 button's
124 * digital signal.
125 *
126 * @param loop the event loop instance to attach the event to. Defaults to the
127 * CommandScheduler's default loop.
128 * @return a Trigger instance representing the right trigger 2 button's
129 * digital signal attached to the given loop.
130 */
132 .GetDefaultButtonLoop()) const;
133
134 /**
135 * Constructs a Trigger instance around the share button's
136 * digital signal.
137 *
138 * @param loop the event loop instance to attach the event to. Defaults to the
139 * CommandScheduler's default loop.
140 * @return a Trigger instance representing the share button's
141 * digital signal attached to the given loop.
142 */
144 .GetDefaultButtonLoop()) const;
145
146 /**
147 * Constructs a Trigger instance around the options button's
148 * digital signal.
149 *
150 * @param loop the event loop instance to attach the event to. Defaults to the
151 * CommandScheduler's default loop.
152 * @return a Trigger instance representing the options button's
153 * digital signal attached to the given loop.
154 */
156 .GetDefaultButtonLoop()) const;
157
158 /**
159 * Constructs a Trigger instance around the L3 (left stick) button's
160 * digital signal.
161 *
162 * @param loop the event loop instance to attach the event to. Defaults to the
163 * CommandScheduler's default loop.
164 * @return a Trigger instance representing the L3 (left stick) button's
165 * digital signal attached to the given loop.
166 */
168 .GetDefaultButtonLoop()) const;
169
170 /**
171 * Constructs a Trigger instance around the R3 (right stick) button's
172 * digital signal.
173 *
174 * @param loop the event loop instance to attach the event to. Defaults to the
175 * CommandScheduler's default loop.
176 * @return a Trigger instance representing the R3 (right stick) button's
177 * digital signal attached to the given loop.
178 */
180 .GetDefaultButtonLoop()) const;
181
182 /**
183 * Constructs a Trigger instance around the PlayStation button's
184 * digital signal.
185 *
186 * @param loop the event loop instance to attach the event to. Defaults to the
187 * CommandScheduler's default loop.
188 * @return a Trigger instance representing the PlayStation button's
189 * digital signal attached to the given loop.
190 */
192 .GetDefaultButtonLoop()) const;
193
194 /**
195 * Constructs a Trigger instance around the touchpad button's
196 * digital signal.
197 *
198 * @param loop the event loop instance to attach the event to. Defaults to the
199 * CommandScheduler's default loop.
200 * @return a Trigger instance representing the touchpad button's
201 * digital signal attached to the given loop.
202 */
204 .GetDefaultButtonLoop()) const;
205
206 /**
207 * Get the X axis value of left side of the controller.
208 *
209 * @return The axis value.
210 */
211 double GetLeftX() const;
212
213 /**
214 * Get the Y axis value of left side of the controller.
215 *
216 * @return The axis value.
217 */
218 double GetLeftY() const;
219
220 /**
221 * Get the X axis value of right side of the controller.
222 *
223 * @return The axis value.
224 */
225 double GetRightX() const;
226
227 /**
228 * Get the Y axis value of right side of the controller.
229 *
230 * @return The axis value.
231 */
232 double GetRightY() const;
233
234 /**
235 * Get the left trigger 2 axis value of the controller. Note that this axis is bound
236 * to the range of [0, 1] as opposed to the usual [-1, 1].
237 *
238 * @return The axis value.
239 */
240 double GetL2Axis() const;
241
242 /**
243 * Get the right trigger 2 axis value of the controller. Note that this axis is bound
244 * to the range of [0, 1] as opposed to the usual [-1, 1].
245 *
246 * @return The axis value.
247 */
248 double GetR2Axis() const;
249
250 private:
251 frc::PS4Controller m_hid;
252};
253} // namespace frc2
A version of frc::GenericHID with Trigger factories for command-based.
Definition CommandGenericHID.h:19
A version of frc::PS4Controller with Trigger factories for command-based.
Definition CommandPS4Controller.h:21
double GetL2Axis() const
Get the left trigger 2 axis value of the controller.
frc::PS4Controller & GetHID()
Get the underlying GenericHID object.
double GetR2Axis() const
Get the right trigger 2 axis value of the controller.
double GetRightX() const
Get the X axis value of right side of the controller.
Trigger Square(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the square button's digital signal.
double GetLeftX() const
Get the X axis value of left side of the controller.
Trigger Cross(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the cross button's digital signal.
Trigger L3(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the L3 (left stick) button's digital signal.
Trigger Options(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the options button's digital signal.
Trigger Circle(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the circle button's digital signal.
Trigger R1(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the right trigger 1 button's digital signal.
Trigger Touchpad(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the touchpad button's digital signal.
Trigger Share(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the share button's digital signal.
double GetLeftY() const
Get the Y axis value of left side of the controller.
Trigger R2(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the right trigger 2 button's digital signal.
double GetRightY() const
Get the Y axis value of right side of the controller.
Trigger PS(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the PlayStation button's digital signal.
CommandPS4Controller(int port)
Construct an instance of a controller.
Trigger Triangle(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the triangle button's digital signal.
Trigger L2(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the left trigger 2 button's digital signal.
Trigger R3(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the R3 (right stick) button's digital signal.
Trigger L1(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the left trigger 1 button's digital signal.
static CommandScheduler & GetInstance()
Returns the Scheduler instance.
This class provides an easy way to link commands to conditions.
Definition Trigger.h:32
A declarative way to bind a set of actions to a loop and execute them when the loop is polled.
Definition EventLoop.h:15
Handle input from PS4 controllers connected to the Driver Station.
Definition PS4Controller.h:30
Definition FunctionalCommand.h:13