USB Gamepad with LEDs using Leonardo

I’m trying to create a gamepad with LEDs using a Leonardo. I’ve been modifying the HID.cpp and USBAPI.h files with any examples I could find. I managed to get the gamepad working following these instructions http://www.imaginaryindustries.com/blog/?p=80, and have had a keyboard working with LEDs, using this patch: http://forum.arduino.cc/index.php?topic=173583.msg1621405#msg1621405 , but am having a heck of a time creating an HID that works. The buttons and LEDs are seen by my computer, but button presses aren’t being registered.

Does anyone know what changes need to be made for these to work? My HID.cpp and USBAPI.h files are below. Thanks.

HID_USBAPI.zip (7.75 KB)