USB input controller how to.

How would you program a usb controller into labview. I know which vi’s to use, but I don’t know which values the usb is in the driver’s station.:confused:

It isn’t clear what it is you are attempting to do. I think you are trying to read a joystick on the PC. In that case, you will be using the Input Device Control VIs. I think the primary question is how to use the device number input.

This number is determined by the OS when the OS discovers the devices plugged into the USB bus. If devices are plugged in when you run your program, you can often hard code the number, but this will not travel well to other computers, and will have issues when the joysticks are plugged in after running, etc.

The way to use this is to run the VI Query Input Devices. For fun, you can open and run it interactive. It will produce an array of info about the joysticks and other devices. This will sometimes be surprising as laptops will often list a joystick even when one isn’t plugged in. This is because they can have an HID device that is actually a specialized joystick, or they can have a BT bridge device that supports both mouse and a joystick. The joystick may not be there at the moment, but since it can show up when BT is ready, they declare it early.

Anyway, the device index to use is the index into the array returned by the Query call. If doing this interactively, you may want to list the items into a listbox and let the user select from the joysticks. More likely, you want to search the array for the device name looking for the mfg name you expect in the array.

If I’m way off on what you are asking, please try again.

Greg McKaskle

Actually, I think he’s trying to deal with a Joystick attached to the DS. If this is the case, you simply use the Open Joystick, and Get Axis VIs provided with WPILib. You feed it the USB port its plugged into on the DS (USB1-4), and the Axis off the joystick (i believe its Axis 1 = X, Axis 2 = Y).

Is anyone trying to connect a USB keypad/numpad to the DriverStation? I picked up a Targus two port numeric keypad and we are not getting much info from it. We are programming in C/C++ and tried getting raw button data (as if it were a joystick) and weren’t able to read anything. Although as we typed on the keypad, it did make strange characters appear on the DriverStation.

If anyone has any info on connecting something like this, I’d certainly appreciate a few clues.


The first issue is: does the Linux system that is running on the driver station recognize the controller. If it has a driver that recognizes the controller, then you need to figure out how the system has mapped that interface to the joystick buttons. I’d hook up a hyperterminal to the serial port, put a loop in the C code print all the button values, and see if you’re getting anything.

I attached a Microsoft USB steering wheel and it recognized it although the centering didn’t work. Note that in this case the device is pretty similar to a joystick.

The usb device has to be HID compliant. That means if you plug it onto a Windows or MAC or Linux system and it works without needing to install drivers it will most likely work on the DS.

I have a SNES controller that i turned into a USB joystick with an AVR microcontroller, which is now a low speed usb 1.0 HID joystick, which i am just itching to try with the DS.

Very cool!

Sounds like the perfect topic for a white paper. I inherited some code to turn a PIC18 (or was it 16?) into an HID joystick. I just don’t have the time right now to polish it for release.

A numeric keypad is not going to work with the DS. A numeric keypad will appear like a keyboard to the DS, not a joystick. Those who have suggested that an HID-compliant device will work are only half correct. It needs to be an HID-compliant game controller device.

The strange characters you are seeing on the DS are likely because you are typing on the keyboard and sending those keystrokes to the Linux terminal in which the DS program is running.

Thanks. Nah, no need for a white paper. I just copied this project:

Just use google translate to read it (unless you know German). It was a fun 1 day project. I already had the AVR programmer, and the chip because i had already made the USB Capslocker . It was basically the same parts list and practically the same code too.

Also, for anyone interested here are some other USB AVR projects.

here is the AVR programmer i used:

also, I’ve been trying to complete the PPM RC to USB joystick, however i haven’t had any luck in figuring out the fuses need for the chip. I wanted to use the VEX (PPM RC) controller and hook the radio and crystal to the chip. I thought it be pretty cool to use on an Open Source flight simulator with a VEX controller.

edit: I might try to whitepaper it after I’ve verified it will work with the DS. I’m about 98% sure it will work though.

Thanks Dave, what you’ve described is kinda what I thought. I hoped it might be a quick way to add lots of inputs and thought it was worth a try. Anyhow, thanks again.