Joystick butons

When we program joysitck button 6 to turn a motor on, we end up having to use button # 10 on the joystick. Any ideas how to define the button numbers in labview?

@ahudson You can select which button to use from the array that comes out of the Joystick Get Values VI:

30%20PM

The same applies to the Axis and POV indexes.

We have numbers there, but we assign button 6 to do a task, and instead we have to press button 8 to do it and assign button 7 to do a task and have to press button 1 to do it. We do not know how to make the button we assign be the button that does it.

Button numbers are tricky (they don’t necessarily correspond to the number printed on the joystick - and this is for all languages), if you open the driver station, go to the usb tab, and select the joystick you want, you can see the axis and buttons indicators (for determining what index the button you want it at, count from zero at the top down to the desired one).

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

We always use second option with dashboard. I think it’s just simple stupid C: Nice answer

@xszym I think I understand what you said but the screenshot shows the Driver Station software, not the Dashboard. There is a difference. Teams can customize the dashboard but not the Driver Station.

You right, my mistake. I meant Driver Station.

One time we also use website to check joypad. You can check it:
https://html5gamepad.com

Regards

1 Like