WPILibC++ 2024.3.2
CommandGenericHID.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
6#include <frc/GenericHID.h>
7
8#include "Trigger.h"
10
11namespace frc2 {
12/**
13 * A subclass of {@link GenericHID} with {@link Trigger} factories for
14 * command-based.
15 *
16 * @see GenericHID
17 */
19 public:
20 using GenericHID::GenericHID;
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 a Trigger instance based around this angle of a POV on the HID.
37 *
38 * <p>The POV angles start at 0 in the up direction, and increase clockwise
39 * (eg right is 90, upper-left is 315).
40 *
41 * @param loop the event loop instance to attach the event to. Defaults to
42 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
43 * scheduler button loop}.
44 * @param angle POV angle in degrees, or -1 for the center / not pressed.
45 * @return a Trigger instance based around this angle of a POV on the HID.
46 */
47 Trigger POV(int angle,
48 frc::EventLoop* loop =
49 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
50
51 /**
52 * Constructs a Trigger instance based around this angle of a POV on the HID.
53 *
54 * <p>The POV angles start at 0 in the up direction, and increase clockwise
55 * (eg right is 90, upper-left is 315).
56 *
57 * @param loop the event loop instance to attach the event to. Defaults to
58 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
59 * scheduler button loop}.
60 * @param pov index of the POV to read (starting at 0). Defaults to 0.
61 * @param angle POV angle in degrees, or -1 for the center / not pressed.
62 * @return a Trigger instance based around this angle of a POV on the HID.
63 */
64 Trigger POV(int pov, int angle,
65 frc::EventLoop* loop =
66 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
67
68 /**
69 * Constructs a Trigger instance based around the 0 degree angle (up) of the
70 * default (index 0) POV on the HID.
71 *
72 * @param loop the event loop instance to attach the event to. Defaults to
73 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
74 * scheduler button loop}.
75 * @return a Trigger instance based around the 0 degree angle of a POV on the
76 * HID.
77 */
79 .GetDefaultButtonLoop()) const;
80
81 /**
82 * Constructs a Trigger instance based around the 45 degree angle (right up)
83 * of the default (index 0) POV on the HID.
84 *
85 * @param loop the event loop instance to attach the event to. Defaults to
86 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
87 * scheduler button loop}.
88 * @return a Trigger instance based around the 45 degree angle of a POV on the
89 * HID.
90 */
92 .GetDefaultButtonLoop()) const;
93
94 /**
95 * Constructs a Trigger instance based around the 90 degree angle (right) of
96 * the default (index 0) POV on the HID.
97 *
98 * @param loop the event loop instance to attach the event to. Defaults to
99 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
100 * scheduler button loop}.
101 * @return a Trigger instance based around the 90 degree angle of a POV on the
102 * HID.
103 */
105 .GetDefaultButtonLoop()) const;
106
107 /**
108 * Constructs a Trigger instance based around the 135 degree angle (right
109 * down) of the default (index 0) POV on the HID.
110 *
111 * @return a Trigger instance based around the 135 degree angle of a POV on
112 * the HID.
113 */
115 frc::EventLoop* loop =
116 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
117
118 /**
119 * Constructs a Trigger instance based around the 180 degree angle (down) of
120 * the default (index 0) POV on the HID.
121 *
122 * @param loop the event loop instance to attach the event to. Defaults to
123 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
124 * scheduler button loop}.
125 * @return a Trigger instance based around the 180 degree angle of a POV on
126 * the HID.
127 */
129 .GetDefaultButtonLoop()) const;
130
131 /**
132 * Constructs a Trigger instance based around the 225 degree angle (down left)
133 * of the default (index 0) POV on the HID.
134 *
135 * @param loop the event loop instance to attach the event to. Defaults to
136 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
137 * scheduler button loop}.
138 * @return a Trigger instance based around the 225 degree angle of a POV on
139 * the HID.
140 */
142 .GetDefaultButtonLoop()) const;
143
144 /**
145 * Constructs a Trigger instance based around the 270 degree angle (left) of
146 * the default (index 0) POV on the HID.
147 *
148 * @param loop the event loop instance to attach the event to. Defaults to
149 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
150 * scheduler button loop}.
151 * @return a Trigger instance based around the 270 degree angle of a POV on
152 * the HID.
153 */
155 .GetDefaultButtonLoop()) const;
156
157 /**
158 * Constructs a Trigger instance based around the 315 degree angle (left up)
159 * of the default (index 0) POV on the HID.
160 *
161 * @param loop the event loop instance to attach the event to. Defaults to
162 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
163 * scheduler button loop}.
164 * @return a Trigger instance based around the 315 degree angle of a POV on
165 * the HID.
166 */
168 .GetDefaultButtonLoop()) const;
169
170 /**
171 * Constructs a Trigger instance based around the center (not pressed)
172 * position of the default (index 0) POV on the HID.
173 *
174 * @param loop the event loop instance to attach the event to. Defaults to
175 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
176 * scheduler button loop}.
177 * @return a Trigger instance based around the center position of a POV on the
178 * HID.
179 */
181 .GetDefaultButtonLoop()) const;
182
183 /**
184 * Constructs a Trigger instance that is true when the axis value is less than
185 * {@code threshold}, attached to {@link
186 * CommandScheduler::GetDefaultButtonLoop() the default command scheduler
187 * button loop}.
188 * @param axis The axis to read, starting at 0.
189 * @param threshold The value below which this trigger should return true.
190 * @param loop the event loop instance to attach the event to. Defaults to
191 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
192 * scheduler button loop}.
193 * @return a Trigger instance that is true when the axis value is less than
194 * the provided threshold.
195 */
197 int axis, double threshold,
198 frc::EventLoop* loop =
199 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
200
201 /**
202 * Constructs a Trigger instance that is true when the axis value is greater
203 * than {@code threshold}, attached to {@link
204 * CommandScheduler::GetDefaultButtonLoop() the default command scheduler
205 * button loop}.
206 * @param axis The axis to read, starting at 0.
207 * @param threshold The value below which this trigger should return true.
208 * @param loop the event loop instance to attach the event to. Defaults to
209 * {@link CommandScheduler::GetDefaultButtonLoop() the default command
210 * scheduler button loop}.
211 * @return a Trigger instance that is true when the axis value is greater than
212 * the provided threshold.
213 */
215 int axis, double threshold,
216 frc::EventLoop* loop =
217 CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
218};
219} // namespace frc2
A subclass of GenericHID with Trigger factories for command-based.
Definition: CommandGenericHID.h:18
Trigger POVRight(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance based around the 90 degree angle (right) of the default (index 0) POV o...
Trigger POVDown(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance based around the 180 degree angle (down) of the default (index 0) POV o...
Trigger POV(int angle, frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs a Trigger instance based around this angle of a POV on the HID.
Trigger POVCenter(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance based around the center (not pressed) position of the default (index 0)...
Trigger POVUpRight(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance based around the 45 degree angle (right up) of the default (index 0) PO...
Trigger Button(int button, frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs an event instance around this button's digital signal.
Trigger POVLeft(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance based around the 270 degree angle (left) of the default (index 0) POV o...
Trigger POV(int pov, int angle, frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs a Trigger instance based around this angle of a POV on the HID.
Trigger AxisLessThan(int axis, double threshold, frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs a Trigger instance that is true when the axis value is less than threshold,...
Trigger POVDownLeft(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance based around the 225 degree angle (down left) of the default (index 0) ...
Trigger POVUpLeft(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance based around the 315 degree angle (left up) of the default (index 0) PO...
Trigger AxisGreaterThan(int axis, double threshold, frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs a Trigger instance that is true when the axis value is greater than threshold,...
Trigger POVDownRight(frc::EventLoop *loop=CommandScheduler::GetInstance().GetDefaultButtonLoop()) const
Constructs a Trigger instance based around the 135 degree angle (right down) of the default (index 0)...
Trigger POVUp(frc::EventLoop *loop=CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const
Constructs a Trigger instance based around the 0 degree angle (up) of the default (index 0) POV on th...
static CommandScheduler & GetInstance()
Returns the Scheduler instance.
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 standard HID devices connected to the Driver Station.
Definition: GenericHID.h:24
Definition: TrapezoidProfileSubsystem.h:12