WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
Gamepad.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#pragma once
6
10
11namespace wpi {
12
13/**
14 * Handle input from Gamepad controllers connected to the Driver Station.
15 *
16 * This class handles Gamepad input that comes from the Driver Station. Each
17 * time a value is requested the most recent value is returned. There is a
18 * single class instance for each controller and the mapping of ports to
19 * hardware buttons depends on the code in the Driver Station.
20 *
21 * Only first party controllers from Generic are guaranteed to have the
22 * correct mapping, and only through the official NI DS. Sim is not guaranteed
23 * to have the same mapping, as well as any 3rd party controllers.
24 */
25class Gamepad : public GenericHID,
27 public wpi::util::SendableHelper<Gamepad> {
28 public:
29 /**
30 * Construct an instance of a controller.
31 *
32 * The controller index is the USB port on the Driver Station.
33 *
34 * @param port The port on the Driver Station that the controller is plugged
35 * into (0-5).
36 */
37 explicit Gamepad(int port);
38
39 ~Gamepad() override = default;
40
41 Gamepad(Gamepad&&) = default;
42 Gamepad& operator=(Gamepad&&) = default;
43
44 /**
45 * Get the X axis value of left side of the controller. Right is positive.
46 *
47 * @return the axis value.
48 */
49 double GetLeftX() const;
50
51 /**
52 * Get the Y axis value of left side of the controller. Back is positive.
53 *
54 * @return the axis value.
55 */
56 double GetLeftY() const;
57
58 /**
59 * Get the X axis value of right side of the controller. Right is positive.
60 *
61 * @return the axis value.
62 */
63 double GetRightX() const;
64
65 /**
66 * Get the Y axis value of right side of the controller. Back is positive.
67 *
68 * @return the axis value.
69 */
70 double GetRightY() const;
71
72 /**
73 * Get the left trigger axis value of the controller. Note that this axis
74 * is bound to the range of [0, 1] as opposed to the usual [-1, 1].
75 *
76 * @return the axis value.
77 */
78 double GetLeftTriggerAxis() const;
79
80 /**
81 * Constructs an event instance around the axis value of the left trigger.
82 * The returned trigger will be true when the axis value is greater than
83 * {@code threshold}.
84 * @param threshold the minimum axis value for the returned event to be true.
85 * This value should be in the range [0, 1] where 0 is the unpressed state of
86 * the axis.
87 * @param loop the event loop instance to attach the event to.
88 * @return an event instance that is true when the left trigger's axis
89 * exceeds the provided threshold, attached to the given event loop
90 */
91 BooleanEvent LeftTrigger(double threshold, EventLoop* loop) const;
92
93 /**
94 * Constructs an event instance around the axis value of the left trigger.
95 * The returned trigger will be true when the axis value is greater than 0.5.
96 * @param loop the event loop instance to attach the event to.
97 * @return an event instance that is true when the left trigger's axis
98 * exceeds 0.5, attached to the given event loop
99 */
101
102 /**
103 * Get the right trigger axis value of the controller. Note that this axis
104 * is bound to the range of [0, 1] as opposed to the usual [-1, 1].
105 *
106 * @return the axis value.
107 */
108 double GetRightTriggerAxis() const;
109
110 /**
111 * Constructs an event instance around the axis value of the right trigger.
112 * The returned trigger will be true when the axis value is greater than
113 * {@code threshold}.
114 * @param threshold the minimum axis value for the returned event to be true.
115 * This value should be in the range [0, 1] where 0 is the unpressed state of
116 * the axis.
117 * @param loop the event loop instance to attach the event to.
118 * @return an event instance that is true when the right trigger's axis
119 * exceeds the provided threshold, attached to the given event loop
120 */
121 BooleanEvent RightTrigger(double threshold, EventLoop* loop) const;
122
123 /**
124 * Constructs an event instance around the axis value of the right trigger.
125 * The returned trigger will be true when the axis value is greater than 0.5.
126 * @param loop the event loop instance to attach the event to.
127 * @return an event instance that is true when the right trigger's axis
128 * exceeds 0.5, attached to the given event loop
129 */
131
132 /**
133 * Read the value of the South Face button on the controller.
134 *
135 * @return The state of the button.
136 */
137 bool GetSouthFaceButton() const;
138
139 /**
140 * Whether the South Face button was pressed since the last check.
141 *
142 * @return Whether the button was pressed since the last check.
143 */
145
146 /**
147 * Whether the South Face button was released since the last check.
148 *
149 * @return Whether the button was released since the last check.
150 */
152
153 /**
154 * Constructs an event instance around the South Face button's
155 * digital signal.
156 *
157 * @param loop the event loop instance to attach the event to.
158 * @return an event instance representing the South Face button's
159 * digital signal attached to the given loop.
160 */
162
163 /**
164 * Read the value of the East Face button on the controller.
165 *
166 * @return The state of the button.
167 */
168 bool GetEastFaceButton() const;
169
170 /**
171 * Whether the East Face button was pressed since the last check.
172 *
173 * @return Whether the button was pressed since the last check.
174 */
176
177 /**
178 * Whether the East Face button was released since the last check.
179 *
180 * @return Whether the button was released since the last check.
181 */
183
184 /**
185 * Constructs an event instance around the East Face button's
186 * digital signal.
187 *
188 * @param loop the event loop instance to attach the event to.
189 * @return an event instance representing the East Face button's
190 * digital signal attached to the given loop.
191 */
193
194 /**
195 * Read the value of the West Face button on the controller.
196 *
197 * @return The state of the button.
198 */
199 bool GetWestFaceButton() const;
200
201 /**
202 * Whether the West Face button was pressed since the last check.
203 *
204 * @return Whether the button was pressed since the last check.
205 */
207
208 /**
209 * Whether the West Face button was released since the last check.
210 *
211 * @return Whether the button was released since the last check.
212 */
214
215 /**
216 * Constructs an event instance around the West Face button's
217 * digital signal.
218 *
219 * @param loop the event loop instance to attach the event to.
220 * @return an event instance representing the West Face button's
221 * digital signal attached to the given loop.
222 */
224
225 /**
226 * Read the value of the North Face button on the controller.
227 *
228 * @return The state of the button.
229 */
230 bool GetNorthFaceButton() const;
231
232 /**
233 * Whether the North Face button was pressed since the last check.
234 *
235 * @return Whether the button was pressed since the last check.
236 */
238
239 /**
240 * Whether the North Face button was released since the last check.
241 *
242 * @return Whether the button was released since the last check.
243 */
245
246 /**
247 * Constructs an event instance around the North Face button's
248 * digital signal.
249 *
250 * @param loop the event loop instance to attach the event to.
251 * @return an event instance representing the North Face button's
252 * digital signal attached to the given loop.
253 */
255
256 /**
257 * Read the value of the Back button on the controller.
258 *
259 * @return The state of the button.
260 */
261 bool GetBackButton() const;
262
263 /**
264 * Whether the Back button was pressed since the last check.
265 *
266 * @return Whether the button was pressed since the last check.
267 */
269
270 /**
271 * Whether the Back button was released since the last check.
272 *
273 * @return Whether the button was released since the last check.
274 */
276
277 /**
278 * Constructs an event instance around the Back button's
279 * digital signal.
280 *
281 * @param loop the event loop instance to attach the event to.
282 * @return an event instance representing the Back button's
283 * digital signal attached to the given loop.
284 */
286
287 /**
288 * Read the value of the Guide button on the controller.
289 *
290 * @return The state of the button.
291 */
292 bool GetGuideButton() const;
293
294 /**
295 * Whether the Guide button was pressed since the last check.
296 *
297 * @return Whether the button was pressed since the last check.
298 */
300
301 /**
302 * Whether the Guide button was released since the last check.
303 *
304 * @return Whether the button was released since the last check.
305 */
307
308 /**
309 * Constructs an event instance around the Guide button's
310 * digital signal.
311 *
312 * @param loop the event loop instance to attach the event to.
313 * @return an event instance representing the Guide button's
314 * digital signal attached to the given loop.
315 */
317
318 /**
319 * Read the value of the Start button on the controller.
320 *
321 * @return The state of the button.
322 */
323 bool GetStartButton() const;
324
325 /**
326 * Whether the Start button was pressed since the last check.
327 *
328 * @return Whether the button was pressed since the last check.
329 */
331
332 /**
333 * Whether the Start button was released since the last check.
334 *
335 * @return Whether the button was released since the last check.
336 */
338
339 /**
340 * Constructs an event instance around the Start button's
341 * digital signal.
342 *
343 * @param loop the event loop instance to attach the event to.
344 * @return an event instance representing the Start button's
345 * digital signal attached to the given loop.
346 */
348
349 /**
350 * Read the value of the left stick button on the controller.
351 *
352 * @return The state of the button.
353 */
354 bool GetLeftStickButton() const;
355
356 /**
357 * Whether the left stick button was pressed since the last check.
358 *
359 * @return Whether the button was pressed since the last check.
360 */
362
363 /**
364 * Whether the left stick button was released since the last check.
365 *
366 * @return Whether the button was released since the last check.
367 */
369
370 /**
371 * Constructs an event instance around the left stick button's
372 * digital signal.
373 *
374 * @param loop the event loop instance to attach the event to.
375 * @return an event instance representing the left stick button's
376 * digital signal attached to the given loop.
377 */
379
380 /**
381 * Read the value of the right stick button on the controller.
382 *
383 * @return The state of the button.
384 */
386
387 /**
388 * Whether the right stick button was pressed since the last check.
389 *
390 * @return Whether the button was pressed since the last check.
391 */
393
394 /**
395 * Whether the right stick button was released since the last check.
396 *
397 * @return Whether the button was released since the last check.
398 */
400
401 /**
402 * Constructs an event instance around the right stick button's
403 * digital signal.
404 *
405 * @param loop the event loop instance to attach the event to.
406 * @return an event instance representing the right stick button's
407 * digital signal attached to the given loop.
408 */
410
411 /**
412 * Read the value of the right bumper button on the controller.
413 *
414 * @return The state of the button.
415 */
417
418 /**
419 * Whether the right bumper button was pressed since the last check.
420 *
421 * @return Whether the button was pressed since the last check.
422 */
424
425 /**
426 * Whether the right bumper button was released since the last check.
427 *
428 * @return Whether the button was released since the last check.
429 */
431
432 /**
433 * Constructs an event instance around the right bumper button's
434 * digital signal.
435 *
436 * @param loop the event loop instance to attach the event to.
437 * @return an event instance representing the right bumper button's
438 * digital signal attached to the given loop.
439 */
441
442 /**
443 * Read the value of the right bumper button on the controller.
444 *
445 * @return The state of the button.
446 */
448
449 /**
450 * Whether the right bumper button was pressed since the last check.
451 *
452 * @return Whether the button was pressed since the last check.
453 */
455
456 /**
457 * Whether the right bumper button was released since the last check.
458 *
459 * @return Whether the button was released since the last check.
460 */
462
463 /**
464 * Constructs an event instance around the right bumper button's
465 * digital signal.
466 *
467 * @param loop the event loop instance to attach the event to.
468 * @return an event instance representing the right bumper button's
469 * digital signal attached to the given loop.
470 */
472
473 /**
474 * Read the value of the D-pad up button on the controller.
475 *
476 * @return The state of the button.
477 */
478 bool GetDpadUpButton() const;
479
480 /**
481 * Whether the D-pad up button was pressed since the last check.
482 *
483 * @return Whether the button was pressed since the last check.
484 */
486
487 /**
488 * Whether the D-pad up button was released since the last check.
489 *
490 * @return Whether the button was released since the last check.
491 */
493
494 /**
495 * Constructs an event instance around the D-pad up button's
496 * digital signal.
497 *
498 * @param loop the event loop instance to attach the event to.
499 * @return an event instance representing the D-pad up button's
500 * digital signal attached to the given loop.
501 */
503
504 /**
505 * Read the value of the D-pad down button on the controller.
506 *
507 * @return The state of the button.
508 */
509 bool GetDpadDownButton() const;
510
511 /**
512 * Whether the D-pad down button was pressed since the last check.
513 *
514 * @return Whether the button was pressed since the last check.
515 */
517
518 /**
519 * Whether the D-pad down button was released since the last check.
520 *
521 * @return Whether the button was released since the last check.
522 */
524
525 /**
526 * Constructs an event instance around the D-pad down button's
527 * digital signal.
528 *
529 * @param loop the event loop instance to attach the event to.
530 * @return an event instance representing the D-pad down button's
531 * digital signal attached to the given loop.
532 */
534
535 /**
536 * Read the value of the D-pad left button on the controller.
537 *
538 * @return The state of the button.
539 */
540 bool GetDpadLeftButton() const;
541
542 /**
543 * Whether the D-pad left button was pressed since the last check.
544 *
545 * @return Whether the button was pressed since the last check.
546 */
548
549 /**
550 * Whether the D-pad left button was released since the last check.
551 *
552 * @return Whether the button was released since the last check.
553 */
555
556 /**
557 * Constructs an event instance around the D-pad left button's
558 * digital signal.
559 *
560 * @param loop the event loop instance to attach the event to.
561 * @return an event instance representing the D-pad left button's
562 * digital signal attached to the given loop.
563 */
565
566 /**
567 * Read the value of the D-pad right button on the controller.
568 *
569 * @return The state of the button.
570 */
571 bool GetDpadRightButton() const;
572
573 /**
574 * Whether the D-pad right button was pressed since the last check.
575 *
576 * @return Whether the button was pressed since the last check.
577 */
579
580 /**
581 * Whether the D-pad right button was released since the last check.
582 *
583 * @return Whether the button was released since the last check.
584 */
586
587 /**
588 * Constructs an event instance around the D-pad right button's
589 * digital signal.
590 *
591 * @param loop the event loop instance to attach the event to.
592 * @return an event instance representing the D-pad right button's
593 * digital signal attached to the given loop.
594 */
596
597 /**
598 * Read the value of the Miscellaneous 1 button on the controller.
599 *
600 * @return The state of the button.
601 */
602 bool GetMisc1Button() const;
603
604 /**
605 * Whether the Miscellaneous 1 button was pressed since the last check.
606 *
607 * @return Whether the button was pressed since the last check.
608 */
610
611 /**
612 * Whether the Miscellaneous 1 button was released since the last check.
613 *
614 * @return Whether the button was released since the last check.
615 */
617
618 /**
619 * Constructs an event instance around the Miscellaneous 1 button's
620 * digital signal.
621 *
622 * @param loop the event loop instance to attach the event to.
623 * @return an event instance representing the Miscellaneous 1 button's
624 * digital signal attached to the given loop.
625 */
627
628 /**
629 * Read the value of the Right Paddle 1 button on the controller.
630 *
631 * @return The state of the button.
632 */
634
635 /**
636 * Whether the Right Paddle 1 button was pressed since the last check.
637 *
638 * @return Whether the button was pressed since the last check.
639 */
641
642 /**
643 * Whether the Right Paddle 1 button was released since the last check.
644 *
645 * @return Whether the button was released since the last check.
646 */
648
649 /**
650 * Constructs an event instance around the Right Paddle 1 button's
651 * digital signal.
652 *
653 * @param loop the event loop instance to attach the event to.
654 * @return an event instance representing the Right Paddle 1 button's
655 * digital signal attached to the given loop.
656 */
658
659 /**
660 * Read the value of the Left Paddle 1 button on the controller.
661 *
662 * @return The state of the button.
663 */
665
666 /**
667 * Whether the Left Paddle 1 button was pressed since the last check.
668 *
669 * @return Whether the button was pressed since the last check.
670 */
672
673 /**
674 * Whether the Left Paddle 1 button was released since the last check.
675 *
676 * @return Whether the button was released since the last check.
677 */
679
680 /**
681 * Constructs an event instance around the Left Paddle 1 button's
682 * digital signal.
683 *
684 * @param loop the event loop instance to attach the event to.
685 * @return an event instance representing the Left Paddle 1 button's
686 * digital signal attached to the given loop.
687 */
689
690 /**
691 * Read the value of the Right Paddle 2 button on the controller.
692 *
693 * @return The state of the button.
694 */
696
697 /**
698 * Whether the Right Paddle 2 button was pressed since the last check.
699 *
700 * @return Whether the button was pressed since the last check.
701 */
703
704 /**
705 * Whether the Right Paddle 2 button was released since the last check.
706 *
707 * @return Whether the button was released since the last check.
708 */
710
711 /**
712 * Constructs an event instance around the Right Paddle 2 button's
713 * digital signal.
714 *
715 * @param loop the event loop instance to attach the event to.
716 * @return an event instance representing the Right Paddle 2 button's
717 * digital signal attached to the given loop.
718 */
720
721 /**
722 * Read the value of the Left Paddle 2 button on the controller.
723 *
724 * @return The state of the button.
725 */
727
728 /**
729 * Whether the Left Paddle 2 button was pressed since the last check.
730 *
731 * @return Whether the button was pressed since the last check.
732 */
734
735 /**
736 * Whether the Left Paddle 2 button was released since the last check.
737 *
738 * @return Whether the button was released since the last check.
739 */
741
742 /**
743 * Constructs an event instance around the Left Paddle 2 button's
744 * digital signal.
745 *
746 * @param loop the event loop instance to attach the event to.
747 * @return an event instance representing the Left Paddle 2 button's
748 * digital signal attached to the given loop.
749 */
751
752 /**
753 * Read the value of the Touchpad button on the controller.
754 *
755 * @return The state of the button.
756 */
757 bool GetTouchpadButton() const;
758
759 /**
760 * Whether the Touchpad button was pressed since the last check.
761 *
762 * @return Whether the button was pressed since the last check.
763 */
765
766 /**
767 * Whether the Touchpad button was released since the last check.
768 *
769 * @return Whether the button was released since the last check.
770 */
772
773 /**
774 * Constructs an event instance around the Touchpad button's
775 * digital signal.
776 *
777 * @param loop the event loop instance to attach the event to.
778 * @return an event instance representing the Touchpad button's
779 * digital signal attached to the given loop.
780 */
782
783 /**
784 * Read the value of the Miscellaneous 2 button on the controller.
785 *
786 * @return The state of the button.
787 */
788 bool GetMisc2Button() const;
789
790 /**
791 * Whether the Miscellaneous 2 button was pressed since the last check.
792 *
793 * @return Whether the button was pressed since the last check.
794 */
796
797 /**
798 * Whether the Miscellaneous 2 button was released since the last check.
799 *
800 * @return Whether the button was released since the last check.
801 */
803
804 /**
805 * Constructs an event instance around the Miscellaneous 2 button's
806 * digital signal.
807 *
808 * @param loop the event loop instance to attach the event to.
809 * @return an event instance representing the Miscellaneous 2 button's
810 * digital signal attached to the given loop.
811 */
813
814 /**
815 * Read the value of the Miscellaneous 3 button on the controller.
816 *
817 * @return The state of the button.
818 */
819 bool GetMisc3Button() const;
820
821 /**
822 * Whether the Miscellaneous 3 button was pressed since the last check.
823 *
824 * @return Whether the button was pressed since the last check.
825 */
827
828 /**
829 * Whether the Miscellaneous 3 button was released since the last check.
830 *
831 * @return Whether the button was released since the last check.
832 */
834
835 /**
836 * Constructs an event instance around the Miscellaneous 3 button's
837 * digital signal.
838 *
839 * @param loop the event loop instance to attach the event to.
840 * @return an event instance representing the Miscellaneous 3 button's
841 * digital signal attached to the given loop.
842 */
844
845 /**
846 * Read the value of the Miscellaneous 4 button on the controller.
847 *
848 * @return The state of the button.
849 */
850 bool GetMisc4Button() const;
851
852 /**
853 * Whether the Miscellaneous 4 button was pressed since the last check.
854 *
855 * @return Whether the button was pressed since the last check.
856 */
858
859 /**
860 * Whether the Miscellaneous 4 button was released since the last check.
861 *
862 * @return Whether the button was released since the last check.
863 */
865
866 /**
867 * Constructs an event instance around the Miscellaneous 4 button's
868 * digital signal.
869 *
870 * @param loop the event loop instance to attach the event to.
871 * @return an event instance representing the Miscellaneous 4 button's
872 * digital signal attached to the given loop.
873 */
875
876 /**
877 * Read the value of the Miscellaneous 5 button on the controller.
878 *
879 * @return The state of the button.
880 */
881 bool GetMisc5Button() const;
882
883 /**
884 * Whether the Miscellaneous 5 button was pressed since the last check.
885 *
886 * @return Whether the button was pressed since the last check.
887 */
889
890 /**
891 * Whether the Miscellaneous 5 button was released since the last check.
892 *
893 * @return Whether the button was released since the last check.
894 */
896
897 /**
898 * Constructs an event instance around the Miscellaneous 5 button's
899 * digital signal.
900 *
901 * @param loop the event loop instance to attach the event to.
902 * @return an event instance representing the Miscellaneous 5 button's
903 * digital signal attached to the given loop.
904 */
906
907 /**
908 * Read the value of the Miscellaneous 6 button on the controller.
909 *
910 * @return The state of the button.
911 */
912 bool GetMisc6Button() const;
913
914 /**
915 * Whether the Miscellaneous 6 button was pressed since the last check.
916 *
917 * @return Whether the button was pressed since the last check.
918 */
920
921 /**
922 * Whether the Miscellaneous 6 button was released since the last check.
923 *
924 * @return Whether the button was released since the last check.
925 */
927
928 /**
929 * Constructs an event instance around the Miscellaneous 6 button's
930 * digital signal.
931 *
932 * @param loop the event loop instance to attach the event to.
933 * @return an event instance representing the Miscellaneous 6 button's
934 * digital signal attached to the given loop.
935 */
937
938 /** Represents a digital button on an Gamepad. */
939 struct Button {
940 /// South Face button.
941 static constexpr int kSouthFace = 0;
942 /// East Face button.
943 static constexpr int kEastFace = 1;
944 /// West Face button.
945 static constexpr int kWestFace = 2;
946 /// North Face button.
947 static constexpr int kNorthFace = 3;
948 /// Back button.
949 static constexpr int kBack = 4;
950 /// Guide button.
951 static constexpr int kGuide = 5;
952 /// Start button.
953 static constexpr int kStart = 6;
954 /// Left stick button.
955 static constexpr int kLeftStick = 7;
956 /// Right stick button.
957 static constexpr int kRightStick = 8;
958 /// right bumper button.
959 static constexpr int kLeftBumper = 9;
960 /// right bumper button.
961 static constexpr int kRightBumper = 10;
962 /// D-pad up button.
963 static constexpr int kDpadUp = 11;
964 /// D-pad down button.
965 static constexpr int kDpadDown = 12;
966 /// D-pad left button.
967 static constexpr int kDpadLeft = 13;
968 /// D-pad right button.
969 static constexpr int kDpadRight = 14;
970 /// Miscellaneous 1 button.
971 static constexpr int kMisc1 = 15;
972 /// Right Paddle 1 button.
973 static constexpr int kRightPaddle1 = 16;
974 /// Left Paddle 1 button.
975 static constexpr int kLeftPaddle1 = 17;
976 /// Right Paddle 2 button.
977 static constexpr int kRightPaddle2 = 18;
978 /// Left Paddle 2 button.
979 static constexpr int kLeftPaddle2 = 19;
980 /// Touchpad button.
981 static constexpr int kTouchpad = 20;
982 /// Miscellaneous 2 button.
983 static constexpr int kMisc2 = 21;
984 /// Miscellaneous 3 button.
985 static constexpr int kMisc3 = 22;
986 /// Miscellaneous 4 button.
987 static constexpr int kMisc4 = 23;
988 /// Miscellaneous 5 button.
989 static constexpr int kMisc5 = 24;
990 /// Miscellaneous 6 button.
991 static constexpr int kMisc6 = 25;
992 };
993
994 /** Represents an axis on an Gamepad. */
995 struct Axis {
996 /// Left X axis.
997 static constexpr int kLeftX = 0;
998 /// Left Y axis.
999 static constexpr int kLeftY = 1;
1000 /// Right X axis.
1001 static constexpr int kRightX = 2;
1002 /// Right Y axis.
1003 static constexpr int kRightY = 3;
1004 /// Left trigger.
1005 static constexpr int kLeftTrigger = 4;
1006 /// Right trigger.
1007 static constexpr int kRightTrigger = 5;
1008 };
1009
1011
1012 private:
1013 double GetAxisForSendable(int axis) const;
1014 bool GetButtonForSendable(int button) const;
1015};
1016
1017} // 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
bool GetMisc5Button() const
Read the value of the Miscellaneous 5 button on the controller.
BooleanEvent RightBumper(EventLoop *loop) const
Constructs an event instance around the right bumper button's digital signal.
BooleanEvent RightPaddle1(EventLoop *loop) const
Constructs an event instance around the Right Paddle 1 button's digital signal.
Gamepad & operator=(Gamepad &&)=default
BooleanEvent RightStick(EventLoop *loop) const
Constructs an event instance around the right stick button's digital signal.
~Gamepad() override=default
BooleanEvent Guide(EventLoop *loop) const
Constructs an event instance around the Guide button's digital signal.
bool GetStartButtonReleased()
Whether the Start button was released since the last check.
bool GetMisc5ButtonPressed()
Whether the Miscellaneous 5 button was pressed since the last check.
bool GetSouthFaceButton() const
Read the value of the South Face button on the controller.
BooleanEvent Misc1(EventLoop *loop) const
Constructs an event instance around the Miscellaneous 1 button's digital signal.
BooleanEvent RightTrigger(double threshold, EventLoop *loop) const
Constructs an event instance around the axis value of the right trigger.
BooleanEvent Misc6(EventLoop *loop) const
Constructs an event instance around the Miscellaneous 6 button's digital signal.
bool GetDpadLeftButtonPressed()
Whether the D-pad left button was pressed since the last check.
bool GetDpadLeftButton() const
Read the value of the D-pad left button on the controller.
bool GetMisc4ButtonReleased()
Whether the Miscellaneous 4 button was released since the last check.
bool GetDpadDownButton() const
Read the value of the D-pad down button on the controller.
bool GetWestFaceButtonReleased()
Whether the West Face button was released since the last check.
bool GetDpadUpButtonPressed()
Whether the D-pad up button was pressed since the last check.
Gamepad(int port)
Construct an instance of a controller.
BooleanEvent LeftPaddle2(EventLoop *loop) const
Constructs an event instance around the Left Paddle 2 button's digital signal.
bool GetBackButton() const
Read the value of the Back button on the controller.
bool GetMisc2ButtonReleased()
Whether the Miscellaneous 2 button was released since the last check.
BooleanEvent NorthFace(EventLoop *loop) const
Constructs an event instance around the North Face button's digital signal.
bool GetMisc3Button() const
Read the value of the Miscellaneous 3 button on the controller.
bool GetBackButtonReleased()
Whether the Back button was released since the last check.
bool GetDpadRightButtonReleased()
Whether the D-pad right button was released since the last check.
bool GetRightStickButtonPressed()
Whether the right stick button was pressed since the last check.
BooleanEvent LeftPaddle1(EventLoop *loop) const
Constructs an event instance around the Left Paddle 1 button's digital signal.
bool GetRightPaddle2ButtonReleased()
Whether the Right Paddle 2 button was released since the last check.
bool GetSouthFaceButtonPressed()
Whether the South Face button was pressed since the last check.
bool GetRightPaddle1ButtonReleased()
Whether the Right Paddle 1 button was released since the last check.
double GetRightY() const
Get the Y axis value of right side of the controller.
BooleanEvent RightTrigger(EventLoop *loop) const
Constructs an event instance around the axis value of the right trigger.
double GetLeftTriggerAxis() const
Get the left trigger axis value of the controller.
BooleanEvent Misc4(EventLoop *loop) const
Constructs an event instance around the Miscellaneous 4 button's digital signal.
bool GetEastFaceButton() const
Read the value of the East Face button on the controller.
BooleanEvent Back(EventLoop *loop) const
Constructs an event instance around the Back button's digital signal.
bool GetMisc1ButtonReleased()
Whether the Miscellaneous 1 button was released since the last check.
double GetLeftY() const
Get the Y axis value of left side of the controller.
bool GetDpadDownButtonReleased()
Whether the D-pad down button was released since the last check.
bool GetRightPaddle2Button() const
Read the value of the Right Paddle 2 button on the controller.
bool GetLeftPaddle2ButtonReleased()
Whether the Left Paddle 2 button was released since the last check.
BooleanEvent EastFace(EventLoop *loop) const
Constructs an event instance around the East Face button's digital signal.
BooleanEvent LeftTrigger(double threshold, EventLoop *loop) const
Constructs an event instance around the axis value of the left trigger.
bool GetRightBumperButtonPressed()
Whether the right bumper button was pressed since the last check.
bool GetDpadLeftButtonReleased()
Whether the D-pad left button was released since the last check.
bool GetWestFaceButtonPressed()
Whether the West Face button was pressed since the last check.
BooleanEvent Misc3(EventLoop *loop) const
Constructs an event instance around the Miscellaneous 3 button's digital signal.
bool GetRightPaddle1Button() const
Read the value of the Right Paddle 1 button on the controller.
bool GetLeftBumperButtonPressed()
Whether the right bumper button was pressed since the last check.
bool GetGuideButton() const
Read the value of the Guide button on the controller.
bool GetMisc2ButtonPressed()
Whether the Miscellaneous 2 button was pressed since the last check.
bool GetDpadUpButton() const
Read the value of the D-pad up button on the controller.
bool GetTouchpadButtonReleased()
Whether the Touchpad button was released since the last check.
bool GetLeftPaddle1ButtonPressed()
Whether the Left Paddle 1 button was pressed since the last check.
bool GetLeftStickButton() const
Read the value of the left stick button on the controller.
bool GetLeftBumperButtonReleased()
Whether the right bumper button was released since the last check.
bool GetRightBumperButtonReleased()
Whether the right bumper button was released since the last check.
bool GetLeftStickButtonReleased()
Whether the left stick button was released since the last check.
bool GetSouthFaceButtonReleased()
Whether the South Face button was released since the last check.
BooleanEvent DpadRight(EventLoop *loop) const
Constructs an event instance around the D-pad right button's digital signal.
bool GetMisc6ButtonReleased()
Whether the Miscellaneous 6 button was released since the last check.
bool GetMisc3ButtonPressed()
Whether the Miscellaneous 3 button was pressed since the last check.
bool GetMisc6Button() const
Read the value of the Miscellaneous 6 button on the controller.
bool GetDpadUpButtonReleased()
Whether the D-pad up button was released since the last check.
bool GetDpadRightButton() const
Read the value of the D-pad right button on the controller.
bool GetGuideButtonReleased()
Whether the Guide button was released since the last check.
bool GetTouchpadButtonPressed()
Whether the Touchpad button was pressed since the last check.
void InitSendable(wpi::util::SendableBuilder &builder) override
Initializes this Sendable object.
bool GetMisc4Button() const
Read the value of the Miscellaneous 4 button on the controller.
Gamepad(Gamepad &&)=default
bool GetMisc2Button() const
Read the value of the Miscellaneous 2 button on the controller.
bool GetLeftPaddle2Button() const
Read the value of the Left Paddle 2 button on the controller.
bool GetDpadDownButtonPressed()
Whether the D-pad down button was pressed since the last check.
BooleanEvent WestFace(EventLoop *loop) const
Constructs an event instance around the West Face button's digital signal.
bool GetRightPaddle2ButtonPressed()
Whether the Right Paddle 2 button was pressed since the last check.
BooleanEvent Touchpad(EventLoop *loop) const
Constructs an event instance around the Touchpad button's digital signal.
bool GetMisc6ButtonPressed()
Whether the Miscellaneous 6 button was pressed since the last check.
bool GetLeftBumperButton() const
Read the value of the right bumper button on the controller.
BooleanEvent LeftStick(EventLoop *loop) const
Constructs an event instance around the left stick button's digital signal.
bool GetMisc1Button() const
Read the value of the Miscellaneous 1 button on the controller.
BooleanEvent SouthFace(EventLoop *loop) const
Constructs an event instance around the South Face button's digital signal.
bool GetTouchpadButton() const
Read the value of the Touchpad button on the controller.
bool GetLeftPaddle2ButtonPressed()
Whether the Left Paddle 2 button was pressed since the last check.
bool GetDpadRightButtonPressed()
Whether the D-pad right button was pressed since the last check.
BooleanEvent DpadLeft(EventLoop *loop) const
Constructs an event instance around the D-pad left button's digital signal.
bool GetRightPaddle1ButtonPressed()
Whether the Right Paddle 1 button was pressed since the last check.
bool GetMisc3ButtonReleased()
Whether the Miscellaneous 3 button was released since the last check.
bool GetRightBumperButton() const
Read the value of the right bumper button on the controller.
bool GetRightStickButton() const
Read the value of the right stick button on the controller.
bool GetEastFaceButtonPressed()
Whether the East Face button was pressed since the last check.
bool GetLeftPaddle1Button() const
Read the value of the Left Paddle 1 button on the controller.
bool GetBackButtonPressed()
Whether the Back button was pressed since the last check.
BooleanEvent DpadDown(EventLoop *loop) const
Constructs an event instance around the D-pad down button's digital signal.
bool GetLeftPaddle1ButtonReleased()
Whether the Left Paddle 1 button was released since the last check.
BooleanEvent Misc5(EventLoop *loop) const
Constructs an event instance around the Miscellaneous 5 button's digital signal.
BooleanEvent LeftTrigger(EventLoop *loop) const
Constructs an event instance around the axis value of the left trigger.
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.
BooleanEvent DpadUp(EventLoop *loop) const
Constructs an event instance around the D-pad up button's digital signal.
bool GetMisc1ButtonPressed()
Whether the Miscellaneous 1 button was pressed since the last check.
BooleanEvent LeftBumper(EventLoop *loop) const
Constructs an event instance around the right bumper button's digital signal.
double GetRightX() const
Get the X axis value of right side of the controller.
bool GetNorthFaceButton() const
Read the value of the North Face button on the controller.
bool GetEastFaceButtonReleased()
Whether the East Face button was released since the last check.
bool GetWestFaceButton() const
Read the value of the West Face button on the controller.
bool GetNorthFaceButtonReleased()
Whether the North Face button was released since the last check.
BooleanEvent RightPaddle2(EventLoop *loop) const
Constructs an event instance around the Right Paddle 2 button's digital signal.
BooleanEvent Misc2(EventLoop *loop) const
Constructs an event instance around the Miscellaneous 2 button's digital signal.
bool GetGuideButtonPressed()
Whether the Guide button was pressed since the last check.
bool GetMisc4ButtonPressed()
Whether the Miscellaneous 4 button was pressed since the last check.
bool GetMisc5ButtonReleased()
Whether the Miscellaneous 5 button was released since the last check.
bool GetLeftStickButtonPressed()
Whether the left stick button was pressed since the last check.
bool GetStartButtonPressed()
Whether the Start button was pressed since the last check.
bool GetRightStickButtonReleased()
Whether the right stick button was released since the last check.
bool GetNorthFaceButtonPressed()
Whether the North Face button was pressed since the last check.
bool GetStartButton() const
Read the value of the Start button on the controller.
BooleanEvent Start(EventLoop *loop) const
Constructs an event instance around the Start button's digital signal.
GenericHID(int port)
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 Gamepad.
Definition Gamepad.hpp:995
static constexpr int kLeftX
Left X axis.
Definition Gamepad.hpp:997
static constexpr int kRightX
Right X axis.
Definition Gamepad.hpp:1001
static constexpr int kRightTrigger
Right trigger.
Definition Gamepad.hpp:1007
static constexpr int kLeftY
Left Y axis.
Definition Gamepad.hpp:999
static constexpr int kRightY
Right Y axis.
Definition Gamepad.hpp:1003
static constexpr int kLeftTrigger
Left trigger.
Definition Gamepad.hpp:1005
Represents a digital button on an Gamepad.
Definition Gamepad.hpp:939
static constexpr int kWestFace
West Face button.
Definition Gamepad.hpp:945
static constexpr int kNorthFace
North Face button.
Definition Gamepad.hpp:947
static constexpr int kMisc2
Miscellaneous 2 button.
Definition Gamepad.hpp:983
static constexpr int kSouthFace
South Face button.
Definition Gamepad.hpp:941
static constexpr int kRightBumper
right bumper button.
Definition Gamepad.hpp:961
static constexpr int kGuide
Guide button.
Definition Gamepad.hpp:951
static constexpr int kEastFace
East Face button.
Definition Gamepad.hpp:943
static constexpr int kRightStick
Right stick button.
Definition Gamepad.hpp:957
static constexpr int kDpadDown
D-pad down button.
Definition Gamepad.hpp:965
static constexpr int kLeftPaddle1
Left Paddle 1 button.
Definition Gamepad.hpp:975
static constexpr int kDpadUp
D-pad up button.
Definition Gamepad.hpp:963
static constexpr int kDpadRight
D-pad right button.
Definition Gamepad.hpp:969
static constexpr int kStart
Start button.
Definition Gamepad.hpp:953
static constexpr int kTouchpad
Touchpad button.
Definition Gamepad.hpp:981
static constexpr int kMisc1
Miscellaneous 1 button.
Definition Gamepad.hpp:971
static constexpr int kRightPaddle1
Right Paddle 1 button.
Definition Gamepad.hpp:973
static constexpr int kMisc6
Miscellaneous 6 button.
Definition Gamepad.hpp:991
static constexpr int kMisc3
Miscellaneous 3 button.
Definition Gamepad.hpp:985
static constexpr int kLeftBumper
right bumper button.
Definition Gamepad.hpp:959
static constexpr int kBack
Back button.
Definition Gamepad.hpp:949
static constexpr int kLeftStick
Left stick button.
Definition Gamepad.hpp:955
static constexpr int kLeftPaddle2
Left Paddle 2 button.
Definition Gamepad.hpp:979
static constexpr int kMisc4
Miscellaneous 4 button.
Definition Gamepad.hpp:987
static constexpr int kMisc5
Miscellaneous 5 button.
Definition Gamepad.hpp:989
static constexpr int kRightPaddle2
Right Paddle 2 button.
Definition Gamepad.hpp:977
static constexpr int kDpadLeft
D-pad left button.
Definition Gamepad.hpp:967