blob: a08225b3dd2baea8047248d02bfdedda9e30869a [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001// 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.
Brian Silverman8fce7482020-01-05 13:18:21 -08004
5#include "frc/XboxController.h"
6
7#include <hal/FRCUsageReporting.h>
8
9using namespace frc;
10
11XboxController::XboxController(int port) : GenericHID(port) {
12 HAL_Report(HALUsageReporting::kResourceType_XboxController, port + 1);
13}
14
Austin Schuh812d0d12021-11-04 20:16:48 -070015double XboxController::GetLeftX() const {
16 return GetRawAxis(Axis::kLeftX);
Brian Silverman8fce7482020-01-05 13:18:21 -080017}
18
Austin Schuh812d0d12021-11-04 20:16:48 -070019double XboxController::GetRightX() const {
20 return GetRawAxis(Axis::kRightX);
Brian Silverman8fce7482020-01-05 13:18:21 -080021}
22
Austin Schuh812d0d12021-11-04 20:16:48 -070023double XboxController::GetLeftY() const {
24 return GetRawAxis(Axis::kLeftY);
Brian Silverman8fce7482020-01-05 13:18:21 -080025}
26
Austin Schuh812d0d12021-11-04 20:16:48 -070027double XboxController::GetRightY() const {
28 return GetRawAxis(Axis::kRightY);
Brian Silverman8fce7482020-01-05 13:18:21 -080029}
30
Austin Schuh812d0d12021-11-04 20:16:48 -070031double XboxController::GetLeftTriggerAxis() const {
32 return GetRawAxis(Axis::kLeftTrigger);
Brian Silverman8fce7482020-01-05 13:18:21 -080033}
34
Austin Schuh812d0d12021-11-04 20:16:48 -070035double XboxController::GetRightTriggerAxis() const {
36 return GetRawAxis(Axis::kRightTrigger);
Brian Silverman8fce7482020-01-05 13:18:21 -080037}
38
Austin Schuh812d0d12021-11-04 20:16:48 -070039bool XboxController::GetLeftBumper() const {
40 return GetRawButton(Button::kLeftBumper);
Brian Silverman8fce7482020-01-05 13:18:21 -080041}
42
Austin Schuh812d0d12021-11-04 20:16:48 -070043bool XboxController::GetRightBumper() const {
44 return GetRawButton(Button::kRightBumper);
Brian Silverman8fce7482020-01-05 13:18:21 -080045}
46
Austin Schuh812d0d12021-11-04 20:16:48 -070047bool XboxController::GetLeftBumperPressed() {
48 return GetRawButtonPressed(Button::kLeftBumper);
49}
50
51bool XboxController::GetRightBumperPressed() {
52 return GetRawButtonPressed(Button::kRightBumper);
53}
54
55bool XboxController::GetLeftBumperReleased() {
56 return GetRawButtonReleased(Button::kLeftBumper);
57}
58
59bool XboxController::GetRightBumperReleased() {
60 return GetRawButtonReleased(Button::kRightBumper);
61}
62
63bool XboxController::GetLeftStickButton() const {
64 return GetRawButton(Button::kLeftStick);
65}
66
67bool XboxController::GetRightStickButton() const {
68 return GetRawButton(Button::kRightStick);
69}
70
71bool XboxController::GetLeftStickButtonPressed() {
72 return GetRawButtonPressed(Button::kLeftStick);
73}
74
75bool XboxController::GetRightStickButtonPressed() {
76 return GetRawButtonPressed(Button::kRightStick);
77}
78
79bool XboxController::GetLeftStickButtonReleased() {
80 return GetRawButtonReleased(Button::kLeftStick);
81}
82
83bool XboxController::GetRightStickButtonReleased() {
84 return GetRawButtonReleased(Button::kRightStick);
Brian Silverman8fce7482020-01-05 13:18:21 -080085}
86
87bool XboxController::GetAButton() const {
Austin Schuh812d0d12021-11-04 20:16:48 -070088 return GetRawButton(Button::kA);
Brian Silverman8fce7482020-01-05 13:18:21 -080089}
90
91bool XboxController::GetAButtonPressed() {
Austin Schuh812d0d12021-11-04 20:16:48 -070092 return GetRawButtonPressed(Button::kA);
Brian Silverman8fce7482020-01-05 13:18:21 -080093}
94
95bool XboxController::GetAButtonReleased() {
Austin Schuh812d0d12021-11-04 20:16:48 -070096 return GetRawButtonReleased(Button::kA);
Brian Silverman8fce7482020-01-05 13:18:21 -080097}
98
99bool XboxController::GetBButton() const {
Austin Schuh812d0d12021-11-04 20:16:48 -0700100 return GetRawButton(Button::kB);
Brian Silverman8fce7482020-01-05 13:18:21 -0800101}
102
103bool XboxController::GetBButtonPressed() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700104 return GetRawButtonPressed(Button::kB);
Brian Silverman8fce7482020-01-05 13:18:21 -0800105}
106
107bool XboxController::GetBButtonReleased() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700108 return GetRawButtonReleased(Button::kB);
Brian Silverman8fce7482020-01-05 13:18:21 -0800109}
110
111bool XboxController::GetXButton() const {
Austin Schuh812d0d12021-11-04 20:16:48 -0700112 return GetRawButton(Button::kX);
Brian Silverman8fce7482020-01-05 13:18:21 -0800113}
114
115bool XboxController::GetXButtonPressed() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700116 return GetRawButtonPressed(Button::kX);
Brian Silverman8fce7482020-01-05 13:18:21 -0800117}
118
119bool XboxController::GetXButtonReleased() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700120 return GetRawButtonReleased(Button::kX);
Brian Silverman8fce7482020-01-05 13:18:21 -0800121}
122
123bool XboxController::GetYButton() const {
Austin Schuh812d0d12021-11-04 20:16:48 -0700124 return GetRawButton(Button::kY);
Brian Silverman8fce7482020-01-05 13:18:21 -0800125}
126
127bool XboxController::GetYButtonPressed() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700128 return GetRawButtonPressed(Button::kY);
Brian Silverman8fce7482020-01-05 13:18:21 -0800129}
130
131bool XboxController::GetYButtonReleased() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700132 return GetRawButtonReleased(Button::kY);
Brian Silverman8fce7482020-01-05 13:18:21 -0800133}
134
135bool XboxController::GetBackButton() const {
Austin Schuh812d0d12021-11-04 20:16:48 -0700136 return GetRawButton(Button::kBack);
Brian Silverman8fce7482020-01-05 13:18:21 -0800137}
138
139bool XboxController::GetBackButtonPressed() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700140 return GetRawButtonPressed(Button::kBack);
Brian Silverman8fce7482020-01-05 13:18:21 -0800141}
142
143bool XboxController::GetBackButtonReleased() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700144 return GetRawButtonReleased(Button::kBack);
Brian Silverman8fce7482020-01-05 13:18:21 -0800145}
146
147bool XboxController::GetStartButton() const {
Austin Schuh812d0d12021-11-04 20:16:48 -0700148 return GetRawButton(Button::kStart);
Brian Silverman8fce7482020-01-05 13:18:21 -0800149}
150
151bool XboxController::GetStartButtonPressed() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700152 return GetRawButtonPressed(Button::kStart);
Brian Silverman8fce7482020-01-05 13:18:21 -0800153}
154
155bool XboxController::GetStartButtonReleased() {
Austin Schuh812d0d12021-11-04 20:16:48 -0700156 return GetRawButtonReleased(Button::kStart);
Brian Silverman8fce7482020-01-05 13:18:21 -0800157}