Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 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 | #include "frc/PS4Controller.h" |
| 6 | |
| 7 | #include <hal/FRCUsageReporting.h> |
| 8 | |
| 9 | using namespace frc; |
| 10 | |
| 11 | PS4Controller::PS4Controller(int port) : GenericHID(port) { |
| 12 | HAL_Report(HALUsageReporting::kResourceType_PS4Controller, port + 1); |
| 13 | } |
| 14 | |
| 15 | double PS4Controller::GetLeftX() const { |
| 16 | return GetRawAxis(Axis::kLeftX); |
| 17 | } |
| 18 | |
| 19 | double PS4Controller::GetRightX() const { |
| 20 | return GetRawAxis(Axis::kRightX); |
| 21 | } |
| 22 | |
| 23 | double PS4Controller::GetLeftY() const { |
| 24 | return GetRawAxis(Axis::kLeftY); |
| 25 | } |
| 26 | |
| 27 | double PS4Controller::GetRightY() const { |
| 28 | return GetRawAxis(Axis::kRightY); |
| 29 | } |
| 30 | |
| 31 | double PS4Controller::GetL2Axis() const { |
| 32 | return GetRawAxis(Axis::kL2); |
| 33 | } |
| 34 | |
| 35 | double PS4Controller::GetR2Axis() const { |
| 36 | return GetRawAxis(Axis::kR2); |
| 37 | } |
| 38 | |
| 39 | bool PS4Controller::GetSquareButton() const { |
| 40 | return GetRawButton(Button::kSquare); |
| 41 | } |
| 42 | |
| 43 | bool PS4Controller::GetSquareButtonPressed() { |
| 44 | return GetRawButtonPressed(Button::kSquare); |
| 45 | } |
| 46 | |
| 47 | bool PS4Controller::GetSquareButtonReleased() { |
| 48 | return GetRawButtonReleased(Button::kSquare); |
| 49 | } |
| 50 | |
| 51 | bool PS4Controller::GetCrossButton() const { |
| 52 | return GetRawButton(Button::kCross); |
| 53 | } |
| 54 | |
| 55 | bool PS4Controller::GetCrossButtonPressed() { |
| 56 | return GetRawButtonPressed(Button::kCross); |
| 57 | } |
| 58 | |
| 59 | bool PS4Controller::GetCrossButtonReleased() { |
| 60 | return GetRawButtonReleased(Button::kCross); |
| 61 | } |
| 62 | |
| 63 | bool PS4Controller::GetCircleButton() const { |
| 64 | return GetRawButton(Button::kCircle); |
| 65 | } |
| 66 | |
| 67 | bool PS4Controller::GetCircleButtonPressed() { |
| 68 | return GetRawButtonPressed(Button::kCircle); |
| 69 | } |
| 70 | |
| 71 | bool PS4Controller::GetCircleButtonReleased() { |
| 72 | return GetRawButtonReleased(Button::kCircle); |
| 73 | } |
| 74 | |
| 75 | bool PS4Controller::GetTriangleButton() const { |
| 76 | return GetRawButton(Button::kTriangle); |
| 77 | } |
| 78 | |
| 79 | bool PS4Controller::GetTriangleButtonPressed() { |
| 80 | return GetRawButtonPressed(Button::kTriangle); |
| 81 | } |
| 82 | |
| 83 | bool PS4Controller::GetTriangleButtonReleased() { |
| 84 | return GetRawButtonReleased(Button::kTriangle); |
| 85 | } |
| 86 | |
| 87 | bool PS4Controller::GetL1Button() const { |
| 88 | return GetRawButton(Button::kL1); |
| 89 | } |
| 90 | |
| 91 | bool PS4Controller::GetL1ButtonPressed() { |
| 92 | return GetRawButtonPressed(Button::kL1); |
| 93 | } |
| 94 | |
| 95 | bool PS4Controller::GetL1ButtonReleased() { |
| 96 | return GetRawButtonReleased(Button::kL1); |
| 97 | } |
| 98 | |
| 99 | bool PS4Controller::GetR1Button() const { |
| 100 | return GetRawButton(Button::kR1); |
| 101 | } |
| 102 | |
| 103 | bool PS4Controller::GetR1ButtonPressed() { |
| 104 | return GetRawButtonPressed(Button::kR1); |
| 105 | } |
| 106 | |
| 107 | bool PS4Controller::GetR1ButtonReleased() { |
| 108 | return GetRawButtonReleased(Button::kR1); |
| 109 | } |
| 110 | |
| 111 | bool PS4Controller::GetL2Button() const { |
| 112 | return GetRawButton(Button::kL2); |
| 113 | } |
| 114 | |
| 115 | bool PS4Controller::GetL2ButtonPressed() { |
| 116 | return GetRawButtonPressed(Button::kL2); |
| 117 | } |
| 118 | |
| 119 | bool PS4Controller::GetL2ButtonReleased() { |
| 120 | return GetRawButtonReleased(Button::kL2); |
| 121 | } |
| 122 | |
| 123 | bool PS4Controller::GetR2Button() const { |
| 124 | return GetRawButton(Button::kR2); |
| 125 | } |
| 126 | |
| 127 | bool PS4Controller::GetR2ButtonPressed() { |
| 128 | return GetRawButtonPressed(Button::kR2); |
| 129 | } |
| 130 | |
| 131 | bool PS4Controller::GetR2ButtonReleased() { |
| 132 | return GetRawButtonReleased(Button::kR2); |
| 133 | } |
| 134 | |
| 135 | bool PS4Controller::GetShareButton() const { |
| 136 | return GetRawButton(Button::kShare); |
| 137 | } |
| 138 | |
| 139 | bool PS4Controller::GetShareButtonPressed() { |
| 140 | return GetRawButtonPressed(Button::kShare); |
| 141 | } |
| 142 | |
| 143 | bool PS4Controller::GetShareButtonReleased() { |
| 144 | return GetRawButtonReleased(Button::kShare); |
| 145 | } |
| 146 | |
| 147 | bool PS4Controller::GetOptionsButton() const { |
| 148 | return GetRawButton(Button::kOptions); |
| 149 | } |
| 150 | |
| 151 | bool PS4Controller::GetOptionsButtonPressed() { |
| 152 | return GetRawButtonPressed(Button::kOptions); |
| 153 | } |
| 154 | |
| 155 | bool PS4Controller::GetOptionsButtonReleased() { |
| 156 | return GetRawButtonReleased(Button::kOptions); |
| 157 | } |
| 158 | |
| 159 | bool PS4Controller::GetL3Button() const { |
| 160 | return GetRawButton(Button::kL3); |
| 161 | } |
| 162 | |
| 163 | bool PS4Controller::GetL3ButtonPressed() { |
| 164 | return GetRawButtonPressed(Button::kL3); |
| 165 | } |
| 166 | |
| 167 | bool PS4Controller::GetL3ButtonReleased() { |
| 168 | return GetRawButtonReleased(Button::kL3); |
| 169 | } |
| 170 | |
| 171 | bool PS4Controller::GetR3Button() const { |
| 172 | return GetRawButton(Button::kR3); |
| 173 | } |
| 174 | |
| 175 | bool PS4Controller::GetR3ButtonPressed() { |
| 176 | return GetRawButtonPressed(Button::kR3); |
| 177 | } |
| 178 | |
| 179 | bool PS4Controller::GetR3ButtonReleased() { |
| 180 | return GetRawButtonReleased(Button::kR3); |
| 181 | } |
| 182 | |
| 183 | bool PS4Controller::GetPSButton() const { |
| 184 | return GetRawButton(Button::kPS); |
| 185 | } |
| 186 | |
| 187 | bool PS4Controller::GetPSButtonPressed() { |
| 188 | return GetRawButtonPressed(Button::kPS); |
| 189 | } |
| 190 | |
| 191 | bool PS4Controller::GetPSButtonReleased() { |
| 192 | return GetRawButtonReleased(Button::kPS); |
| 193 | } |
| 194 | |
| 195 | bool PS4Controller::GetTouchpad() const { |
| 196 | return GetRawButton(Button::kTouchpad); |
| 197 | } |
| 198 | |
| 199 | bool PS4Controller::GetTouchpadPressed() { |
| 200 | return GetRawButtonPressed(Button::kTouchpad); |
| 201 | } |
| 202 | |
| 203 | bool PS4Controller::GetTouchpadReleased() { |
| 204 | return GetRawButtonReleased(Button::kTouchpad); |
| 205 | } |