From 5817da8c10b4a34bea3d2e599879ce47e5996631 Mon Sep 17 00:00:00 2001 From: Lucas Bubner Date: Wed, 11 Dec 2024 10:11:43 +1030 Subject: [PATCH] `gp` bindings --- .../bunyipslib/CommandBasedBunyipsOpMode.java | 38 ++++++++++++++----- .../studentrobotics/bunyipslib/Scheduler.kt | 28 ++++++++++---- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/main/java/au/edu/sa/mbhs/studentrobotics/bunyipslib/CommandBasedBunyipsOpMode.java b/src/main/java/au/edu/sa/mbhs/studentrobotics/bunyipslib/CommandBasedBunyipsOpMode.java index 7eb3b67ad..98d8f7c99 100644 --- a/src/main/java/au/edu/sa/mbhs/studentrobotics/bunyipslib/CommandBasedBunyipsOpMode.java +++ b/src/main/java/au/edu/sa/mbhs/studentrobotics/bunyipslib/CommandBasedBunyipsOpMode.java @@ -36,14 +36,14 @@ public abstract class CommandBasedBunyipsOpMode extends BunyipsOpMode { private HashSet managedSubsystems = new HashSet<>(); /** - * 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 {@code `when`} * (see here), * 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") @@ -52,10 +52,10 @@ 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) { @@ -63,9 +63,9 @@ public Scheduler.ControllerTriggerCreator on(@NonNull Controller 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() { @@ -73,15 +73,35 @@ public Scheduler.ControllerTriggerCreator 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. @@ -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() { } diff --git a/src/main/java/au/edu/sa/mbhs/studentrobotics/bunyipslib/Scheduler.kt b/src/main/java/au/edu/sa/mbhs/studentrobotics/bunyipslib/Scheduler.kt index 3b17a7211..e39c2c50a 100644 --- a/src/main/java/au/edu/sa/mbhs/studentrobotics/bunyipslib/Scheduler.kt +++ b/src/main/java/au/edu/sa/mbhs/studentrobotics/bunyipslib/Scheduler.kt @@ -192,14 +192,14 @@ 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 { @@ -207,7 +207,7 @@ class Scheduler : BunyipsComponent() { } /** - * 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. @@ -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.