Where can I find the Xbox controller button mapping for Java?

Our team switched from labview to java. Where can I find a picture of an Xbox controller that shows the button numbers and axis numbers for Java? Thanks!

1 Like

You can use the XboxController class and access joysticks and buttons using methods such as getY(Hand), getAButtonPressed(), etc. Hand refers to the side of the controller, so Hand.kLeft will be the left side and Hand.kRight will be the right side. Hand is a parameter for any input that is on both sides of the controller, such as joystick axes and triggers, and bumpers.

2 Likes

If you are using vscode… and you are using the XboxController class… In the java file where you declare xbox variable right click on XboxController. Click on Go to definition and it will show you how the class is implemented. You can see a private enum inside the class that shows the button mappings.

Thanks for the help! Much appreciated!

You can probably just connect your controller to your computer while drive station is open, then check which buttons/axis are currently being pressed.

Search for usb game controllers in the start menu and open that. Then select the controller you want and click properties. When you press a button on the controller the corresponding number will light up. For axises go on the driver station and look under the controller tab.