Xbox Controller Buttons are not Working

We, are having trouble with button mapping commands. For some reason, using the JoystickButton methods to run a command does not work (Note: we are using Java); however, when we map the commands to a joystick or trigger, the command works just fine. We have never had an issue like this, and it has come to our attention that some of then libraries have been updated. We have updated the libraries to the newest version but we are still having the same issue. Are we using the wrong library? Has anyone had this issue? If so please let us know, help would be greatly appreciated!

Please post your code, preferably to GitHub

First check that it is not your actual joystick problem. Look at driver station to see that the button presses are actually being read by the computer. Then I would add a simple button code that will print onto console whether or not the button is being read by code. If these two come out fine, then there is some kind of problem with how you wrote that button mapping.

Here is our code;

Best I can tell, you are never calling the scheduler. So your button inputs are never going to be polled, nor your command’s executed.

This is probably because you tried to take the old Command Based Framework Template, and use the new Command Based Framework inside it.

But here is what the RobotPeriodic looks like in our Code:

   * This function is called every robot packet, no matter the mode. Use this for items like
   * diagnostics that you want ran during disabled, autonomous, teleoperated and test.
   * <p>This runs after the mode specific periodic functions, but before
   * LiveWindow and SmartDashboard integrated updating.
  public void robotPeriodic() {
    // Runs the Scheduler.  This is responsible for polling buttons, adding newly-scheduled
    // commands, running already-scheduled commands, removing finished or interrupted commands,
    // and running subsystem periodic() methods.  This must be called from the robot's periodic
    // block in order for anything in the Command-based framework to work.

and the import for the CommandScheduler is

import edu.wpi.first.wpilibj2.command.CommandScheduler;

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.