[wpilib] Remove UserControls (#8973)

It was too complex, and we can solve it by figuring out how to make
singleton GenericHID objects, implemented in #8970.
This commit is contained in:
Thad House
2026-06-11 15:33:51 -07:00
committed by GitHub
parent c647e67de0
commit 025732093f
10 changed files with 55 additions and 267 deletions

View File

@@ -4,27 +4,28 @@
package org.wpilib.examples.expansionhubsample;
import org.wpilib.driverstation.DefaultUserControls;
import org.wpilib.driverstation.DriverStation;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.opmode.PeriodicOpMode;
import org.wpilib.opmode.Teleop;
@Teleop
public class DefaultTeleMode extends PeriodicOpMode {
private final Robot robot;
private final DefaultUserControls userControls;
private final Gamepad gamepad;
public DefaultTeleMode(Robot robot, DefaultUserControls userControls) {
public DefaultTeleMode(Robot robot) {
this.robot = robot;
this.userControls = userControls;
this.gamepad = DriverStation.getGamepad(0);
}
@Override
public void periodic() {
robot.motor0.setThrottle(-userControls.getGamepad(0).getLeftY());
robot.motor1.setThrottle(-userControls.getGamepad(0).getRightY());
robot.motor2.setThrottle(-userControls.getGamepad(0).getLeftX());
robot.motor3.setThrottle(-userControls.getGamepad(0).getRightX());
robot.servo0.setPosition(userControls.getGamepad(0).getLeftTriggerAxis());
robot.servo1.setPosition(userControls.getGamepad(0).getRightTriggerAxis());
robot.motor0.setThrottle(-gamepad.getLeftY());
robot.motor1.setThrottle(-gamepad.getRightY());
robot.motor2.setThrottle(-gamepad.getLeftX());
robot.motor3.setThrottle(-gamepad.getRightX());
robot.servo0.setPosition(gamepad.getLeftTriggerAxis());
robot.servo1.setPosition(gamepad.getRightTriggerAxis());
}
}

View File

@@ -4,8 +4,6 @@
package org.wpilib.examples.expansionhubsample;
import org.wpilib.driverstation.DefaultUserControls;
import org.wpilib.driverstation.UserControlsInstance;
import org.wpilib.framework.OpModeRobot;
import org.wpilib.hardware.expansionhub.ExpansionHubMotor;
import org.wpilib.hardware.expansionhub.ExpansionHubServo;
@@ -14,7 +12,6 @@ import org.wpilib.hardware.expansionhub.ExpansionHubServo;
* This is a demo program showing the use of the Expansion Hub motors and servos. The motors and
* servos are driven using the controllers in the telop opmode, and timed in the auto op mode.
*/
@UserControlsInstance(DefaultUserControls.class)
public class Robot extends OpModeRobot {
public final ExpansionHubMotor motor0 = new ExpansionHubMotor(0, 0);
public final ExpansionHubMotor motor1 = new ExpansionHubMotor(0, 1);