HID crafting with a PIC and a joystick

[Amr Bekhit] converted his gameport joystick to use as a USB joystick. Much like a universal USB joystick interface, this uses an additional microcontroller to talk to the serial bus while monitoring the controls on the stick. [Amr’s] discussion about creating HID descriptors is clear and easy to understand. What he’s laid out can be translated to any custom HID your heart desires. Give it a try with that old peripheral that’s been gathering dust in the corner.

Wow, this may be exactly what I have been looking for. I mooched an old gameport steering wheel and pedal set from freecycle, but the pots are clearly past their best because the values drift and jitter like crazy.

I’ve been meaning to replace them with optical encoders and Arduino-ify (sorry) but wasn’t sure how to make it appear to be a HID.

I have been working on my own usb joystick project based on this project.http://starlino.com/usb_gamepad.html
It uses the mcc18 compiler. you should be able to program it as either a mouse or a joystick. I have a problem with it right now though. I think the 100k ohm potentiometers for x and y are too high resistance for th adc of the 18f2550. I was going to add a 1458 dual op-amp as a buffer. does anyone know if this is the right way to go?

I noticed he mentioned making a 6-button joystick with the two extra switches in the front. He uses a 4-button HID descriptor, and does not mention how to add buttons to the template, only that it can be done. The switches are wired to the PIC, but the resulting HID joystick has 4-buttons.

At least the product already exists. Anyway, AFAIK, the gameport is nothing but a connector whose each pin connects directly to one of the buttons, axis and so on the joystick. Look at this: http://en.wikipedia.org/wiki/Game_port
So, if I’m not wrong, we can consider this project as DIY gameport to USB adapter.

@3L_S4N70 Not exactly. In the standard gameport, the potentiometers are used as variable resistors. I believe that originally they used to discharge capacitors that were charged by “writing” to the gameport, and it was care of the software to count the time these took to get back to a logic 0. This meant that the joysticks would drift a lot with temperature variations, and were quite inaccurate at best. this still stands true for the gameport adapters, though I suspect they use a Wheatstone bridge, with the joystick’s potentiometers as an element, to compensate somewhat. From the wiring in the picture it looks like the joystick potentiometers are set up as voltage dividers, with the wiper picking up a voltage between the extremes at the opposite ends of the potentiometer. This means that the positioning is more accurate, and less dependent on the actual value of the potentiometer itself, as long as its resistance is high enough to limit the current between the supply rails.

@Brandano Yep, I guess you are right, he uses the potentiometers as voltage dividers (directly to the ADC). Well, it’s quite disppointing that to really have an accurate system, the joystick must be taken apart and modified. Anyway, for non-analog gamepads, this project can be used to make the gameport to USB adapter.

@Mike: When I first started the project, I did not know how to modify the joystick descriptor correctly, which is why I left it at the default 4-buttons. Now that I do know, I’ll change it to 6 buttons and update the website.