WPILibC++ 2025.3.1
Loading...
Searching...
No Matches
StadiaController.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 ./wpilibc/generate_hids.py. DO NOT MODIFY
6
7#pragma once
8
11
12#include "frc/GenericHID.h"
13
14namespace frc {
15
16/**
17 * Handle input from Stadia controllers connected to the Driver Station.
18 *
19 * This class handles Stadia 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 */
29 public wpi::Sendable,
30 public wpi::SendableHelper<StadiaController> {
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 StadiaController(int port);
41
42 ~StadiaController() 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 /**
541 * Read the value of the left bumper (LB) button on the controller.
542 *
543 * @return the state of the button
544 * @deprecated Use GetLeftBumperButton instead. This function is deprecated
545 * for removal to make function names consistent to allow the HID classes to
546 * be automatically generated.
547 */
548 [[deprecated("Use GetLeftBumperButton instead")]]
549 bool GetLeftBumper() const;
550
551 /**
552 * Read the value of the right bumper (RB) button on the controller.
553 *
554 * @return the state of the button
555 * @deprecated Use GetRightBumperButton instead. This function is deprecated
556 * for removal to make function names consistent to allow the HID classes to
557 * be automatically generated.
558 */
559 [[deprecated("Use GetRightBumperButton instead")]]
560 bool GetRightBumper() const;
561
562 /**
563 * Whether the left bumper (LB) was pressed since the last check.
564 *
565 * @return Whether the button was pressed since the last check
566 * @deprecated Use GetLeftBumperButtonPressed instead. This function is
567 * deprecated for removal to make function names consistent to allow the HID
568 * classes to be automatically generated.
569 */
570 [[deprecated("Use GetLeftBumperButtonPressed instead")]]
572
573 /**
574 * Whether the right bumper (RB) was pressed since the last check.
575 *
576 * @return Whether the button was pressed since the last check
577 * @deprecated Use GetRightBumperButtonPressed instead. This function is
578 * deprecated for removal to make function names consistent to allow the HID
579 * classes to be automatically generated.
580 */
581 [[deprecated("Use GetRightBumperButtonPressed instead")]]
583
584 /**
585 * Whether the left bumper (LB) was released since the last check.
586 *
587 * @return Whether the button was released since the last check.
588 * @deprecated Use GetLeftBumperButtonReleased instead. This function is
589 * deprecated for removal to make function names consistent to allow the HID
590 * classes to be automatically generated.
591 */
592 [[deprecated("Use GetLeftBumperButtonReleased instead")]]
594
595 /**
596 * Whether the right bumper (RB) was released since the last check.
597 *
598 * @return Whether the button was released since the last check.
599 * @deprecated Use GetRightBumperButtonReleased instead. This function is
600 * deprecated for removal to make function names consistent to allow the HID
601 * classes to be automatically generated.
602 */
603 [[deprecated("Use GetRightBumperButtonReleased instead")]]
605
606 /** Represents a digital button on an StadiaController. */
607 struct Button {
608 /// A button.
609 static constexpr int kA = 1;
610 /// B button.
611 static constexpr int kB = 2;
612 /// X button.
613 static constexpr int kX = 3;
614 /// Y button.
615 static constexpr int kY = 4;
616 /// Left bumper button.
617 static constexpr int kLeftBumper = 5;
618 /// Right bumper button.
619 static constexpr int kRightBumper = 6;
620 /// Left stick button.
621 static constexpr int kLeftStick = 7;
622 /// Right stick button.
623 static constexpr int kRightStick = 8;
624 /// Ellipses button.
625 static constexpr int kEllipses = 9;
626 /// Hamburger button.
627 static constexpr int kHamburger = 10;
628 /// Stadia button.
629 static constexpr int kStadia = 11;
630 /// Right trigger button.
631 static constexpr int kRightTrigger = 12;
632 /// Left trigger button.
633 static constexpr int kLeftTrigger = 13;
634 /// Google button.
635 static constexpr int kGoogle = 14;
636 /// Frame button.
637 static constexpr int kFrame = 15;
638 };
639
640 /** Represents an axis on an StadiaController. */
641 struct Axis {
642 /// Left X axis.
643 static constexpr int kLeftX = 0;
644 /// Right X axis.
645 static constexpr int kRightX = 3;
646 /// Left Y axis.
647 static constexpr int kLeftY = 1;
648 /// Right Y axis.
649 static constexpr int kRightY = 4;
650 };
651
652 void InitSendable(wpi::SendableBuilder& builder) override;
653};
654
655} // namespace frc
This class provides an easy way to link actions to active high logic signals.
Definition BooleanEvent.h:30
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
Handle input from Stadia controllers connected to the Driver Station.
Definition StadiaController.h:30
bool GetStadiaButtonPressed()
Whether the stadia button was pressed since the last check.
BooleanEvent RightStick(EventLoop *loop) const
Constructs an event instance around the right stick button's digital signal.
BooleanEvent LeftTrigger(EventLoop *loop) const
Constructs an event instance around the left trigger button's digital signal.
BooleanEvent X(EventLoop *loop) const
Constructs an event instance around the X button's digital signal.
bool GetXButtonPressed()
Whether the X button was pressed since the last check.
bool GetLeftBumperButton() const
Read the value of the left bumper button on the controller.
bool GetYButton() const
Read the value of the Y button on the controller.
bool GetStadiaButtonReleased()
Whether the stadia button was released since the last check.
bool GetRightBumperReleased()
Whether the right bumper (RB) was released since the last check.
bool GetEllipsesButtonPressed()
Whether the ellipses button was pressed since the last check.
bool GetGoogleButtonReleased()
Whether the google button was released since the last check.
bool GetLeftBumperPressed()
Whether the left bumper (LB) was pressed since the last check.
bool GetLeftTriggerButtonReleased()
Whether the left trigger button was released since the last check.
bool GetBButtonReleased()
Whether the B button was released since the last check.
bool GetHamburgerButton() const
Read the value of the hamburger button on the controller.
bool GetLeftTriggerButtonPressed()
Whether the left trigger button was pressed since the last check.
double GetLeftX() const
Get the X axis value of left side of the controller.
bool GetBButtonPressed()
Whether the B button was pressed since the last check.
bool GetYButtonPressed()
Whether the Y button was pressed since the last check.
bool GetLeftStickButtonPressed()
Whether the left stick button was pressed since the last check.
bool GetEllipsesButtonReleased()
Whether the ellipses button was released since the last check.
BooleanEvent LeftBumper(EventLoop *loop) const
Constructs an event instance around the left bumper button's digital signal.
bool GetStadiaButton() const
Read the value of the stadia button on the controller.
bool GetRightBumperButtonReleased()
Whether the right bumper button was released since the last check.
bool GetGoogleButtonPressed()
Whether the google button was pressed since the last check.
BooleanEvent Y(EventLoop *loop) const
Constructs an event instance around the Y button's digital signal.
bool GetHamburgerButtonReleased()
Whether the hamburger button was released since the last check.
bool GetRightBumperButtonPressed()
Whether the right bumper button was pressed since the last check.
bool GetAButton() const
Read the value of the A button on the controller.
bool GetRightTriggerButton() const
Read the value of the right trigger button on the controller.
bool GetHamburgerButtonPressed()
Whether the hamburger button was pressed since the last check.
bool GetRightBumperButton() const
Read the value of the right bumper button on the controller.
bool GetLeftStickButtonReleased()
Whether the left stick button was released since the last check.
bool GetGoogleButton() const
Read the value of the google button on the controller.
BooleanEvent Ellipses(EventLoop *loop) const
Constructs an event instance around the ellipses button's digital signal.
BooleanEvent B(EventLoop *loop) const
Constructs an event instance around the B button's digital signal.
BooleanEvent Hamburger(EventLoop *loop) const
Constructs an event instance around the hamburger button's digital signal.
bool GetRightStickButtonReleased()
Whether the right stick button was released since the last check.
BooleanEvent Frame(EventLoop *loop) const
Constructs an event instance around the frame button's digital signal.
bool GetLeftTriggerButton() const
Read the value of the left trigger button on the controller.
bool GetXButtonReleased()
Whether the X button was released since the last check.
double GetLeftY() const
Get the Y axis value of left side of the controller.
bool GetLeftBumperButtonReleased()
Whether the left bumper button was released since the last check.
bool GetAButtonReleased()
Whether the A button was released since the last check.
bool GetRightBumperPressed()
Whether the right bumper (RB) was pressed since the last check.
BooleanEvent Stadia(EventLoop *loop) const
Constructs an event instance around the stadia button's digital signal.
bool GetLeftBumperButtonPressed()
Whether the left bumper button was pressed since the last check.
double GetRightY() const
Get the Y axis value of right side of the controller.
BooleanEvent A(EventLoop *loop) const
Constructs an event instance around the A button's digital signal.
bool GetRightBumper() const
Read the value of the right bumper (RB) button on the controller.
double GetRightX() const
Get the X axis value of right side of the controller.
bool GetFrameButtonPressed()
Whether the frame button was pressed since the last check.
bool GetRightStickButtonPressed()
Whether the right stick button was pressed since the last check.
bool GetRightTriggerButtonPressed()
Whether the right trigger button was pressed since the last check.
BooleanEvent Google(EventLoop *loop) const
Constructs an event instance around the google button's digital signal.
bool GetLeftStickButton() const
Read the value of the left stick button on the controller.
bool GetAButtonPressed()
Whether the A button was pressed since the last check.
bool GetBButton() const
Read the value of the B button on the controller.
BooleanEvent RightTrigger(EventLoop *loop) const
Constructs an event instance around the right trigger button's digital signal.
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
bool GetRightStickButton() const
Read the value of the right stick button on the controller.
bool GetYButtonReleased()
Whether the Y button was released since the last check.
StadiaController(int port)
Construct an instance of a controller.
bool GetRightTriggerButtonReleased()
Whether the right trigger button was released since the last check.
bool GetFrameButtonReleased()
Whether the frame button was released since the last check.
BooleanEvent LeftStick(EventLoop *loop) const
Constructs an event instance around the left stick button's digital signal.
StadiaController & operator=(StadiaController &&)=default
bool GetLeftBumperReleased()
Whether the left bumper (LB) was released since the last check.
bool GetXButton() const
Read the value of the X button on the controller.
StadiaController(StadiaController &&)=default
bool GetEllipsesButton() const
Read the value of the ellipses button on the controller.
~StadiaController() override=default
bool GetLeftBumper() const
Read the value of the left bumper (LB) button on the controller.
BooleanEvent RightBumper(EventLoop *loop) const
Constructs an event instance around the right bumper button's digital signal.
bool GetFrameButton() const
Read the value of the frame button on the controller.
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.h:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.h:21
Interface for Sendable objects.
Definition Sendable.h:16
Definition CAN.h:11
Represents an axis on an StadiaController.
Definition StadiaController.h:641
static constexpr int kLeftY
Left Y axis.
Definition StadiaController.h:647
static constexpr int kLeftX
Left X axis.
Definition StadiaController.h:643
static constexpr int kRightY
Right Y axis.
Definition StadiaController.h:649
static constexpr int kRightX
Right X axis.
Definition StadiaController.h:645
Represents a digital button on an StadiaController.
Definition StadiaController.h:607
static constexpr int kLeftStick
Left stick button.
Definition StadiaController.h:621
static constexpr int kGoogle
Google button.
Definition StadiaController.h:635
static constexpr int kLeftBumper
Left bumper button.
Definition StadiaController.h:617
static constexpr int kHamburger
Hamburger button.
Definition StadiaController.h:627
static constexpr int kY
Y button.
Definition StadiaController.h:615
static constexpr int kLeftTrigger
Left trigger button.
Definition StadiaController.h:633
static constexpr int kRightTrigger
Right trigger button.
Definition StadiaController.h:631
static constexpr int kEllipses
Ellipses button.
Definition StadiaController.h:625
static constexpr int kX
X button.
Definition StadiaController.h:613
static constexpr int kRightBumper
Right bumper button.
Definition StadiaController.h:619
static constexpr int kStadia
Stadia button.
Definition StadiaController.h:629
static constexpr int kFrame
Frame button.
Definition StadiaController.h:637
static constexpr int kB
B button.
Definition StadiaController.h:611
static constexpr int kA
A button.
Definition StadiaController.h:609
static constexpr int kRightStick
Right stick button.
Definition StadiaController.h:623