Class Pad.Button

java.lang.Object
com.crossbotics.ftchelper.teleop.Key
com.crossbotics.ftchelper.robot.Pad.Button
Enclosing class:
Pad

public static final class Pad.Button extends Key
One button or trigger. Each method gives it a job and hands the button back. It is a Key too, so lib.pause(g1.a) can move a library job onto it.
  • Method Details

    • toString

      public String toString()
      "G2 RT".
      Overrides:
      toString in class Key
    • press

      public Pad.Button press(Runnable onPress)
      Runs onPress once each time it is pressed.
    • press

      public Pad.Button press(Action action)
      Starts the action; pressing again while it runs cancels it.
    • tapOrDoubleTap

      public Pad.Button tapOrDoubleTap(Runnable tap, Runnable doubleTap)
      One tap runs tap; a second tap soon after (within Pad.DOUBLE_TAP_SEC) runs doubleTap instead. The first tap of a double-tap has already run tap, so make the two work together, e.g. tap = intake on/off, double-tap = push out.
    • release

      public Pad.Button release(Runnable onRelease)
      Runs onRelease once each time it is let go.
    • hold

      public Pad.Button hold(Runnable whileHeld)
      Runs whileHeld every loop while it is held. Alone it starts at once; with other gestures on the same button (tap, double-tap...) it starts once the press lasts Tunables.Buttons.holdSec (0.3 s), so a quick tap stays a tap.
    • hold

      public Pad.Button hold(Runnable whileHeld, Runnable onRelease)
      hold(Runnable), and onRelease once when it is let go.
    • tap

      public Pad.Button tap(Runnable job)
      A quick tap (press and let go) runs job. It runs at once when pressed, unless the button also has a longer gesture (hold, double-tap...): then it runs as soon as that can no longer happen (when let go, or Tunables.Buttons.tapGapSec later).
    • tap

      public Pad.Button tap(Action action)
      tap(Runnable) with an action (a tap again while it runs cancels it).
    • doubleTap

      public Pad.Button doubleTap(Runnable job)
      Two quick taps run job (the first tap alone runs the tap job, if any).
    • doubleTap

      public Pad.Button doubleTap(Action action)
      doubleTap(Runnable) with an action.
    • taps

      public Pad.Button taps(int n, Runnable job)
      n quick taps in a row (2 to 5) run job, e.g. 3 taps = intake backward.
    • taps

      public Pad.Button taps(int n, Action action)
      taps(int, Runnable) with an action.
    • tapThenHold

      public Pad.Button tapThenHold(Runnable whileHeld)
      A quick tap, then press again and hold: whileHeld runs every loop while held (last season's "spray": tap, then hold fire).
    • tapThenHold

      public Pad.Button tapThenHold(Runnable whileHeld, Runnable onRelease)
      tapThenHold(Runnable), and onRelease once when it is let go.
    • heldFor

      public Pad.Button heldFor(double seconds, Runnable job)
      Held down for seconds: job runs once (a safe "are you sure?" for big moves, like re-homing a lift). Let go sooner and nothing happens (or the tap job runs).
    • heldFor

      public Pad.Button heldFor(double seconds, Action action)
    • with

      public Pad.Button with(Pad.Button other, Runnable job)
      A pair: hold this button (the "shift key"), then press other to run job. The shift key gets no job of its own; other keeps its own job when pressed alone. Both on the same gamepad.
    • with

      public Pad.Button with(Pad.Button other, Action action)
      with(Button, Runnable) with an action.
    • rumble

      public Pad.Button rumble()
      Feedback: the gamepad buzzes when this job runs (a hold: when it starts). On a toggle: two buzzes = on, one = off. After a gesture, it is for that gesture.
    • rumble

      public Pad.Button rumble(int buzzes)
      rumble() with buzzes short buzzes (1 to 3).
    • toggle

      public Pad.Button toggle(Toggleable part)
      Each press switches the part (an intake, a launcher, a claw, a mode) on or off.
    • toggle

      public Pad.Button toggle(Runnable onEnable, Runnable onDisable)
      Each press flips between running onEnable and onDisable.
    • slow

      public Pad.Button slow()
      Slow driving, for one driver (Tunables.Drive.slowSpeed). On a trigger, e.g. g1.lt.slow(): the further it is pulled, the slower, down to slowSpeed at a full squeeze (like the two-driver LT). On a button: slow while it is held. (With two drivers, G1 LT already does this; after lib.slow(null) in libraryButtons you may use it with two drivers too.)
    • free

      public Pad.Button free()
      No job: it stays free, even if a module suggested one for it. Listed as free on the help page.
    • needs

      public Pad.Button needs(Module<?>... parts)
      This button's job needs these parts: while one of them is not on the robot (marked optional() in Robot.java and not in the configuration), the button does nothing and the button map shows "off: IntakeDeploy not on the robot". The whole button (all its gestures). A part's own buttons and toggle(Toggleable) know their part already.
      
       g1.x.press(Actions.deployIntake(robot)).says("deploy intake").needs(robot.intakeDeploy);
       
      Parameters:
      parts - one or more parts from Robot.java
      Returns:
      this button
    • says

      public Pad.Button says(String words)
      Words for the help page, e.g. .says("score high"). After a gesture, for that gesture.