Hello everyone,
We are a rookie team, and though I have mentored before, I never got a chance to work with Xbox controllers before. I’m managed to find some sample codes here and there, but I’ve never found a sample code that used the XboxController library. Any reason as to why the Joystick class is used over the XboxController class? Does it not work properly? I just don’t want to set up the team to fail for any hidden reason that we never discover, God forbid, we learn the hard way during the middle of a match.
Regards,
The XboxController class is new this year in wpilib, so most FRC example code will be written with the API that does not include it. If you look at the source code for the XboxController class (at C:\Users(your user)\wpilib\java\current\lib\WPILib-sources\edu\wpi\first\wpilibj), you can see that it boils down to getRawAxis() and getRawButton() calls in GamepadBase, but does the figuring out of which controller button corresponds to which index for you.
For example, the method getAButton() literally just returns getRawButton(1).
Note: I assume it works the same way in C++, as I only checked the java source code.
The XboxController class is new this year. That is probably why you cannot find many code examples. Although both will work, if you are using a Xbox controller use the XboxController class. It has methods like getY(Hand) that will make your code easier to read in the long run.
Thank you both Austin and Bradley. That makes much more sense. I though I was going crazy.