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 005package org.wpilib.command3.button; 006 007import org.wpilib.command3.Scheduler; 008import org.wpilib.command3.Trigger; 009import org.wpilib.driverstation.Gamepad; 010import org.wpilib.event.EventLoop; 011 012/** 013 * A version of {@link Gamepad} with {@link Trigger} factories for command-based. 014 * 015 * @see Gamepad 016 */ 017@SuppressWarnings("MethodName") 018public class CommandGamepad extends CommandGenericHID { 019 private final Gamepad m_hid; 020 021 /** 022 * Construct an instance of a controller. 023 * 024 * @param port The port index on the Driver Station that the controller is plugged into. 025 */ 026 public CommandGamepad(int port) { 027 super(port); 028 m_hid = new Gamepad(port); 029 } 030 031 /** 032 * Construct an instance of a controller. 033 * 034 * @param scheduler The scheduler that should execute the triggered commands. 035 * @param port The port index on the Driver Station that the controller is plugged into. 036 */ 037 public CommandGamepad(Scheduler scheduler, int port) { 038 super(scheduler, port); 039 m_hid = new Gamepad(port); 040 } 041 042 /** 043 * Get the underlying GenericHID object. 044 * 045 * @return the wrapped GenericHID object 046 */ 047 @Override 048 public Gamepad getHID() { 049 return m_hid; 050 } 051 052 /** 053 * Constructs a Trigger instance around the South Face button's digital signal. 054 * 055 * @return a Trigger instance representing the South Face button's digital signal attached to the 056 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 057 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 058 * scheduler} if a scheduler was not explicitly provided. 059 * @see #southFace(EventLoop) 060 */ 061 public Trigger southFace() { 062 return southFace(getScheduler().getDefaultEventLoop()); 063 } 064 065 /** 066 * Constructs a Trigger instance around the South Face button's digital signal. 067 * 068 * @param loop the event loop instance to attach the event to. 069 * @return a Trigger instance representing the South Face button's digital signal attached to the 070 * given loop. 071 */ 072 public Trigger southFace(EventLoop loop) { 073 return button(Gamepad.Button.kSouthFace.value, loop); 074 } 075 076 /** 077 * Constructs a Trigger instance around the East Face button's digital signal. 078 * 079 * @return a Trigger instance representing the East Face button's digital signal attached to the 080 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 081 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 082 * scheduler} if a scheduler was not explicitly provided. 083 * @see #eastFace(EventLoop) 084 */ 085 public Trigger eastFace() { 086 return eastFace(getScheduler().getDefaultEventLoop()); 087 } 088 089 /** 090 * Constructs a Trigger instance around the East Face button's digital signal. 091 * 092 * @param loop the event loop instance to attach the event to. 093 * @return a Trigger instance representing the East Face button's digital signal attached to the 094 * given loop. 095 */ 096 public Trigger eastFace(EventLoop loop) { 097 return button(Gamepad.Button.kEastFace.value, loop); 098 } 099 100 /** 101 * Constructs a Trigger instance around the West Face button's digital signal. 102 * 103 * @return a Trigger instance representing the West Face button's digital signal attached to the 104 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 105 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 106 * scheduler} if a scheduler was not explicitly provided. 107 * @see #westFace(EventLoop) 108 */ 109 public Trigger westFace() { 110 return westFace(getScheduler().getDefaultEventLoop()); 111 } 112 113 /** 114 * Constructs a Trigger instance around the West Face button's digital signal. 115 * 116 * @param loop the event loop instance to attach the event to. 117 * @return a Trigger instance representing the West Face button's digital signal attached to the 118 * given loop. 119 */ 120 public Trigger westFace(EventLoop loop) { 121 return button(Gamepad.Button.kWestFace.value, loop); 122 } 123 124 /** 125 * Constructs a Trigger instance around the North Face button's digital signal. 126 * 127 * @return a Trigger instance representing the North Face button's digital signal attached to the 128 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 129 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 130 * scheduler} if a scheduler was not explicitly provided. 131 * @see #northFace(EventLoop) 132 */ 133 public Trigger northFace() { 134 return northFace(getScheduler().getDefaultEventLoop()); 135 } 136 137 /** 138 * Constructs a Trigger instance around the North Face button's digital signal. 139 * 140 * @param loop the event loop instance to attach the event to. 141 * @return a Trigger instance representing the North Face button's digital signal attached to the 142 * given loop. 143 */ 144 public Trigger northFace(EventLoop loop) { 145 return button(Gamepad.Button.kNorthFace.value, loop); 146 } 147 148 /** 149 * Constructs a Trigger instance around the Back button's digital signal. 150 * 151 * @return a Trigger instance representing the Back button's digital signal attached to the {@link 152 * Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler passed to 153 * the controller's constructor, or the {@link Scheduler#getDefault default scheduler} if a 154 * scheduler was not explicitly provided. 155 * @see #back(EventLoop) 156 */ 157 public Trigger back() { 158 return back(getScheduler().getDefaultEventLoop()); 159 } 160 161 /** 162 * Constructs a Trigger instance around the Back button's digital signal. 163 * 164 * @param loop the event loop instance to attach the event to. 165 * @return a Trigger instance representing the Back button's digital signal attached to the given 166 * loop. 167 */ 168 public Trigger back(EventLoop loop) { 169 return button(Gamepad.Button.kBack.value, loop); 170 } 171 172 /** 173 * Constructs a Trigger instance around the Guide button's digital signal. 174 * 175 * @return a Trigger instance representing the Guide button's digital signal attached to the 176 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 177 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 178 * scheduler} if a scheduler was not explicitly provided. 179 * @see #guide(EventLoop) 180 */ 181 public Trigger guide() { 182 return guide(getScheduler().getDefaultEventLoop()); 183 } 184 185 /** 186 * Constructs a Trigger instance around the Guide button's digital signal. 187 * 188 * @param loop the event loop instance to attach the event to. 189 * @return a Trigger instance representing the Guide button's digital signal attached to the given 190 * loop. 191 */ 192 public Trigger guide(EventLoop loop) { 193 return button(Gamepad.Button.kGuide.value, loop); 194 } 195 196 /** 197 * Constructs a Trigger instance around the Start button's digital signal. 198 * 199 * @return a Trigger instance representing the Start button's digital signal attached to the 200 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 201 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 202 * scheduler} if a scheduler was not explicitly provided. 203 * @see #start(EventLoop) 204 */ 205 public Trigger start() { 206 return start(getScheduler().getDefaultEventLoop()); 207 } 208 209 /** 210 * Constructs a Trigger instance around the Start button's digital signal. 211 * 212 * @param loop the event loop instance to attach the event to. 213 * @return a Trigger instance representing the Start button's digital signal attached to the given 214 * loop. 215 */ 216 public Trigger start(EventLoop loop) { 217 return button(Gamepad.Button.kStart.value, loop); 218 } 219 220 /** 221 * Constructs a Trigger instance around the left stick button's digital signal. 222 * 223 * @return a Trigger instance representing the left stick button's digital signal attached to the 224 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 225 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 226 * scheduler} if a scheduler was not explicitly provided. 227 * @see #leftStick(EventLoop) 228 */ 229 public Trigger leftStick() { 230 return leftStick(getScheduler().getDefaultEventLoop()); 231 } 232 233 /** 234 * Constructs a Trigger instance around the left stick button's digital signal. 235 * 236 * @param loop the event loop instance to attach the event to. 237 * @return a Trigger instance representing the left stick button's digital signal attached to the 238 * given loop. 239 */ 240 public Trigger leftStick(EventLoop loop) { 241 return button(Gamepad.Button.kLeftStick.value, loop); 242 } 243 244 /** 245 * Constructs a Trigger instance around the right stick button's digital signal. 246 * 247 * @return a Trigger instance representing the right stick button's digital signal attached to the 248 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 249 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 250 * scheduler} if a scheduler was not explicitly provided. 251 * @see #rightStick(EventLoop) 252 */ 253 public Trigger rightStick() { 254 return rightStick(getScheduler().getDefaultEventLoop()); 255 } 256 257 /** 258 * Constructs a Trigger instance around the right stick button's digital signal. 259 * 260 * @param loop the event loop instance to attach the event to. 261 * @return a Trigger instance representing the right stick button's digital signal attached to the 262 * given loop. 263 */ 264 public Trigger rightStick(EventLoop loop) { 265 return button(Gamepad.Button.kRightStick.value, loop); 266 } 267 268 /** 269 * Constructs a Trigger instance around the right bumper button's digital signal. 270 * 271 * @return a Trigger instance representing the right bumper button's digital signal attached to 272 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 273 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 274 * scheduler} if a scheduler was not explicitly provided. 275 * @see #leftBumper(EventLoop) 276 */ 277 public Trigger leftBumper() { 278 return leftBumper(getScheduler().getDefaultEventLoop()); 279 } 280 281 /** 282 * Constructs a Trigger instance around the right bumper button's digital signal. 283 * 284 * @param loop the event loop instance to attach the event to. 285 * @return a Trigger instance representing the right bumper button's digital signal attached to 286 * the given loop. 287 */ 288 public Trigger leftBumper(EventLoop loop) { 289 return button(Gamepad.Button.kLeftBumper.value, loop); 290 } 291 292 /** 293 * Constructs a Trigger instance around the right bumper button's digital signal. 294 * 295 * @return a Trigger instance representing the right bumper button's digital signal attached to 296 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 297 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 298 * scheduler} if a scheduler was not explicitly provided. 299 * @see #rightBumper(EventLoop) 300 */ 301 public Trigger rightBumper() { 302 return rightBumper(getScheduler().getDefaultEventLoop()); 303 } 304 305 /** 306 * Constructs a Trigger instance around the right bumper button's digital signal. 307 * 308 * @param loop the event loop instance to attach the event to. 309 * @return a Trigger instance representing the right bumper button's digital signal attached to 310 * the given loop. 311 */ 312 public Trigger rightBumper(EventLoop loop) { 313 return button(Gamepad.Button.kRightBumper.value, loop); 314 } 315 316 /** 317 * Constructs a Trigger instance around the D-pad up button's digital signal. 318 * 319 * @return a Trigger instance representing the D-pad up button's digital signal attached to the 320 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 321 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 322 * scheduler} if a scheduler was not explicitly provided. 323 * @see #dpadUp(EventLoop) 324 */ 325 public Trigger dpadUp() { 326 return dpadUp(getScheduler().getDefaultEventLoop()); 327 } 328 329 /** 330 * Constructs a Trigger instance around the D-pad up button's digital signal. 331 * 332 * @param loop the event loop instance to attach the event to. 333 * @return a Trigger instance representing the D-pad up button's digital signal attached to the 334 * given loop. 335 */ 336 public Trigger dpadUp(EventLoop loop) { 337 return button(Gamepad.Button.kDpadUp.value, loop); 338 } 339 340 /** 341 * Constructs a Trigger instance around the D-pad down button's digital signal. 342 * 343 * @return a Trigger instance representing the D-pad down button's digital signal attached to the 344 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 345 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 346 * scheduler} if a scheduler was not explicitly provided. 347 * @see #dpadDown(EventLoop) 348 */ 349 public Trigger dpadDown() { 350 return dpadDown(getScheduler().getDefaultEventLoop()); 351 } 352 353 /** 354 * Constructs a Trigger instance around the D-pad down button's digital signal. 355 * 356 * @param loop the event loop instance to attach the event to. 357 * @return a Trigger instance representing the D-pad down button's digital signal attached to the 358 * given loop. 359 */ 360 public Trigger dpadDown(EventLoop loop) { 361 return button(Gamepad.Button.kDpadDown.value, loop); 362 } 363 364 /** 365 * Constructs a Trigger instance around the D-pad left button's digital signal. 366 * 367 * @return a Trigger instance representing the D-pad left button's digital signal attached to the 368 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 369 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 370 * scheduler} if a scheduler was not explicitly provided. 371 * @see #dpadLeft(EventLoop) 372 */ 373 public Trigger dpadLeft() { 374 return dpadLeft(getScheduler().getDefaultEventLoop()); 375 } 376 377 /** 378 * Constructs a Trigger instance around the D-pad left button's digital signal. 379 * 380 * @param loop the event loop instance to attach the event to. 381 * @return a Trigger instance representing the D-pad left button's digital signal attached to the 382 * given loop. 383 */ 384 public Trigger dpadLeft(EventLoop loop) { 385 return button(Gamepad.Button.kDpadLeft.value, loop); 386 } 387 388 /** 389 * Constructs a Trigger instance around the D-pad right button's digital signal. 390 * 391 * @return a Trigger instance representing the D-pad right button's digital signal attached to the 392 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 393 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 394 * scheduler} if a scheduler was not explicitly provided. 395 * @see #dpadRight(EventLoop) 396 */ 397 public Trigger dpadRight() { 398 return dpadRight(getScheduler().getDefaultEventLoop()); 399 } 400 401 /** 402 * Constructs a Trigger instance around the D-pad right button's digital signal. 403 * 404 * @param loop the event loop instance to attach the event to. 405 * @return a Trigger instance representing the D-pad right button's digital signal attached to the 406 * given loop. 407 */ 408 public Trigger dpadRight(EventLoop loop) { 409 return button(Gamepad.Button.kDpadRight.value, loop); 410 } 411 412 /** 413 * Constructs a Trigger instance around the Miscellaneous 1 button's digital signal. 414 * 415 * @return a Trigger instance representing the Miscellaneous 1 button's digital signal attached to 416 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 417 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 418 * scheduler} if a scheduler was not explicitly provided. 419 * @see #misc1(EventLoop) 420 */ 421 public Trigger misc1() { 422 return misc1(getScheduler().getDefaultEventLoop()); 423 } 424 425 /** 426 * Constructs a Trigger instance around the Miscellaneous 1 button's digital signal. 427 * 428 * @param loop the event loop instance to attach the event to. 429 * @return a Trigger instance representing the Miscellaneous 1 button's digital signal attached to 430 * the given loop. 431 */ 432 public Trigger misc1(EventLoop loop) { 433 return button(Gamepad.Button.kMisc1.value, loop); 434 } 435 436 /** 437 * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. 438 * 439 * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached to 440 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 441 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 442 * scheduler} if a scheduler was not explicitly provided. 443 * @see #rightPaddle1(EventLoop) 444 */ 445 public Trigger rightPaddle1() { 446 return rightPaddle1(getScheduler().getDefaultEventLoop()); 447 } 448 449 /** 450 * Constructs a Trigger instance around the Right Paddle 1 button's digital signal. 451 * 452 * @param loop the event loop instance to attach the event to. 453 * @return a Trigger instance representing the Right Paddle 1 button's digital signal attached to 454 * the given loop. 455 */ 456 public Trigger rightPaddle1(EventLoop loop) { 457 return button(Gamepad.Button.kRightPaddle1.value, loop); 458 } 459 460 /** 461 * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. 462 * 463 * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached to 464 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 465 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 466 * scheduler} if a scheduler was not explicitly provided. 467 * @see #leftPaddle1(EventLoop) 468 */ 469 public Trigger leftPaddle1() { 470 return leftPaddle1(getScheduler().getDefaultEventLoop()); 471 } 472 473 /** 474 * Constructs a Trigger instance around the Left Paddle 1 button's digital signal. 475 * 476 * @param loop the event loop instance to attach the event to. 477 * @return a Trigger instance representing the Left Paddle 1 button's digital signal attached to 478 * the given loop. 479 */ 480 public Trigger leftPaddle1(EventLoop loop) { 481 return button(Gamepad.Button.kLeftPaddle1.value, loop); 482 } 483 484 /** 485 * Constructs a Trigger instance around the Right Paddle 2 button's digital signal. 486 * 487 * @return a Trigger instance representing the Right Paddle 2 button's digital signal attached to 488 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 489 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 490 * scheduler} if a scheduler was not explicitly provided. 491 * @see #rightPaddle2(EventLoop) 492 */ 493 public Trigger rightPaddle2() { 494 return rightPaddle2(getScheduler().getDefaultEventLoop()); 495 } 496 497 /** 498 * Constructs a Trigger instance around the Right Paddle 2 button's digital signal. 499 * 500 * @param loop the event loop instance to attach the event to. 501 * @return a Trigger instance representing the Right Paddle 2 button's digital signal attached to 502 * the given loop. 503 */ 504 public Trigger rightPaddle2(EventLoop loop) { 505 return button(Gamepad.Button.kRightPaddle2.value, loop); 506 } 507 508 /** 509 * Constructs a Trigger instance around the Left Paddle 2 button's digital signal. 510 * 511 * @return a Trigger instance representing the Left Paddle 2 button's digital signal attached to 512 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 513 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 514 * scheduler} if a scheduler was not explicitly provided. 515 * @see #leftPaddle2(EventLoop) 516 */ 517 public Trigger leftPaddle2() { 518 return leftPaddle2(getScheduler().getDefaultEventLoop()); 519 } 520 521 /** 522 * Constructs a Trigger instance around the Left Paddle 2 button's digital signal. 523 * 524 * @param loop the event loop instance to attach the event to. 525 * @return a Trigger instance representing the Left Paddle 2 button's digital signal attached to 526 * the given loop. 527 */ 528 public Trigger leftPaddle2(EventLoop loop) { 529 return button(Gamepad.Button.kLeftPaddle2.value, loop); 530 } 531 532 /** 533 * Constructs a Trigger instance around the Touchpad button's digital signal. 534 * 535 * @return a Trigger instance representing the Touchpad button's digital signal attached to the 536 * {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 537 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 538 * scheduler} if a scheduler was not explicitly provided. 539 * @see #touchpad(EventLoop) 540 */ 541 public Trigger touchpad() { 542 return touchpad(getScheduler().getDefaultEventLoop()); 543 } 544 545 /** 546 * Constructs a Trigger instance around the Touchpad button's digital signal. 547 * 548 * @param loop the event loop instance to attach the event to. 549 * @return a Trigger instance representing the Touchpad button's digital signal attached to the 550 * given loop. 551 */ 552 public Trigger touchpad(EventLoop loop) { 553 return button(Gamepad.Button.kTouchpad.value, loop); 554 } 555 556 /** 557 * Constructs a Trigger instance around the Miscellaneous 2 button's digital signal. 558 * 559 * @return a Trigger instance representing the Miscellaneous 2 button's digital signal attached to 560 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 561 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 562 * scheduler} if a scheduler was not explicitly provided. 563 * @see #misc2(EventLoop) 564 */ 565 public Trigger misc2() { 566 return misc2(getScheduler().getDefaultEventLoop()); 567 } 568 569 /** 570 * Constructs a Trigger instance around the Miscellaneous 2 button's digital signal. 571 * 572 * @param loop the event loop instance to attach the event to. 573 * @return a Trigger instance representing the Miscellaneous 2 button's digital signal attached to 574 * the given loop. 575 */ 576 public Trigger misc2(EventLoop loop) { 577 return button(Gamepad.Button.kMisc2.value, loop); 578 } 579 580 /** 581 * Constructs a Trigger instance around the Miscellaneous 3 button's digital signal. 582 * 583 * @return a Trigger instance representing the Miscellaneous 3 button's digital signal attached to 584 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 585 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 586 * scheduler} if a scheduler was not explicitly provided. 587 * @see #misc3(EventLoop) 588 */ 589 public Trigger misc3() { 590 return misc3(getScheduler().getDefaultEventLoop()); 591 } 592 593 /** 594 * Constructs a Trigger instance around the Miscellaneous 3 button's digital signal. 595 * 596 * @param loop the event loop instance to attach the event to. 597 * @return a Trigger instance representing the Miscellaneous 3 button's digital signal attached to 598 * the given loop. 599 */ 600 public Trigger misc3(EventLoop loop) { 601 return button(Gamepad.Button.kMisc3.value, loop); 602 } 603 604 /** 605 * Constructs a Trigger instance around the Miscellaneous 4 button's digital signal. 606 * 607 * @return a Trigger instance representing the Miscellaneous 4 button's digital signal attached to 608 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 609 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 610 * scheduler} if a scheduler was not explicitly provided. 611 * @see #misc4(EventLoop) 612 */ 613 public Trigger misc4() { 614 return misc4(getScheduler().getDefaultEventLoop()); 615 } 616 617 /** 618 * Constructs a Trigger instance around the Miscellaneous 4 button's digital signal. 619 * 620 * @param loop the event loop instance to attach the event to. 621 * @return a Trigger instance representing the Miscellaneous 4 button's digital signal attached to 622 * the given loop. 623 */ 624 public Trigger misc4(EventLoop loop) { 625 return button(Gamepad.Button.kMisc4.value, loop); 626 } 627 628 /** 629 * Constructs a Trigger instance around the Miscellaneous 5 button's digital signal. 630 * 631 * @return a Trigger instance representing the Miscellaneous 5 button's digital signal attached to 632 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 633 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 634 * scheduler} if a scheduler was not explicitly provided. 635 * @see #misc5(EventLoop) 636 */ 637 public Trigger misc5() { 638 return misc5(getScheduler().getDefaultEventLoop()); 639 } 640 641 /** 642 * Constructs a Trigger instance around the Miscellaneous 5 button's digital signal. 643 * 644 * @param loop the event loop instance to attach the event to. 645 * @return a Trigger instance representing the Miscellaneous 5 button's digital signal attached to 646 * the given loop. 647 */ 648 public Trigger misc5(EventLoop loop) { 649 return button(Gamepad.Button.kMisc5.value, loop); 650 } 651 652 /** 653 * Constructs a Trigger instance around the Miscellaneous 6 button's digital signal. 654 * 655 * @return a Trigger instance representing the Miscellaneous 6 button's digital signal attached to 656 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 657 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 658 * scheduler} if a scheduler was not explicitly provided. 659 * @see #misc6(EventLoop) 660 */ 661 public Trigger misc6() { 662 return misc6(getScheduler().getDefaultEventLoop()); 663 } 664 665 /** 666 * Constructs a Trigger instance around the Miscellaneous 6 button's digital signal. 667 * 668 * @param loop the event loop instance to attach the event to. 669 * @return a Trigger instance representing the Miscellaneous 6 button's digital signal attached to 670 * the given loop. 671 */ 672 public Trigger misc6(EventLoop loop) { 673 return button(Gamepad.Button.kMisc6.value, loop); 674 } 675 676 /** 677 * Constructs a Trigger instance around the axis value of the left trigger. The returned trigger 678 * will be true when the axis value is greater than {@code threshold}. 679 * 680 * @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value 681 * should be in the range [0, 1] where 0 is the unpressed state of the axis. 682 * @param loop the event loop instance to attach the Trigger to. 683 * @return a Trigger instance that is true when the left trigger's axis exceeds the provided 684 * threshold, attached to the given event loop 685 */ 686 public Trigger leftTrigger(double threshold, EventLoop loop) { 687 return axisGreaterThan(Gamepad.Axis.kLeftTrigger.value, threshold, loop); 688 } 689 690 /** 691 * Constructs a Trigger instance around the axis value of the left trigger. The returned trigger 692 * will be true when the axis value is greater than {@code threshold}. 693 * 694 * @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value 695 * should be in the range [0, 1] where 0 is the unpressed state of the axis. 696 * @return a Trigger instance that is true when the left trigger's axis exceeds the provided 697 * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler button 698 * loop}. 699 */ 700 public Trigger leftTrigger(double threshold) { 701 return leftTrigger(threshold, getScheduler().getDefaultEventLoop()); 702 } 703 704 /** 705 * Constructs a Trigger instance around the axis value of the left trigger. The returned trigger 706 * will be true when the axis value is greater than 0.5. 707 * 708 * @return a Trigger instance that is true when the left trigger's axis exceeds 0.5, attached to 709 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 710 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 711 * scheduler} if a scheduler was not explicitly provided. 712 */ 713 public Trigger leftTrigger() { 714 return leftTrigger(0.5); 715 } 716 717 /** 718 * Constructs a Trigger instance around the axis value of the right trigger. The returned trigger 719 * will be true when the axis value is greater than {@code threshold}. 720 * 721 * @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value 722 * should be in the range [0, 1] where 0 is the unpressed state of the axis. 723 * @param loop the event loop instance to attach the Trigger to. 724 * @return a Trigger instance that is true when the right trigger's axis exceeds the provided 725 * threshold, attached to the given event loop 726 */ 727 public Trigger rightTrigger(double threshold, EventLoop loop) { 728 return axisGreaterThan(Gamepad.Axis.kRightTrigger.value, threshold, loop); 729 } 730 731 /** 732 * Constructs a Trigger instance around the axis value of the right trigger. The returned trigger 733 * will be true when the axis value is greater than {@code threshold}. 734 * 735 * @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value 736 * should be in the range [0, 1] where 0 is the unpressed state of the axis. 737 * @return a Trigger instance that is true when the right trigger's axis exceeds the provided 738 * threshold, attached to the {@link Scheduler#getDefaultEventLoop() default scheduler button 739 * loop}. 740 */ 741 public Trigger rightTrigger(double threshold) { 742 return rightTrigger(threshold, getScheduler().getDefaultEventLoop()); 743 } 744 745 /** 746 * Constructs a Trigger instance around the axis value of the right trigger. The returned trigger 747 * will be true when the axis value is greater than 0.5. 748 * 749 * @return a Trigger instance that is true when the right trigger's axis exceeds 0.5, attached to 750 * the {@link Scheduler#getDefaultEventLoop() default scheduler event loop} on the scheduler 751 * passed to the controller's constructor, or the {@link Scheduler#getDefault default 752 * scheduler} if a scheduler was not explicitly provided. 753 */ 754 public Trigger rightTrigger() { 755 return rightTrigger(0.5); 756 } 757 758 /** 759 * Get the X axis value of left side of the controller. Right is positive. 760 * 761 * @return The axis value. 762 */ 763 public double getLeftX() { 764 return m_hid.getLeftX(); 765 } 766 767 /** 768 * Get the Y axis value of left side of the controller. Back is positive. 769 * 770 * @return The axis value. 771 */ 772 public double getLeftY() { 773 return m_hid.getLeftY(); 774 } 775 776 /** 777 * Get the X axis value of right side of the controller. Right is positive. 778 * 779 * @return The axis value. 780 */ 781 public double getRightX() { 782 return m_hid.getRightX(); 783 } 784 785 /** 786 * Get the Y axis value of right side of the controller. Back is positive. 787 * 788 * @return The axis value. 789 */ 790 public double getRightY() { 791 return m_hid.getRightY(); 792 } 793 794 /** 795 * Get the left trigger axis value of the controller. Note that this axis is bound to the range of 796 * [0, 1] as opposed to the usual [-1, 1]. 797 * 798 * @return The axis value. 799 */ 800 public double getLeftTriggerAxis() { 801 return m_hid.getLeftTriggerAxis(); 802 } 803 804 /** 805 * Get the right trigger axis value of the controller. Note that this axis is bound to the range 806 * of [0, 1] as opposed to the usual [-1, 1]. 807 * 808 * @return The axis value. 809 */ 810 public double getRightTriggerAxis() { 811 return m_hid.getRightTriggerAxis(); 812 } 813}