001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005// THIS FILE WAS AUTO-GENERATED BY ./commandsv3/generate_files.py. DO NOT MODIFY 006 007package org.wpilib.commands3.button; 008 009import edu.wpi.first.wpilibj.StadiaController; 010import edu.wpi.first.wpilibj.event.EventLoop; 011import org.wpilib.commands3.Scheduler; 012import org.wpilib.commands3.Trigger; 013 014/** 015 * A version of {@link StadiaController} with {@link Trigger} factories for command-based. 016 * 017 * @see StadiaController 018 */ 019@SuppressWarnings("MethodName") 020public class CommandStadiaController extends CommandGenericHID { 021 private final StadiaController m_hid; 022 023 /** 024 * Construct an instance of a controller. Commands bound to buttons on the controller will be 025 * scheduled on the {@link Scheduler#getDefault() default scheduler} using its default event loop. 026 * 027 * @param port The port index on the Driver Station that the controller is plugged into. 028 */ 029 public CommandStadiaController(int port) { 030 super(port); 031 m_hid = new StadiaController(port); 032 } 033 034 /** 035 * Construct an instance of a controller. Commands bound to buttons on the controller will be 036 * scheduled on the given scheduler using its default event loop. 037 * 038 * @param scheduler The scheduler that should execute the triggered commands. 039 * @param port The port index on the Driver Station that the controller is plugged into. 040 */ 041 public CommandStadiaController(Scheduler scheduler, int port) { 042 super(scheduler, port); 043 m_hid = new StadiaController(port); 044 } 045 046 /** 047 * Get the underlying GenericHID object. 048 * 049 * @return the wrapped GenericHID object 050 */ 051 @Override 052 public StadiaController getHID() { 053 return m_hid; 054 } 055 056 /** 057 * Constructs a Trigger instance around the A button's digital signal. 058 * 059 * @return a Trigger instance representing the A button's digital signal attached 060 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 061 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 062 * default scheduler} if a scheduler was not explicitly provided. 063 * @see #a(EventLoop) 064 */ 065 public Trigger a() { 066 return a(getScheduler().getDefaultEventLoop()); 067 } 068 069 /** 070 * Constructs a Trigger instance around the A button's digital signal. 071 * 072 * @param loop the event loop instance to attach the event to. 073 * @return a Trigger instance representing the A button's digital signal attached 074 * to the given loop. 075 */ 076 public Trigger a(EventLoop loop) { 077 return button(StadiaController.Button.kA.value, loop); 078 } 079 080 /** 081 * Constructs a Trigger instance around the B button's digital signal. 082 * 083 * @return a Trigger instance representing the B button's digital signal attached 084 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 085 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 086 * default scheduler} if a scheduler was not explicitly provided. 087 * @see #b(EventLoop) 088 */ 089 public Trigger b() { 090 return b(getScheduler().getDefaultEventLoop()); 091 } 092 093 /** 094 * Constructs a Trigger instance around the B button's digital signal. 095 * 096 * @param loop the event loop instance to attach the event to. 097 * @return a Trigger instance representing the B button's digital signal attached 098 * to the given loop. 099 */ 100 public Trigger b(EventLoop loop) { 101 return button(StadiaController.Button.kB.value, loop); 102 } 103 104 /** 105 * Constructs a Trigger instance around the X button's digital signal. 106 * 107 * @return a Trigger instance representing the X button's digital signal attached 108 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 109 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 110 * default scheduler} if a scheduler was not explicitly provided. 111 * @see #x(EventLoop) 112 */ 113 public Trigger x() { 114 return x(getScheduler().getDefaultEventLoop()); 115 } 116 117 /** 118 * Constructs a Trigger instance around the X button's digital signal. 119 * 120 * @param loop the event loop instance to attach the event to. 121 * @return a Trigger instance representing the X button's digital signal attached 122 * to the given loop. 123 */ 124 public Trigger x(EventLoop loop) { 125 return button(StadiaController.Button.kX.value, loop); 126 } 127 128 /** 129 * Constructs a Trigger instance around the Y button's digital signal. 130 * 131 * @return a Trigger instance representing the Y button's digital signal attached 132 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 133 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 134 * default scheduler} if a scheduler was not explicitly provided. 135 * @see #y(EventLoop) 136 */ 137 public Trigger y() { 138 return y(getScheduler().getDefaultEventLoop()); 139 } 140 141 /** 142 * Constructs a Trigger instance around the Y button's digital signal. 143 * 144 * @param loop the event loop instance to attach the event to. 145 * @return a Trigger instance representing the Y button's digital signal attached 146 * to the given loop. 147 */ 148 public Trigger y(EventLoop loop) { 149 return button(StadiaController.Button.kY.value, loop); 150 } 151 152 /** 153 * Constructs a Trigger instance around the left bumper button's digital signal. 154 * 155 * @return a Trigger instance representing the left bumper button's digital signal attached 156 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 157 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 158 * default scheduler} if a scheduler was not explicitly provided. 159 * @see #leftBumper(EventLoop) 160 */ 161 public Trigger leftBumper() { 162 return leftBumper(getScheduler().getDefaultEventLoop()); 163 } 164 165 /** 166 * Constructs a Trigger instance around the left bumper button's digital signal. 167 * 168 * @param loop the event loop instance to attach the event to. 169 * @return a Trigger instance representing the left bumper button's digital signal attached 170 * to the given loop. 171 */ 172 public Trigger leftBumper(EventLoop loop) { 173 return button(StadiaController.Button.kLeftBumper.value, loop); 174 } 175 176 /** 177 * Constructs a Trigger instance around the right bumper button's digital signal. 178 * 179 * @return a Trigger instance representing the right bumper button's digital signal attached 180 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 181 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 182 * default scheduler} if a scheduler was not explicitly provided. 183 * @see #rightBumper(EventLoop) 184 */ 185 public Trigger rightBumper() { 186 return rightBumper(getScheduler().getDefaultEventLoop()); 187 } 188 189 /** 190 * Constructs a Trigger instance around the right bumper button's digital signal. 191 * 192 * @param loop the event loop instance to attach the event to. 193 * @return a Trigger instance representing the right bumper button's digital signal attached 194 * to the given loop. 195 */ 196 public Trigger rightBumper(EventLoop loop) { 197 return button(StadiaController.Button.kRightBumper.value, loop); 198 } 199 200 /** 201 * Constructs a Trigger instance around the left stick button's digital signal. 202 * 203 * @return a Trigger instance representing the left stick button's digital signal attached 204 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 205 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 206 * default scheduler} if a scheduler was not explicitly provided. 207 * @see #leftStick(EventLoop) 208 */ 209 public Trigger leftStick() { 210 return leftStick(getScheduler().getDefaultEventLoop()); 211 } 212 213 /** 214 * Constructs a Trigger instance around the left stick button's digital signal. 215 * 216 * @param loop the event loop instance to attach the event to. 217 * @return a Trigger instance representing the left stick button's digital signal attached 218 * to the given loop. 219 */ 220 public Trigger leftStick(EventLoop loop) { 221 return button(StadiaController.Button.kLeftStick.value, loop); 222 } 223 224 /** 225 * Constructs a Trigger instance around the right stick button's digital signal. 226 * 227 * @return a Trigger instance representing the right stick button's digital signal attached 228 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 229 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 230 * default scheduler} if a scheduler was not explicitly provided. 231 * @see #rightStick(EventLoop) 232 */ 233 public Trigger rightStick() { 234 return rightStick(getScheduler().getDefaultEventLoop()); 235 } 236 237 /** 238 * Constructs a Trigger instance around the right stick button's digital signal. 239 * 240 * @param loop the event loop instance to attach the event to. 241 * @return a Trigger instance representing the right stick button's digital signal attached 242 * to the given loop. 243 */ 244 public Trigger rightStick(EventLoop loop) { 245 return button(StadiaController.Button.kRightStick.value, loop); 246 } 247 248 /** 249 * Constructs a Trigger instance around the ellipses button's digital signal. 250 * 251 * @return a Trigger instance representing the ellipses button's digital signal attached 252 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 253 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 254 * default scheduler} if a scheduler was not explicitly provided. 255 * @see #ellipses(EventLoop) 256 */ 257 public Trigger ellipses() { 258 return ellipses(getScheduler().getDefaultEventLoop()); 259 } 260 261 /** 262 * Constructs a Trigger instance around the ellipses button's digital signal. 263 * 264 * @param loop the event loop instance to attach the event to. 265 * @return a Trigger instance representing the ellipses button's digital signal attached 266 * to the given loop. 267 */ 268 public Trigger ellipses(EventLoop loop) { 269 return button(StadiaController.Button.kEllipses.value, loop); 270 } 271 272 /** 273 * Constructs a Trigger instance around the hamburger button's digital signal. 274 * 275 * @return a Trigger instance representing the hamburger button's digital signal attached 276 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 277 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 278 * default scheduler} if a scheduler was not explicitly provided. 279 * @see #hamburger(EventLoop) 280 */ 281 public Trigger hamburger() { 282 return hamburger(getScheduler().getDefaultEventLoop()); 283 } 284 285 /** 286 * Constructs a Trigger instance around the hamburger button's digital signal. 287 * 288 * @param loop the event loop instance to attach the event to. 289 * @return a Trigger instance representing the hamburger button's digital signal attached 290 * to the given loop. 291 */ 292 public Trigger hamburger(EventLoop loop) { 293 return button(StadiaController.Button.kHamburger.value, loop); 294 } 295 296 /** 297 * Constructs a Trigger instance around the stadia button's digital signal. 298 * 299 * @return a Trigger instance representing the stadia button's digital signal attached 300 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 301 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 302 * default scheduler} if a scheduler was not explicitly provided. 303 * @see #stadia(EventLoop) 304 */ 305 public Trigger stadia() { 306 return stadia(getScheduler().getDefaultEventLoop()); 307 } 308 309 /** 310 * Constructs a Trigger instance around the stadia button's digital signal. 311 * 312 * @param loop the event loop instance to attach the event to. 313 * @return a Trigger instance representing the stadia button's digital signal attached 314 * to the given loop. 315 */ 316 public Trigger stadia(EventLoop loop) { 317 return button(StadiaController.Button.kStadia.value, loop); 318 } 319 320 /** 321 * Constructs a Trigger instance around the right trigger button's digital signal. 322 * 323 * @return a Trigger instance representing the right trigger button's digital signal attached 324 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 325 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 326 * default scheduler} if a scheduler was not explicitly provided. 327 * @see #rightTrigger(EventLoop) 328 */ 329 public Trigger rightTrigger() { 330 return rightTrigger(getScheduler().getDefaultEventLoop()); 331 } 332 333 /** 334 * Constructs a Trigger instance around the right trigger button's digital signal. 335 * 336 * @param loop the event loop instance to attach the event to. 337 * @return a Trigger instance representing the right trigger button's digital signal attached 338 * to the given loop. 339 */ 340 public Trigger rightTrigger(EventLoop loop) { 341 return button(StadiaController.Button.kRightTrigger.value, loop); 342 } 343 344 /** 345 * Constructs a Trigger instance around the left trigger button's digital signal. 346 * 347 * @return a Trigger instance representing the left trigger button's digital signal attached 348 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 349 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 350 * default scheduler} if a scheduler was not explicitly provided. 351 * @see #leftTrigger(EventLoop) 352 */ 353 public Trigger leftTrigger() { 354 return leftTrigger(getScheduler().getDefaultEventLoop()); 355 } 356 357 /** 358 * Constructs a Trigger instance around the left trigger button's digital signal. 359 * 360 * @param loop the event loop instance to attach the event to. 361 * @return a Trigger instance representing the left trigger button's digital signal attached 362 * to the given loop. 363 */ 364 public Trigger leftTrigger(EventLoop loop) { 365 return button(StadiaController.Button.kLeftTrigger.value, loop); 366 } 367 368 /** 369 * Constructs a Trigger instance around the google button's digital signal. 370 * 371 * @return a Trigger instance representing the google button's digital signal attached 372 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 373 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 374 * default scheduler} if a scheduler was not explicitly provided. 375 * @see #google(EventLoop) 376 */ 377 public Trigger google() { 378 return google(getScheduler().getDefaultEventLoop()); 379 } 380 381 /** 382 * Constructs a Trigger instance around the google button's digital signal. 383 * 384 * @param loop the event loop instance to attach the event to. 385 * @return a Trigger instance representing the google button's digital signal attached 386 * to the given loop. 387 */ 388 public Trigger google(EventLoop loop) { 389 return button(StadiaController.Button.kGoogle.value, loop); 390 } 391 392 /** 393 * Constructs a Trigger instance around the frame button's digital signal. 394 * 395 * @return a Trigger instance representing the frame button's digital signal attached 396 * to the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the 397 * scheduler passed to the controller's constructor, or the {@link Scheduler#getDefault 398 * default scheduler} if a scheduler was not explicitly provided. 399 * @see #frame(EventLoop) 400 */ 401 public Trigger frame() { 402 return frame(getScheduler().getDefaultEventLoop()); 403 } 404 405 /** 406 * Constructs a Trigger instance around the frame button's digital signal. 407 * 408 * @param loop the event loop instance to attach the event to. 409 * @return a Trigger instance representing the frame button's digital signal attached 410 * to the given loop. 411 */ 412 public Trigger frame(EventLoop loop) { 413 return button(StadiaController.Button.kFrame.value, loop); 414 } 415 416 /** 417 * Get the X axis value of left side of the controller. Right is positive. 418 * 419 * @return The axis value. 420 */ 421 public double getLeftX() { 422 return m_hid.getLeftX(); 423 } 424 425 /** 426 * Get the X axis value of right side of the controller. Right is positive. 427 * 428 * @return The axis value. 429 */ 430 public double getRightX() { 431 return m_hid.getRightX(); 432 } 433 434 /** 435 * Get the Y axis value of left side of the controller. Back is positive. 436 * 437 * @return The axis value. 438 */ 439 public double getLeftY() { 440 return m_hid.getLeftY(); 441 } 442 443 /** 444 * Get the Y axis value of right side of the controller. Back is positive. 445 * 446 * @return The axis value. 447 */ 448 public double getRightY() { 449 return m_hid.getRightY(); 450 } 451}