Get joystick name and index in wpilib C++

Hi, we’re trying to figure out how to access the joystick name, or some sort of hardware identifier in wpilib from C++. Basically, we want to be able to tell the difference between the logitech joystick, and the Xbox 360 controller when the robot initializes. We plan to convert a joystick into a switch box to store settings for autonomous mode each match, and we don’t want to have to check the stick indices every time. Is there any way to get an identifier to tell which stick is shown as which index?

Also, I’m not incorrect in interpreting the rules as meaning that a box of switches set before the match during strategy talks would be fine to use because no human is touching the driver station or moving beyond the white line during autonomous mode am I?

Unless you can find a unique value to key off of (The throttle on the joystick may be an option here) there is no great way to do this. The best bet may be to use the throttle on the logitech joystick to identify it. Secure it all the way down with tape and then look for that value.

EDIT: Just re-read and realized you’re talking about harvesting the joystick internals for a custom device. The same thought applies, just tie one of the axes to 0 or 5V (or whatever the max voltage on the internal pots is) and key off of that.

Also, I’m not incorrect in interpreting the rules as meaning that a box of switches set before the match during strategy talks would be fine to use because no human is touching the driver station or moving beyond the white line during autonomous mode am I?

Nope, lots of teams use this type of technique to select autonomous modes.

Just to confirm. No information about the Vendor or Model of the joystick is ever sent to the robot. The DS displays it, but it is not part of the protocol. If your team plugs the joysticks into the same ports each time, I’d expect that you do not need to redo the ordering. Have you seen different?

To cut through the inverted inversions of the sentence. Joystick and I/O settings are sent to the robot during disabled mode and are latched during auto. A custom control box, with switches and pots is often used. If the I/O is not connected and the I/O is configured for Compatible mode, you can also make the settings directly onscreen. The Boolean and sliders can be named and their names and settings are stored to the ini file.

Greg McKaskle

I have wanted to do the same thing. It’s not using WPIlib but the way I came up with was to have a seperate program running on the driver station that asked Windows what the joysticks were and then sent this to the robot seperately from the control data.

It turned out that it’s not hard to write a program on the PC to query the joystick information but we never got around to putting together the pieces to send it to the robot because we ended up only using one joystick.