Skip to content

Commit

Permalink
gp bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
bubner committed Dec 10, 2024
1 parent 3203c27 commit 5817da8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public abstract class CommandBasedBunyipsOpMode extends BunyipsOpMode {
private HashSet<BunyipsSubsystem> managedSubsystems = new HashSet<>();

/**
* Create a new controller button trigger creator.
* Create a new controller trigger creator.
* <p>
* For Kotlin users, calling this method can be done with the notation {@code `when`}
* (see <a href="https://kotlinlang.org/docs/java-interop.html#escaping-for-java-identifiers-that-are-keywords-in-kotlin">here</a>),
* or by calling the alias {@code on}.
*
* @param user The Controller instance to use.
* @return The controller button trigger creator.
* @return The controller trigger creator.
*/
@NonNull
@SuppressLint("NoHardKeywords")
Expand All @@ -52,36 +52,56 @@ public Scheduler.ControllerTriggerCreator when(@NonNull Controller user) {
}

/**
* Create a new controller button trigger creator.
* Create a new controller trigger creator.
*
* @param user The Controller instance to use.
* @return The controller button trigger creator.
* @return The controller trigger creator.
*/
@NonNull
public Scheduler.ControllerTriggerCreator on(@NonNull Controller user) {
return scheduler.when(user);
}

/**
* Create a new controller button trigger creator for the driver.
* Create a new controller trigger creator for the driver (gamepad 1).
*
* @return The controller button trigger creator.
* @return The controller trigger creator.
*/
@NonNull
public Scheduler.ControllerTriggerCreator driver() {
return scheduler.driver();
}

/**
* Create a new controller button trigger creator for the operator.
* Create a new controller trigger creator for gamepad 1 (driver).
*
* @return The controller button trigger creator.
* @return The controller trigger creator.
*/
@NonNull
public Scheduler.ControllerTriggerCreator gp1() {
return scheduler.gp1();
}

/**
* Create a new controller trigger creator for the operator (gamepad 2).
*
* @return The controller trigger creator.
*/
@NonNull
public Scheduler.ControllerTriggerCreator operator() {
return scheduler.operator();
}

/**
* Create a new controller trigger creator for gamepad 2 (operator).
*
* @return The controller trigger creator.
*/
@NonNull
public Scheduler.ControllerTriggerCreator gp2() {
return scheduler.gp2();
}

/**
* Run a task when a condition is met.
* This condition will be evaluated continuously.
Expand Down Expand Up @@ -225,7 +245,7 @@ protected final void activeLoop() {
protected abstract void assignCommands();

/**
* Override this method to run any additional activeLoop() code before the Scheduler runs.
* Override this method to run any additional {@code activeLoop()} code before the Scheduler runs.
*/
protected void periodic() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,22 @@ class Scheduler : BunyipsComponent() {
}

/**
* Create a new controller button trigger creator.
* Create a new controller trigger creator.
*
* For Kotlin users, calling this method can be done with the notation `` `when` ``
* (see [here](https://kotlinlang.org/docs/java-interop.html#escaping-for-java-identifiers-that-are-keywords-in-kotlin)),
* or by calling the alias `on`.
*
* @param user The Controller instance to use.
* @return The controller button trigger creator.
* @return The controller trigger creator.
*/
@SuppressLint("NoHardKeywords")
fun `when`(user: Controller): ControllerTriggerCreator {
return ControllerTriggerCreator(user)
}

/**
* Create a new controller button trigger creator.
* Create a new controller trigger creator.
*
* @param user The Controller instance to use.
* @return The controller button trigger creator.
Expand All @@ -217,23 +217,37 @@ class Scheduler : BunyipsComponent() {
}

/**
* Create a new controller button trigger creator for the driver.
* Create a new controller trigger creator for the driver (gamepad 1).
*
* @return The controller button trigger creator.
* @return The controller trigger creator.
*/
fun driver(): ControllerTriggerCreator {
return ControllerTriggerCreator(require(opMode).gamepad1)
}

/**
* Create a new controller button trigger creator for the operator.
* Create a new controller trigger creator for gamepad 1 (driver).
*
* @return The controller button trigger creator.
* @return The controller trigger creator.
*/
fun gp1() = driver()

/**
* Create a new controller trigger creator for the operator (gamepad 2).
*
* @return The controller trigger creator.
*/
fun operator(): ControllerTriggerCreator {
return ControllerTriggerCreator(require(opMode).gamepad2)
}

/**
* Create a new controller trigger creator for gamepad 2 (operator).
*
* @return The controller trigger creator.
*/
fun gp2() = operator()

/**
* Run a task when a condition is met.
* This condition will be evaluated continuously.
Expand Down

0 comments on commit 5817da8

Please sign in to comment.