WPILibC++ 2024.3.2
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#pragma once
7
8#include "Trigger.h"
10
11namespace frc2 {
12/**
13 * A version of {@link XboxController} with {@link Trigger} factories for
14 * command-based.
15 *
16 * @see XboxController
17 */
19 public:
20 using XboxController::XboxController;
21
22 /**
23 * Constructs an event instance around this button's digital signal.
24 *
25 * @param button the button index
26 * @param loop the event loop instance to attach the event to. Defaults to the
27 * CommandScheduler's default loop.
28 * @return an event instance representing the button's digital signal attached
29 * to the given loop.
30 */
31 Trigger Button(int button,
33 .GetDefaultButtonLoop()) const;
34
35 /**
36 * Constructs an event instance around the left bumper's digital signal.
37 *
38 * @param loop the event loop instance to attach the event to. Defaults to the
39 * CommandScheduler's default loop.
40 * @return an event instance representing the left bumper's digital signal
41 * attached to the given loop.
42 */
44 .GetDefaultButtonLoop()) const;
45
46 /**
47 * Constructs an event instance around the right bumper's digital signal.
48 *
49 * @param loop the event loop instance to attach the event to. Defaults to the
50 * CommandScheduler's default loop.
51 * @return an event instance representing the right bumper's digital signal
52 * attached to the given loop.
53 */
55 .GetDefaultButtonLoop()) const;
56
57 /**
58 * Constructs an event instance around the left stick's digital signal.
59 *
60 * @param loop the event loop instance to attach the event to. Defaults to the
61 * CommandScheduler's default loop.
62 * @return an event instance representing the left stick's digital signal
63 * attached to the given loop.
64 */
66 .GetDefaultButtonLoop()) const;
67
68 /**
69 * Constructs an event instance around the right stick's digital signal.
70 *
71 * @param loop the event loop instance to attach the event to. Defaults to the
72 * CommandScheduler's default loop.
73 * @return an event instance representing the right stick's digital signal
74 * attached to the given loop.
75 */
77 .GetDefaultButtonLoop()) const;
78
79 /**
80 * Constructs an event instance around the A button's digital signal.
81 *
82 * @param loop the event loop instance to attach the event to. Defaults to the
83 * CommandScheduler's default loop.
84 * @return an event instance representing the A button's digital signal
85 * attached to the given loop.
86 */
88 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
89
90 /**
91 * Constructs an event instance around the B button's digital signal.
92 *
93 * @param loop the event loop instance to attach the event to. Defaults to the
94 * CommandScheduler's default loop.
95 * @return an event instance representing the B button's digital signal
96 * attached to the given loop.
97 */
99 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
100
101 /**
102 * Constructs an event instance around the X button's digital signal.
103 *
104 * @param loop the event loop instance to attach the event to. Defaults to the
105 * CommandScheduler's default loop.
106 * @return an event instance representing the X button's digital signal
107 * attached to the given loop.
108 */
110 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
111
112 /**
113 * Constructs an event instance around the Y button's digital signal.
114 *
115 * @param loop the event loop instance to attach the event to. Defaults to the
116 * CommandScheduler's default loop.
117 * @return an event instance representing the Y button's digital signal
118 * attached to the given loop.
119 */
121 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
122
123 /**
124 * Constructs an event instance around the back button's 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 an event instance representing the back button's digital signal
129 * attached to the given loop.
130 */
132 .GetDefaultButtonLoop()) const;
133
134 /**
135 * Constructs an event instance around the start button's digital signal.
136 *
137 * @param loop the event loop instance to attach the event to. Defaults to the
138 * CommandScheduler's default loop.
139 * @return an event instance representing the start button's digital signal
140 * attached to the given loop.
141 */
143 .GetDefaultButtonLoop()) const;
144
145 /**
146 * Constructs a Trigger instance around the axis value of the left trigger.
147 * The returned Trigger will be true when the axis value is greater than
148 * {@code threshold}.
149 *
150 * @param threshold the minimum axis value for the returned Trigger to be
151 * true. This value should be in the range [0, 1] where 0 is the unpressed
152 * state of the axis. Defaults to 0.5.
153 * @param loop the event loop instance to attach the Trigger to. Defaults to
154 * the CommandScheduler's default loop.
155 * @return a Trigger instance that is true when the left trigger's axis
156 * exceeds the provided threshold, attached to the given loop
157 */
158 Trigger LeftTrigger(double threshold = 0.5,
160 .GetDefaultButtonLoop()) const;
161
162 /**
163 * Constructs a Trigger instance around the axis value of the right trigger.
164 * The returned Trigger will be true when the axis value is greater than
165 * {@code threshold}.
166 *
167 * @param threshold the minimum axis value for the returned Trigger to be
168 * true. This value should be in the range [0, 1] where 0 is the unpressed
169 * state of the axis. Defaults to 0.5.
170 * @param loop the event loop instance to attach the Trigger to. Defaults to
171 * the CommandScheduler's default loop.
172 * @return a Trigger instance that is true when the right trigger's axis
173 * exceeds the provided threshold, attached to the given loop
174 */
176 double threshold = 0.5,
177 frc::EventLoop* loop =
178 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
179};
180} // namespace frc2
static CommandScheduler & GetInstance()
Returns the Scheduler instance.
A version of XboxController with Trigger factories for command-based.
Definition: CommandXboxController.h:18
Trigger RightStick(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around the right stick's digital signal.
Trigger Back(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around the back button's digital signal.
Trigger LeftStick(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around the left stick's digital signal.
Trigger Y(frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs an event instance around the Y button's digital signal.
Trigger Button(int button, frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around this button's digital signal.
Trigger B(frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs an event instance around the B button's digital signal.
Trigger Start(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around the start button's digital signal.
Trigger LeftBumper(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around the left bumper's digital signal.
Trigger X(frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs an event instance around the X button's digital signal.
Trigger RightBumper(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around the right bumper's digital signal.
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.
Trigger A(frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs an event 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.
This class provides an easy way to link commands to conditions.
Definition: Trigger.h:31
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 360 or Xbox One controllers connected to the Driver Station.
Definition: XboxController.h:24
Definition: TrapezoidProfileSubsystem.h:12