Package com.crossbotics.ftchelper.teleop
Class Key
java.lang.Object
com.crossbotics.ftchelper.teleop.Key
- Direct Known Subclasses:
Pad.Button
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 Summary
ConstructorsModifierConstructorDescriptionprotectedKey(ControllerBindings.Pad pad, ControllerBindings.Btn btn, ControllerBindings.Trigger trigger) A button (triggernull) or a trigger (btnnull) on one gamepad. -
Method Summary
Modifier and TypeMethodDescriptionfinal ControllerBindings.Btnbtn()The button, or null for a trigger.final booleanstatic Keyg1(ControllerBindings.Btn btn) A button on gamepad 1, e.g.static Keyg1(ControllerBindings.Trigger trigger) A trigger on gamepad 1, e.g.static Keyg2(ControllerBindings.Btn btn) A button on gamepad 2.static Keyg2(ControllerBindings.Trigger trigger) A trigger on gamepad 2.final inthashCode()final booleanisDown(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.final booleanTrue for LT or RT.final Stringname()The button's name as the button map writes it: "BACK", "LT", "D-pad up", "left stick click".final KeyonPad(ControllerBindings.Pad other) The same button on the other gamepad's place:onPad(G1)of G2 X is G1 X.final ControllerBindings.Padpad()Which gamepad.final doublepull(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.toString()"G1 BACK".trigger()The trigger, or null for a button.
-
Constructor Details
-
Key
protected Key(ControllerBindings.Pad pad, ControllerBindings.Btn btn, ControllerBindings.Trigger trigger) A button (triggernull) or a trigger (btnnull) on one gamepad. Useg1(Btn)and friends instead; this is for the library's own buttons in Controls.java.
-
-
Method Details
-
g1
A button on gamepad 1, e.g.Key.g1(Btn.BACK). -
g2
A button on gamepad 2. -
g1
A trigger on gamepad 1, e.g.Key.g1(Trigger.LT). -
g2
A trigger on gamepad 2. -
pad
Which gamepad. -
btn
The button, or null for a 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
The button's name as the button map writes it: "BACK", "LT", "D-pad up", "left stick click". -
onPad
The same button on the other gamepad's place:onPad(G1)of G2 X is G1 X. -
toString
"G1 BACK". -
equals
-
hashCode
public final int hashCode()
-