java.lang.Object
com.crossbotics.ftchelper.teleop.Key
Direct Known Subclasses:
Pad.Button

public class Key extends Object
One button or trigger on one gamepad, e.g. gamepad 1's BACK. LibraryButtons uses it to say where each of the library's own jobs goes (pause, slow, field-centric...).

 lib.fieldCentric(Key.g1(Btn.X));        // field-centric on/off moves to gamepad 1 X
 lib.slow(Key.g1(Trigger.RT));           // slow on the right trigger
 

In Controls.java you do not need this class: write the button the usual way, lib.fieldCentric(g1.x) (each button there is a Key too).

Two Keys are equal when they are the same button on the same gamepad. Docs: docs/modules/teleop.md (section "Moving the library's buttons"), docs/guides/buttons.md

  • Constructor Details

  • Method Details

    • g1

      public static Key g1(ControllerBindings.Btn btn)
      A button on gamepad 1, e.g. Key.g1(Btn.BACK).
    • g2

      public static Key g2(ControllerBindings.Btn btn)
      A button on gamepad 2.
    • g1

      public static Key g1(ControllerBindings.Trigger trigger)
      A trigger on gamepad 1, e.g. Key.g1(Trigger.LT).
    • g2

      public static Key g2(ControllerBindings.Trigger trigger)
      A trigger on gamepad 2.
    • pad

      public final ControllerBindings.Pad pad()
      Which gamepad.
    • btn

      public final ControllerBindings.Btn btn()
      The button, or null for a trigger.
    • trigger

      public final ControllerBindings.Trigger trigger()
      The trigger, or null for a button.
    • isTrigger

      public final boolean isTrigger()
      True for LT or RT.
    • isDown

      public final boolean isDown(com.qualcomm.robotcore.hardware.Gamepad gamepad1, com.qualcomm.robotcore.hardware.Gamepad gamepad2)
      True while it is down: a button pressed, a trigger pulled past half way. False if that gamepad is missing (null).
    • pull

      public final double pull(com.qualcomm.robotcore.hardware.Gamepad gamepad1, com.qualcomm.robotcore.hardware.Gamepad gamepad2)
      How far it is pressed, 0 to 1: a trigger's pull, or 0/1 for a button. 0 with no gamepad.
    • name

      public final String name()
      The button's name as the button map writes it: "BACK", "LT", "D-pad up", "left stick click".
    • onPad

      public final Key onPad(ControllerBindings.Pad other)
      The same button on the other gamepad's place: onPad(G1) of G2 X is G1 X.
    • toString

      public String toString()
      "G1 BACK".
      Overrides:
      toString in class Object
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object