Mega 2560-based USB HID controller project


Long story short, I want to make my Mega 2560 into a game controller, but unlike most projects of this kind it's not a generic HID device and I instead want to use drivers for a specific controller. I have a HID descriptor, VID and PID for the device I want to spoof and I've had some success using a Leonardo, but I don't think the hardware is appropriate for my application so I want to move over to a Mega 2560 instead.

What I'm looking for is a guide similar to this:,111.0.html and/or similar resources so I can essentially modify them with the specific descriptor and IDs I need. I've found quite a few but they're out of date now, so I'm pretty much just asking for some guidance to find something that I can use as a starting point with a 2560. Also the linked guide assumes maybe a little more knowledge than I have... Not a lot more, mind you, but even if the software he linked wasn't out of date now I'd still have no idea what "Do Tools[ch8594]Make clean" means.

I should point out that I first started this project back in 2015 but got a job early last year that sapped most of my free time, inspiration and desire to do more electronics work at home so I haven't touched it since last summer, so everything I learned about USB and all my memories of modifying Arduino files to give the Leo the new IDs... That's all pretty much gone from my brain now, sadly. In fact I've barely done any Arduino work since then so I'm a little out of the loop.


If you started with a Leonardo then moving to a Mega is a backwards step. The 16U2 chip is much less capable than a Leonardo's processor.

Look at the Teensy. A Teensy 3.2 will do all you want with no hassle reprogramming the interface chip. You can do all your programming on the main chip just like a Leonardo except the Teensy libraries are better.

The Leonardo is the Arduino version of PJRC’s Teensy 2.0 which is way smaller to fit in small spaces.
A Teensy++ 2.0 is the ‘Mega’ AVR Teensy… with more pins (fewer analog pins), 8K RAM and 2 serial ports.
The ARM Teensy’s are loads of things more but the AVR pins are more robust.

Thank you both, maybe I'll stick to the Leonardo then as I'm already quite familiar with it. While I'm aware that the 16U2 isn't as capable as the 32U4, I was under the impression that it doesn't need to be capable because the 2560 would do all the work and simply pass the data to the 16U2's UART. I don't actually know what the differences between the 16U2 and 32U4 are, but I'm assuming the former is 16-bit with less program memory/RAM and the latter is 32-bit with more memory? I'm also assuming they run at the same frequency (48MHz?) to communicate properly as USB devices.

For what it's worth, the device I'm spoofing uses a ST72F651 running in USB mode at 48MHz, it has 32K flash program memory and 5K RAM. The MCU interfaces with one 595 and three 165 shift registers for LEDs and buttons respectively, five potentiometers, an EEPROM (though I'm not sure what it does yet so it may be unnecessary for me to implement that), a 2-bit relative optical encoder whose count is stored as a 14-bit variable, some MOSFETs used to drive two motors and some other hardware used for some ancillary functions that I've forgotten. As far as I can recall that's pretty much it. Would a 32U4 keep up with all of that?

Also, is there an easy way to see or find out which files in the Arduino IDE are relevant to the program that you upload? I will need to modify some core files to configure the Leonardo to do what I want - as in, the HID descriptor, VID and PID, etc. - but I remember getting lost in all of that before. It'd be useful if I could find exactly which files get compiled so I can examine and modify them to see what I get out.

Oh and one last question; is there a way to load programs into the Leonardo without using the USB port? Maybe through the ICSP header?

Thanks again!

The 16U2 and 32U4 are both 8-bit. The biggest difference is the number of pins and the package size. Then the memory available for both your program and for variables.

Yes you can program a Leonardo using the ICSP header. You will need another Arduino or a dedicated ICSP programmer.