Joystick butons

There might be a couple things going on here. Can you please post the model joystick you are using and clear picture(s) of the joystick showing the button numbers?

Expanding on what @mshafer1 was saying, all the buttons (and axis for that matter) come out of the Joystick Get Values VI as a 1D array. In some other languages this is called a list. You can put a probe on the array if you like and see the state of all the buttons. The first element in an array (in most programming languages) is index 0. The numbering scheme on most joysticks starts with button 1. So to get the value of ‘button 1’ you need to use ‘index 0’. ‘Button 2’ would be ‘index 1’, ‘button 3’ would be ‘index 2’ and so on. If you use the Array Size function in LabVIEW, it will act more like what most people expect: if the joystick has 10 buttons and you take the Array Size of the button array, the result is 10.

But it sounds like the issue you are having is even more mixed up than that would explain. The button labels may not match up to the array indexes in any way. To figure out which button is what, you can:

  1. Probe the array coming out of the Joystick Get Values VI while TeleOp is enabled and press and hold the button of interest. You should see somewhere in the array one of the indicators indicate true. If you increment the index in the probe until the ‘true’ is at the top, that will tell you the correct index you want for that button.

  2. Open the Driver Station and go to the USB Devices tab on the left. Make sure you have the correct joystick selected. Press and hold the button you are interested in. You will see a light light up under the Buttons section. The top left rectangle is index 0, the next one down is index 1 and so on.

1 Like