Welcome

Firmware

With everything in place hardware-wise, all I had to do is develop the firmware. Because I used an existing USB-stack, I didn't need to worry about implementing the lower USB-protocols. I still had to write the joystick HID-routines on top of that, though. Some explanation: Every USB HID-device has a so-called 'report descriptor'. This report descriptor is read by the PC and describes whe way the device will send it's data: for example, it can tell the PC that the device will first send 6 16-byte values for the 6 axes it has, then 10 bits containing the values of the various buttons, then 4 bytes of hat-switch data and finally 2 empty bits of padding. That, by the way, is the order my firmware sends its data. The avr-usb-library has support to send the HID-descriptor itself; all you need to do is define it. There's an HID-tool for that provided by the official USB-forum. It's Windows-only, but runs OK under Wine.

After the HID-report-descriptor was done, all that was left was to generate the reports themselves. That's not that difficult: just take the values of the buttons, AD-converters, etc, massage them into a format that makes sense for a gamepad and throw them at the PC.

At this moment, everything worked in Linux and I still had over 4K of flash left, so I decided to get an AVR USB-bootloader and put it in the upper 4K. I decided on taking USBaspLoader. I had to massage it a bit to fit into the 4K and for it to play nicely with the rest of the hardware in the controller, but I eventually managed it: when I plug in my controller while holding the 'back'-button, the device presents itself to the PC as an USBasp-programmer and the gamepad-firmware can be overwritten without opening up the controller.

« Prev 4 Next »


© 2006-2016 Sprite_tm - Contact