Introduction: Sega Genesis Controller to USB Adapter for $2
Step 1: Prepare Bootloader and Development Environment
Prepare a bootloader and an Arduino development environment.
1. Start by following the instructions here.
2. Note: Unfortunately, there are now floating around fake stm32f103c8t6 boards, with a relabeled IC. This relabeled IC has only 32K flash and 10K ram as opposed to the 64K (or even 128K) flash and 20K ram of the originals, and is perhaps an stm32f103c6. If you have one of these, then when you're about to flash the booloader, the STM32 Demonstrator will tell you that you have a low density 32K device (see screenshot). If you're in that position, make sure you have the latest Arduino core and bootloader, as they now support this lower-end device. And you'll need to select the Generic stm32f103c6 in the Arduino IDE.
3. In your libmaple core, replace the contents of STM32F1/libraries/USBComposite with the latest version (or at least 0.92) from here. This is needed to support dual XBox360 controllers.
4. The blue pills have a wrong USB resistor, typically 10K instead of 1.5K. With some computers, they'll work fine, but they may give trouble with others. Check your resistance between 3.3V and A12. If it's not 1.5K, add a resistor in parallel between these pins to get 1.5K. For instance, if you have 10K, then add a 1.8K resistor.
Step 2: Install Sketch
Get my sketch and upload it to the board. There are two sketch options, depending on which Xbox 360 controller you want to emulate (compatibility may vary):
For my retroarch purposes, the sketch sends left stick movements in response to the dpad buttons by default, but if you hold down the START button while pressing the dpad buttons, it sends XBox dpad buttons instead. If you don't need this, comment out the line:
Plug the board into a computer and check that two gamepads show up (they won't move, of course, since you don't have anything hooked to the board). On Windows, press win-R and type joy.cpl to see the two gamepads.
Step 3: Solder
Get or make your two DB9 male sockets (or just one if that's all you want; in that case, you may want to modify the code).
Now connect them as in the two diagrams to your blue pill. The view here is from the back of the DB9 socket, i.e., the side you solder on (or, equivalently, the front of the female jack on the controllers).
Step 4: Optional: Case
I have a design for a 3D-printable case for the project here, assuming you are using my 3D printed DB9 sockets.