WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
CommandXboxController.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
9
13
14namespace frc2 {
15/**
16 * A version of {@link frc::XboxController} with {@link Trigger} factories for
17 * command-based.
18 *
19 * @see frc::XboxController
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 CommandXboxController(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 A 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 A button's
45 * digital signal attached to the given loop.
46 */
48 .GetDefaultButtonLoop()) const;
49
50 /**
51 * Constructs a Trigger instance around the B 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 B button's
57 * digital signal attached to the given loop.
58 */
60 .GetDefaultButtonLoop()) const;
61
62 /**
63 * Constructs a Trigger instance around the X 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 X button's
69 * digital signal attached to the given loop.
70 */
72 .GetDefaultButtonLoop()) const;
73
74 /**
75 * Constructs a Trigger instance around the Y 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 Y button's
81 * digital signal attached to the given loop.
82 */
84 .GetDefaultButtonLoop()) const;
85
86 /**
87 * Constructs a Trigger instance around the left bumper 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 bumper button's
93 * digital signal attached to the given loop.
94 */
96 .GetDefaultButtonLoop()) const;
97
98 /**
99 * Constructs a Trigger instance around the right bumper 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 bumper button's
105 * digital signal attached to the given loop.
106 */
108 .GetDefaultButtonLoop()) const;
109
110 /**
111 * Constructs a Trigger instance around the back 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 back button's
117 * digital signal attached to the given loop.
118 */
120 .GetDefaultButtonLoop()) const;
121
122 /**
123 * Constructs a Trigger instance around the start 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 start button's
129 * digital signal attached to the given loop.
130 */
132 .GetDefaultButtonLoop()) const;
133
134 /**
135 * Constructs a Trigger instance around the left stick 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 left stick button's
141 * digital signal attached to the given loop.
142 */
144 .GetDefaultButtonLoop()) const;
145
146 /**
147 * Constructs a Trigger instance around the right stick 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 right stick button's
153 * digital signal attached to the given loop.
154 */
156 .GetDefaultButtonLoop()) const;
157
158 /**
159 * Constructs a Trigger instance around the axis value of the left trigger.
160 * The returned Trigger will be true when the axis value is greater than
161 * {@code threshold}.
162 *
163 * @param threshold the minimum axis value for the returned Trigger to be
164 * true. This value should be in the range [0, 1] where 0 is the unpressed
165 * state of the axis. Defaults to 0.5.
166 * @param loop the event loop instance to attach the Trigger to. Defaults to
167 * the CommandScheduler's default loop.
168 * @return a Trigger instance that is true when the left trigger's axis
169 * exceeds the provided threshold, attached to the given loop
170 */
171 Trigger LeftTrigger(double threshold = 0.5,
173 .GetDefaultButtonLoop()) const;
174
175 /**
176 * Constructs a Trigger instance around the axis value of the right trigger.
177 * The returned Trigger will be true when the axis value is greater than
178 * {@code threshold}.
179 *
180 * @param threshold the minimum axis value for the returned Trigger to be
181 * true. This value should be in the range [0, 1] where 0 is the unpressed
182 * state of the axis. Defaults to 0.5.
183 * @param loop the event loop instance to attach the Trigger to. Defaults to
184 * the CommandScheduler's default loop.
185 * @return a Trigger instance that is true when the right trigger's axis
186 * exceeds the provided threshold, attached to the given loop
187 */
188 Trigger RightTrigger(double threshold = 0.5,
190 .GetDefaultButtonLoop()) const;
191
192 /**
193 * Get the X axis value of left side of the controller.
194 *
195 * @return The axis value.
196 */
197 double GetLeftX() const;
198
199 /**
200 * Get the X axis value of right side of the controller.
201 *
202 * @return The axis value.
203 */
204 double GetRightX() const;
205
206 /**
207 * Get the Y axis value of left side of the controller.
208 *
209 * @return The axis value.
210 */
211 double GetLeftY() const;
212
213 /**
214 * Get the Y axis value of right side of the controller.
215 *
216 * @return The axis value.
217 */
218 double GetRightY() const;
219
220 /**
221 * Get the left trigger axis value of the controller. Note that this axis is bound
222 * to the range of [0, 1] as opposed to the usual [-1, 1].
223 *
224 * @return The axis value.
225 */
226 double GetLeftTriggerAxis() const;
227
228 /**
229 * Get the right trigger axis value of the controller. Note that this axis is bound
230 * to the range of [0, 1] as opposed to the usual [-1, 1].
231 *
232 * @return The axis value.
233 */
234 double GetRightTriggerAxis() const;
235
236 private:
238};
239} // namespace frc2
A version of frc::GenericHID with Trigger factories for command-based.
Definition CommandGenericHID.h:19
static CommandScheduler & GetInstance()
Returns the Scheduler instance.
A version of frc::XboxController with Trigger factories for command-based.
Definition CommandXboxController.h:21
Trigger RightTrigger(double threshold=0.5, frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the axis value of the right trigger.
frc::XboxController & GetHID()
Get the underlying GenericHID object.
Trigger RightStick(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the right stick button's digital signal.
Trigger Y(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the Y button's digital signal.
Trigger Back(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the back button's digital signal.
double GetLeftY() const
Get the Y axis value of left side of the controller.
double GetLeftTriggerAxis() const
Get the left trigger axis value of the controller.
Trigger LeftStick(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the left stick button's digital signal.
double GetRightX() const
Get the X axis value of right side of the controller.
Trigger B(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the B button's digital signal.
double GetRightY() const
Get the Y axis value of right side of the controller.
CommandXboxController(int port)
Construct an instance of a controller.
Trigger Start(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the start button's digital signal.
Trigger LeftBumper(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the left bumper button's digital signal.
double GetLeftX() const
Get the X axis value of left side of the controller.
double GetRightTriggerAxis() const
Get the right trigger axis value of the controller.
Trigger RightBumper(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the right bumper button's digital signal.
Trigger A(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the A button's digital signal.
Trigger LeftTrigger(double threshold=0.5, frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the axis value of the left trigger.
Trigger X(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance around the X button's digital signal.
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 Xbox controllers connected to the Driver Station.
Definition XboxController.h:30
Definition FunctionalCommand.h:13