WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
NiDsStadiaController.hpp
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 ./wpilibc/generate_hids.py. DO NOT MODIFY
6
7#pragma once
8
11
13
14namespace wpi {
15
16/**
17 * Handle input from NiDsStadia controllers connected to the Driver Station.
18 *
19 * This class handles NiDsStadia input that comes from the Driver Station. Each
20 * time a value is requested the most recent value is returned. There is a
21 * single class instance for each controller and the mapping of ports to
22 * hardware buttons depends on the code in the Driver Station.
23 *
24 * Only first party controllers from Google are guaranteed to have the
25 * correct mapping, and only through the official NI DS. Sim is not guaranteed
26 * to have the same mapping, as well as any 3rd party controllers.
27 */
30 public wpi::util::SendableHelper<NiDsStadiaController> {
31 public:
32 /**
33 * Construct an instance of a controller.
34 *
35 * The controller index is the USB port on the Driver Station.
36 *
37 * @param port The port on the Driver Station that the controller is plugged
38 * into (0-5).
39 */
40 explicit NiDsStadiaController(int port);
41
42 ~NiDsStadiaController() override = default;
43
46
47 /**
48 * Get the X axis value of left side of the controller. Right is positive.
49 *
50 * @return the axis value.
51 */
52 double GetLeftX() const;
53
54 /**
55 * Get the X axis value of right side of the controller. Right is positive.
56 *
57 * @return the axis value.
58 */
59 double GetRightX() const;
60
61 /**
62 * Get the Y axis value of left side of the controller. Back is positive.
63 *
64 * @return the axis value.
65 */
66 double GetLeftY() const;
67
68 /**
69 * Get the Y axis value of right side of the controller. Back is positive.
70 *
71 * @return the axis value.
72 */
73 double GetRightY() const;
74
75 /**
76 * Read the value of the A button on the controller.
77 *
78 * @return The state of the button.
79 */
80 bool GetAButton() const;
81
82 /**
83 * Whether the A button was pressed since the last check.
84 *
85 * @return Whether the button was pressed since the last check.
86 */
88
89 /**
90 * Whether the A button was released since the last check.
91 *
92 * @return Whether the button was released since the last check.
93 */
95
96 /**
97 * Constructs an event instance around the A button's
98 * digital signal.
99 *
100 * @param loop the event loop instance to attach the event to.
101 * @return an event instance representing the A button's
102 * digital signal attached to the given loop.
103 */
105
106 /**
107 * Read the value of the B button on the controller.
108 *
109 * @return The state of the button.
110 */
111 bool GetBButton() const;
112
113 /**
114 * Whether the B button was pressed since the last check.
115 *
116 * @return Whether the button was pressed since the last check.
117 */
119
120 /**
121 * Whether the B button was released since the last check.
122 *
123 * @return Whether the button was released since the last check.
124 */
126
127 /**
128 * Constructs an event instance around the B button's
129 * digital signal.
130 *
131 * @param loop the event loop instance to attach the event to.
132 * @return an event instance representing the B button's
133 * digital signal attached to the given loop.
134 */
136
137 /**
138 * Read the value of the X button on the controller.
139 *
140 * @return The state of the button.
141 */
142 bool GetXButton() const;
143
144 /**
145 * Whether the X button was pressed since the last check.
146 *
147 * @return Whether the button was pressed since the last check.
148 */
150
151 /**
152 * Whether the X button was released since the last check.
153 *
154 * @return Whether the button was released since the last check.
155 */
157
158 /**
159 * Constructs an event instance around the X button's
160 * digital signal.
161 *
162 * @param loop the event loop instance to attach the event to.
163 * @return an event instance representing the X button's
164 * digital signal attached to the given loop.
165 */
167
168 /**
169 * Read the value of the Y button on the controller.
170 *
171 * @return The state of the button.
172 */
173 bool GetYButton() const;
174
175 /**
176 * Whether the Y button was pressed since the last check.
177 *
178 * @return Whether the button was pressed since the last check.
179 */
181
182 /**
183 * Whether the Y button was released since the last check.
184 *
185 * @return Whether the button was released since the last check.
186 */
188
189 /**
190 * Constructs an event instance around the Y button's
191 * digital signal.
192 *
193 * @param loop the event loop instance to attach the event to.
194 * @return an event instance representing the Y button's
195 * digital signal attached to the given loop.
196 */
198
199 /**
200 * Read the value of the left bumper button on the controller.
201 *
202 * @return The state of the button.
203 */
205
206 /**
207 * Whether the left bumper button was pressed since the last check.
208 *
209 * @return Whether the button was pressed since the last check.
210 */
212
213 /**
214 * Whether the left bumper button was released since the last check.
215 *
216 * @return Whether the button was released since the last check.
217 */
219
220 /**
221 * Constructs an event instance around the left bumper button's
222 * digital signal.
223 *
224 * @param loop the event loop instance to attach the event to.
225 * @return an event instance representing the left bumper button's
226 * digital signal attached to the given loop.
227 */
229
230 /**
231 * Read the value of the right bumper button on the controller.
232 *
233 * @return The state of the button.
234 */
236
237 /**
238 * Whether the right bumper button was pressed since the last check.
239 *
240 * @return Whether the button was pressed since the last check.
241 */
243
244 /**
245 * Whether the right bumper button was released since the last check.
246 *
247 * @return Whether the button was released since the last check.
248 */
250
251 /**
252 * Constructs an event instance around the right bumper button's
253 * digital signal.
254 *
255 * @param loop the event loop instance to attach the event to.
256 * @return an event instance representing the right bumper button's
257 * digital signal attached to the given loop.
258 */
260
261 /**
262 * Read the value of the left stick button on the controller.
263 *
264 * @return The state of the button.
265 */
266 bool GetLeftStickButton() const;
267
268 /**
269 * Whether the left stick button was pressed since the last check.
270 *
271 * @return Whether the button was pressed since the last check.
272 */
274
275 /**
276 * Whether the left stick button was released since the last check.
277 *
278 * @return Whether the button was released since the last check.
279 */
281
282 /**
283 * Constructs an event instance around the left stick button's
284 * digital signal.
285 *
286 * @param loop the event loop instance to attach the event to.
287 * @return an event instance representing the left stick button's
288 * digital signal attached to the given loop.
289 */
291
292 /**
293 * Read the value of the right stick button on the controller.
294 *
295 * @return The state of the button.
296 */
298
299 /**
300 * Whether the right stick button was pressed since the last check.
301 *
302 * @return Whether the button was pressed since the last check.
303 */
305
306 /**
307 * Whether the right stick button was released since the last check.
308 *
309 * @return Whether the button was released since the last check.
310 */
312
313 /**
314 * Constructs an event instance around the right stick button's
315 * digital signal.
316 *
317 * @param loop the event loop instance to attach the event to.
318 * @return an event instance representing the right stick button's
319 * digital signal attached to the given loop.
320 */
322
323 /**
324 * Read the value of the ellipses button on the controller.
325 *
326 * @return The state of the button.
327 */
328 bool GetEllipsesButton() const;
329
330 /**
331 * Whether the ellipses button was pressed since the last check.
332 *
333 * @return Whether the button was pressed since the last check.
334 */
336
337 /**
338 * Whether the ellipses button was released since the last check.
339 *
340 * @return Whether the button was released since the last check.
341 */
343
344 /**
345 * Constructs an event instance around the ellipses button's
346 * digital signal.
347 *
348 * @param loop the event loop instance to attach the event to.
349 * @return an event instance representing the ellipses button's
350 * digital signal attached to the given loop.
351 */
353
354 /**
355 * Read the value of the hamburger button on the controller.
356 *
357 * @return The state of the button.
358 */
359 bool GetHamburgerButton() const;
360
361 /**
362 * Whether the hamburger button was pressed since the last check.
363 *
364 * @return Whether the button was pressed since the last check.
365 */
367
368 /**
369 * Whether the hamburger button was released since the last check.
370 *
371 * @return Whether the button was released since the last check.
372 */
374
375 /**
376 * Constructs an event instance around the hamburger button's
377 * digital signal.
378 *
379 * @param loop the event loop instance to attach the event to.
380 * @return an event instance representing the hamburger button's
381 * digital signal attached to the given loop.
382 */
384
385 /**
386 * Read the value of the stadia button on the controller.
387 *
388 * @return The state of the button.
389 */
390 bool GetStadiaButton() const;
391
392 /**
393 * Whether the stadia button was pressed since the last check.
394 *
395 * @return Whether the button was pressed since the last check.
396 */
398
399 /**
400 * Whether the stadia button was released since the last check.
401 *
402 * @return Whether the button was released since the last check.
403 */
405
406 /**
407 * Constructs an event instance around the stadia button's
408 * digital signal.
409 *
410 * @param loop the event loop instance to attach the event to.
411 * @return an event instance representing the stadia button's
412 * digital signal attached to the given loop.
413 */
415
416 /**
417 * Read the value of the right trigger button on the controller.
418 *
419 * @return The state of the button.
420 */
422
423 /**
424 * Whether the right trigger button was pressed since the last check.
425 *
426 * @return Whether the button was pressed since the last check.
427 */
429
430 /**
431 * Whether the right trigger button was released since the last check.
432 *
433 * @return Whether the button was released since the last check.
434 */
436
437 /**
438 * Constructs an event instance around the right trigger button's
439 * digital signal.
440 *
441 * @param loop the event loop instance to attach the event to.
442 * @return an event instance representing the right trigger button's
443 * digital signal attached to the given loop.
444 */
446
447 /**
448 * Read the value of the left trigger button on the controller.
449 *
450 * @return The state of the button.
451 */
453
454 /**
455 * Whether the left trigger button was pressed since the last check.
456 *
457 * @return Whether the button was pressed since the last check.
458 */
460
461 /**
462 * Whether the left trigger button was released since the last check.
463 *
464 * @return Whether the button was released since the last check.
465 */
467
468 /**
469 * Constructs an event instance around the left trigger button's
470 * digital signal.
471 *
472 * @param loop the event loop instance to attach the event to.
473 * @return an event instance representing the left trigger button's
474 * digital signal attached to the given loop.
475 */
477
478 /**
479 * Read the value of the google button on the controller.
480 *
481 * @return The state of the button.
482 */
483 bool GetGoogleButton() const;
484
485 /**
486 * Whether the google button was pressed since the last check.
487 *
488 * @return Whether the button was pressed since the last check.
489 */
491
492 /**
493 * Whether the google button was released since the last check.
494 *
495 * @return Whether the button was released since the last check.
496 */
498
499 /**
500 * Constructs an event instance around the google button's
501 * digital signal.
502 *
503 * @param loop the event loop instance to attach the event to.
504 * @return an event instance representing the google button's
505 * digital signal attached to the given loop.
506 */
508
509 /**
510 * Read the value of the frame button on the controller.
511 *
512 * @return The state of the button.
513 */
514 bool GetFrameButton() const;
515
516 /**
517 * Whether the frame button was pressed since the last check.
518 *
519 * @return Whether the button was pressed since the last check.
520 */
522
523 /**
524 * Whether the frame button was released since the last check.
525 *
526 * @return Whether the button was released since the last check.
527 */
529
530 /**
531 * Constructs an event instance around the frame button's
532 * digital signal.
533 *
534 * @param loop the event loop instance to attach the event to.
535 * @return an event instance representing the frame button's
536 * digital signal attached to the given loop.
537 */
539
540 /** Represents a digital button on an NiDsStadiaController. */
541 struct Button {
542 /// A button.
543 static constexpr int kA = 0;
544 /// B button.
545 static constexpr int kB = 1;
546 /// X button.
547 static constexpr int kX = 2;
548 /// Y button.
549 static constexpr int kY = 3;
550 /// Left bumper button.
551 static constexpr int kLeftBumper = 4;
552 /// Right bumper button.
553 static constexpr int kRightBumper = 5;
554 /// Left stick button.
555 static constexpr int kLeftStick = 6;
556 /// Right stick button.
557 static constexpr int kRightStick = 7;
558 /// Ellipses button.
559 static constexpr int kEllipses = 8;
560 /// Hamburger button.
561 static constexpr int kHamburger = 9;
562 /// Stadia button.
563 static constexpr int kStadia = 10;
564 /// Right trigger button.
565 static constexpr int kRightTrigger = 11;
566 /// Left trigger button.
567 static constexpr int kLeftTrigger = 12;
568 /// Google button.
569 static constexpr int kGoogle = 13;
570 /// Frame button.
571 static constexpr int kFrame = 14;
572 };
573
574 /** Represents an axis on an NiDsStadiaController. */
575 struct Axis {
576 /// Left X axis.
577 static constexpr int kLeftX = 0;
578 /// Right X axis.
579 static constexpr int kRightX = 3;
580 /// Left Y axis.
581 static constexpr int kLeftY = 1;
582 /// Right Y axis.
583 static constexpr int kRightY = 4;
584 };
585
587};
588
589} // namespace wpi
This class provides an easy way to link actions to active high logic signals.
Definition BooleanEvent.hpp:28
A declarative way to bind a set of actions to a loop and execute them when the loop is polled.
Definition EventLoop.hpp:15
GenericHID(int port)
bool GetHamburgerButtonPressed()
Whether the hamburger button was pressed since the last check.
BooleanEvent LeftStick(EventLoop *loop) const
Constructs an event instance around the left stick button's digital signal.
void InitSendable(wpi::util::SendableBuilder &builder) override
Initializes this Sendable object.
bool GetYButton() const
Read the value of the Y button on the controller.
bool GetLeftStickButtonPressed()
Whether the left stick button was pressed since the last check.
bool GetRightTriggerButtonReleased()
Whether the right trigger button was released since the last check.
bool GetLeftStickButton() const
Read the value of the left stick button on the controller.
bool GetLeftTriggerButtonReleased()
Whether the left trigger button was released since the last check.
bool GetRightStickButton() const
Read the value of the right stick button on the controller.
bool GetGoogleButtonReleased()
Whether the google button was released since the last check.
bool GetGoogleButtonPressed()
Whether the google button was pressed since the last check.
BooleanEvent LeftBumper(EventLoop *loop) const
Constructs an event instance around the left bumper button's digital signal.
bool GetEllipsesButtonPressed()
Whether the ellipses button was pressed since the last check.
bool GetStadiaButton() const
Read the value of the stadia button on the controller.
double GetLeftX() const
Get the X axis value of left side of the controller.
BooleanEvent LeftTrigger(EventLoop *loop) const
Constructs an event instance around the left trigger button's digital signal.
double GetRightY() const
Get the Y axis value of right side of the controller.
BooleanEvent RightBumper(EventLoop *loop) const
Constructs an event instance around the right bumper button's digital signal.
bool GetLeftBumperButtonPressed()
Whether the left bumper button was pressed since the last check.
bool GetFrameButton() const
Read the value of the frame button on the controller.
bool GetEllipsesButton() const
Read the value of the ellipses button on the controller.
NiDsStadiaController(int port)
Construct an instance of a controller.
NiDsStadiaController(NiDsStadiaController &&)=default
bool GetBButton() const
Read the value of the B button on the controller.
BooleanEvent Y(EventLoop *loop) const
Constructs an event instance around the Y button's digital signal.
bool GetStadiaButtonReleased()
Whether the stadia button was released since the last check.
BooleanEvent X(EventLoop *loop) const
Constructs an event instance around the X button's digital signal.
BooleanEvent RightStick(EventLoop *loop) const
Constructs an event instance around the right stick button's digital signal.
bool GetXButtonPressed()
Whether the X button was pressed since the last check.
BooleanEvent Google(EventLoop *loop) const
Constructs an event instance around the google button's digital signal.
BooleanEvent RightTrigger(EventLoop *loop) const
Constructs an event instance around the right trigger button's digital signal.
bool GetXButtonReleased()
Whether the X button was released since the last check.
bool GetLeftTriggerButton() const
Read the value of the left trigger button on the controller.
double GetRightX() const
Get the X axis value of right side of the controller.
bool GetLeftStickButtonReleased()
Whether the left stick button was released since the last check.
BooleanEvent Stadia(EventLoop *loop) const
Constructs an event instance around the stadia button's digital signal.
bool GetStadiaButtonPressed()
Whether the stadia button was pressed since the last check.
bool GetFrameButtonPressed()
Whether the frame button was pressed since the last check.
bool GetRightBumperButton() const
Read the value of the right bumper button on the controller.
bool GetRightBumperButtonReleased()
Whether the right bumper button was released since the last check.
bool GetBButtonReleased()
Whether the B button was released since the last check.
bool GetAButton() const
Read the value of the A button on the controller.
bool GetLeftTriggerButtonPressed()
Whether the left trigger button was pressed since the last check.
bool GetHamburgerButton() const
Read the value of the hamburger button on the controller.
bool GetHamburgerButtonReleased()
Whether the hamburger button was released since the last check.
bool GetGoogleButton() const
Read the value of the google button on the controller.
bool GetAButtonPressed()
Whether the A button was pressed since the last check.
~NiDsStadiaController() override=default
BooleanEvent Frame(EventLoop *loop) const
Constructs an event instance around the frame button's digital signal.
bool GetBButtonPressed()
Whether the B button was pressed since the last check.
double GetLeftY() const
Get the Y axis value of left side of the controller.
bool GetRightTriggerButton() const
Read the value of the right trigger button on the controller.
bool GetRightStickButtonPressed()
Whether the right stick button was pressed since the last check.
NiDsStadiaController & operator=(NiDsStadiaController &&)=default
bool GetRightBumperButtonPressed()
Whether the right bumper button was pressed since the last check.
bool GetEllipsesButtonReleased()
Whether the ellipses button was released since the last check.
BooleanEvent A(EventLoop *loop) const
Constructs an event instance around the A button's digital signal.
bool GetAButtonReleased()
Whether the A button was released since the last check.
bool GetXButton() const
Read the value of the X button on the controller.
bool GetYButtonPressed()
Whether the Y button was pressed since the last check.
bool GetRightStickButtonReleased()
Whether the right stick button was released since the last check.
bool GetLeftBumperButton() const
Read the value of the left bumper button on the controller.
BooleanEvent Ellipses(EventLoop *loop) const
Constructs an event instance around the ellipses button's digital signal.
bool GetFrameButtonReleased()
Whether the frame button was released since the last check.
bool GetRightTriggerButtonPressed()
Whether the right trigger button was pressed since the last check.
BooleanEvent Hamburger(EventLoop *loop) const
Constructs an event instance around the hamburger button's digital signal.
BooleanEvent B(EventLoop *loop) const
Constructs an event instance around the B button's digital signal.
bool GetYButtonReleased()
Whether the Y button was released since the last check.
bool GetLeftBumperButtonReleased()
Whether the left bumper button was released since the last check.
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.hpp:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.hpp:21
Interface for Sendable objects.
Definition Sendable.hpp:16
Definition CvSource.hpp:15
Represents an axis on an NiDsStadiaController.
Definition NiDsStadiaController.hpp:575
static constexpr int kLeftY
Left Y axis.
Definition NiDsStadiaController.hpp:581
static constexpr int kRightX
Right X axis.
Definition NiDsStadiaController.hpp:579
static constexpr int kRightY
Right Y axis.
Definition NiDsStadiaController.hpp:583
static constexpr int kLeftX
Left X axis.
Definition NiDsStadiaController.hpp:577
Represents a digital button on an NiDsStadiaController.
Definition NiDsStadiaController.hpp:541
static constexpr int kRightStick
Right stick button.
Definition NiDsStadiaController.hpp:557
static constexpr int kEllipses
Ellipses button.
Definition NiDsStadiaController.hpp:559
static constexpr int kLeftTrigger
Left trigger button.
Definition NiDsStadiaController.hpp:567
static constexpr int kY
Y button.
Definition NiDsStadiaController.hpp:549
static constexpr int kA
A button.
Definition NiDsStadiaController.hpp:543
static constexpr int kHamburger
Hamburger button.
Definition NiDsStadiaController.hpp:561
static constexpr int kRightTrigger
Right trigger button.
Definition NiDsStadiaController.hpp:565
static constexpr int kX
X button.
Definition NiDsStadiaController.hpp:547
static constexpr int kRightBumper
Right bumper button.
Definition NiDsStadiaController.hpp:553
static constexpr int kGoogle
Google button.
Definition NiDsStadiaController.hpp:569
static constexpr int kFrame
Frame button.
Definition NiDsStadiaController.hpp:571
static constexpr int kStadia
Stadia button.
Definition NiDsStadiaController.hpp:563
static constexpr int kLeftBumper
Left bumper button.
Definition NiDsStadiaController.hpp:551
static constexpr int kLeftStick
Left stick button.
Definition NiDsStadiaController.hpp:555
static constexpr int kB
B button.
Definition NiDsStadiaController.hpp:545