Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [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/StadiaController.h" |
| 6 | |
| 7 | #include <hal/FRCUsageReporting.h> |
| 8 | |
| 9 | #include "frc/event/BooleanEvent.h" |
| 10 | |
| 11 | using namespace frc; |
| 12 | |
| 13 | StadiaController::StadiaController(int port) : GenericHID(port) { |
| 14 | // re-enable when StadiaController is added to Usage Reporting |
| 15 | // HAL_Report(HALUsageReporting::kResourceType_StadiaController, port + 1); |
| 16 | } |
| 17 | |
| 18 | double StadiaController::GetLeftX() const { |
| 19 | return GetRawAxis(Axis::kLeftX); |
| 20 | } |
| 21 | |
| 22 | double StadiaController::GetRightX() const { |
| 23 | return GetRawAxis(Axis::kRightX); |
| 24 | } |
| 25 | |
| 26 | double StadiaController::GetLeftY() const { |
| 27 | return GetRawAxis(Axis::kLeftY); |
| 28 | } |
| 29 | |
| 30 | double StadiaController::GetRightY() const { |
| 31 | return GetRawAxis(Axis::kRightY); |
| 32 | } |
| 33 | |
| 34 | bool StadiaController::GetLeftBumper() const { |
| 35 | return GetRawButton(Button::kLeftBumper); |
| 36 | } |
| 37 | |
| 38 | bool StadiaController::GetRightBumper() const { |
| 39 | return GetRawButton(Button::kRightBumper); |
| 40 | } |
| 41 | |
| 42 | bool StadiaController::GetLeftBumperPressed() { |
| 43 | return GetRawButtonPressed(Button::kLeftBumper); |
| 44 | } |
| 45 | |
| 46 | bool StadiaController::GetRightBumperPressed() { |
| 47 | return GetRawButtonPressed(Button::kRightBumper); |
| 48 | } |
| 49 | |
| 50 | bool StadiaController::GetLeftBumperReleased() { |
| 51 | return GetRawButtonReleased(Button::kLeftBumper); |
| 52 | } |
| 53 | |
| 54 | bool StadiaController::GetRightBumperReleased() { |
| 55 | return GetRawButtonReleased(Button::kRightBumper); |
| 56 | } |
| 57 | |
| 58 | BooleanEvent StadiaController::LeftBumper(EventLoop* loop) const { |
| 59 | return BooleanEvent(loop, [this]() { return this->GetLeftBumper(); }); |
| 60 | } |
| 61 | |
| 62 | BooleanEvent StadiaController::RightBumper(EventLoop* loop) const { |
| 63 | return BooleanEvent(loop, [this]() { return this->GetRightBumper(); }); |
| 64 | } |
| 65 | |
| 66 | bool StadiaController::GetLeftStickButton() const { |
| 67 | return GetRawButton(Button::kLeftStick); |
| 68 | } |
| 69 | |
| 70 | bool StadiaController::GetRightStickButton() const { |
| 71 | return GetRawButton(Button::kRightStick); |
| 72 | } |
| 73 | |
| 74 | bool StadiaController::GetLeftStickButtonPressed() { |
| 75 | return GetRawButtonPressed(Button::kLeftStick); |
| 76 | } |
| 77 | |
| 78 | bool StadiaController::GetRightStickButtonPressed() { |
| 79 | return GetRawButtonPressed(Button::kRightStick); |
| 80 | } |
| 81 | |
| 82 | bool StadiaController::GetLeftStickButtonReleased() { |
| 83 | return GetRawButtonReleased(Button::kLeftStick); |
| 84 | } |
| 85 | |
| 86 | bool StadiaController::GetRightStickButtonReleased() { |
| 87 | return GetRawButtonReleased(Button::kRightStick); |
| 88 | } |
| 89 | |
| 90 | BooleanEvent StadiaController::LeftStick(EventLoop* loop) const { |
| 91 | return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); }); |
| 92 | } |
| 93 | |
| 94 | BooleanEvent StadiaController::RightStick(EventLoop* loop) const { |
| 95 | return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); }); |
| 96 | } |
| 97 | |
| 98 | bool StadiaController::GetAButton() const { |
| 99 | return GetRawButton(Button::kA); |
| 100 | } |
| 101 | |
| 102 | bool StadiaController::GetAButtonPressed() { |
| 103 | return GetRawButtonPressed(Button::kA); |
| 104 | } |
| 105 | |
| 106 | bool StadiaController::GetAButtonReleased() { |
| 107 | return GetRawButtonReleased(Button::kA); |
| 108 | } |
| 109 | |
| 110 | BooleanEvent StadiaController::A(EventLoop* loop) const { |
| 111 | return BooleanEvent(loop, [this]() { return this->GetAButton(); }); |
| 112 | } |
| 113 | |
| 114 | bool StadiaController::GetBButton() const { |
| 115 | return GetRawButton(Button::kB); |
| 116 | } |
| 117 | |
| 118 | bool StadiaController::GetBButtonPressed() { |
| 119 | return GetRawButtonPressed(Button::kB); |
| 120 | } |
| 121 | |
| 122 | bool StadiaController::GetBButtonReleased() { |
| 123 | return GetRawButtonReleased(Button::kB); |
| 124 | } |
| 125 | |
| 126 | BooleanEvent StadiaController::B(EventLoop* loop) const { |
| 127 | return BooleanEvent(loop, [this]() { return this->GetBButton(); }); |
| 128 | } |
| 129 | |
| 130 | bool StadiaController::GetXButton() const { |
| 131 | return GetRawButton(Button::kX); |
| 132 | } |
| 133 | |
| 134 | bool StadiaController::GetXButtonPressed() { |
| 135 | return GetRawButtonPressed(Button::kX); |
| 136 | } |
| 137 | |
| 138 | bool StadiaController::GetXButtonReleased() { |
| 139 | return GetRawButtonReleased(Button::kX); |
| 140 | } |
| 141 | |
| 142 | BooleanEvent StadiaController::X(EventLoop* loop) const { |
| 143 | return BooleanEvent(loop, [this]() { return this->GetXButton(); }); |
| 144 | } |
| 145 | |
| 146 | bool StadiaController::GetYButton() const { |
| 147 | return GetRawButton(Button::kY); |
| 148 | } |
| 149 | |
| 150 | bool StadiaController::GetYButtonPressed() { |
| 151 | return GetRawButtonPressed(Button::kY); |
| 152 | } |
| 153 | |
| 154 | bool StadiaController::GetYButtonReleased() { |
| 155 | return GetRawButtonReleased(Button::kY); |
| 156 | } |
| 157 | |
| 158 | BooleanEvent StadiaController::Y(EventLoop* loop) const { |
| 159 | return BooleanEvent(loop, [this]() { return this->GetYButton(); }); |
| 160 | } |
| 161 | |
| 162 | bool StadiaController::GetEllipsesButton() const { |
| 163 | return GetRawButton(Button::kEllipses); |
| 164 | } |
| 165 | |
| 166 | bool StadiaController::GetEllipsesButtonPressed() { |
| 167 | return GetRawButtonPressed(Button::kEllipses); |
| 168 | } |
| 169 | |
| 170 | bool StadiaController::GetEllipsesButtonReleased() { |
| 171 | return GetRawButtonReleased(Button::kEllipses); |
| 172 | } |
| 173 | |
| 174 | BooleanEvent StadiaController::Ellipses(EventLoop* loop) const { |
| 175 | return BooleanEvent(loop, [this]() { return this->GetEllipsesButton(); }); |
| 176 | } |
| 177 | |
| 178 | bool StadiaController::GetHamburgerButton() const { |
| 179 | return GetRawButton(Button::kHamburger); |
| 180 | } |
| 181 | |
| 182 | bool StadiaController::GetHamburgerButtonPressed() { |
| 183 | return GetRawButtonPressed(Button::kHamburger); |
| 184 | } |
| 185 | |
| 186 | bool StadiaController::GetHamburgerButtonReleased() { |
| 187 | return GetRawButtonReleased(Button::kHamburger); |
| 188 | } |
| 189 | |
| 190 | BooleanEvent StadiaController::Hamburger(EventLoop* loop) const { |
| 191 | return BooleanEvent(loop, [this]() { return this->GetHamburgerButton(); }); |
| 192 | } |
| 193 | |
| 194 | bool StadiaController::GetStadiaButton() const { |
| 195 | return GetRawButton(Button::kStadia); |
| 196 | } |
| 197 | |
| 198 | bool StadiaController::GetStadiaButtonPressed() { |
| 199 | return GetRawButtonPressed(Button::kStadia); |
| 200 | } |
| 201 | |
| 202 | bool StadiaController::GetStadiaButtonReleased() { |
| 203 | return GetRawButtonReleased(Button::kStadia); |
| 204 | } |
| 205 | |
| 206 | BooleanEvent StadiaController::Stadia(EventLoop* loop) const { |
| 207 | return BooleanEvent(loop, [this]() { return this->GetStadiaButton(); }); |
| 208 | } |
| 209 | |
| 210 | bool StadiaController::GetGoogleButton() const { |
| 211 | return GetRawButton(Button::kGoogle); |
| 212 | } |
| 213 | |
| 214 | bool StadiaController::GetGoogleButtonPressed() { |
| 215 | return GetRawButtonPressed(Button::kGoogle); |
| 216 | } |
| 217 | |
| 218 | bool StadiaController::GetGoogleButtonReleased() { |
| 219 | return GetRawButtonReleased(Button::kGoogle); |
| 220 | } |
| 221 | |
| 222 | BooleanEvent StadiaController::Google(EventLoop* loop) const { |
| 223 | return BooleanEvent(loop, [this]() { return this->GetGoogleButton(); }); |
| 224 | } |
| 225 | |
| 226 | bool StadiaController::GetFrameButton() const { |
| 227 | return GetRawButton(Button::kFrame); |
| 228 | } |
| 229 | |
| 230 | bool StadiaController::GetFrameButtonPressed() { |
| 231 | return GetRawButtonPressed(Button::kFrame); |
| 232 | } |
| 233 | |
| 234 | bool StadiaController::GetFrameButtonReleased() { |
| 235 | return GetRawButtonReleased(Button::kFrame); |
| 236 | } |
| 237 | |
| 238 | BooleanEvent StadiaController::Frame(EventLoop* loop) const { |
| 239 | return BooleanEvent(loop, [this]() { return this->GetFrameButton(); }); |
| 240 | } |
| 241 | |
| 242 | bool StadiaController::GetLeftTriggerButton() const { |
| 243 | return GetRawButton(Button::kLeftTrigger); |
| 244 | } |
| 245 | |
| 246 | bool StadiaController::GetLeftTriggerButtonPressed() { |
| 247 | return GetRawButtonPressed(Button::kLeftTrigger); |
| 248 | } |
| 249 | |
| 250 | bool StadiaController::GetLeftTriggerButtonReleased() { |
| 251 | return GetRawButtonReleased(Button::kLeftTrigger); |
| 252 | } |
| 253 | |
| 254 | BooleanEvent StadiaController::LeftTrigger(EventLoop* loop) const { |
| 255 | return BooleanEvent(loop, [this]() { return this->GetLeftTriggerButton(); }); |
| 256 | } |
| 257 | |
| 258 | bool StadiaController::GetRightTriggerButton() const { |
| 259 | return GetRawButton(Button::kRightTrigger); |
| 260 | } |
| 261 | |
| 262 | bool StadiaController::GetRightTriggerButtonPressed() { |
| 263 | return GetRawButtonPressed(Button::kRightTrigger); |
| 264 | } |
| 265 | |
| 266 | bool StadiaController::GetRightTriggerButtonReleased() { |
| 267 | return GetRawButtonReleased(Button::kRightTrigger); |
| 268 | } |
| 269 | |
| 270 | BooleanEvent StadiaController::RightTrigger(EventLoop* loop) const { |
| 271 | return BooleanEvent(loop, [this]() { return this->GetRightTriggerButton(); }); |
| 272 | } |