Arduino-USB-HID-RetroJoysti.../README.md

45 lines
3.2 KiB
Markdown
Raw Normal View History

2016-09-05 15:33:10 -04:00
# Arduino-USB-HID-RetroJoystickAdapter
2016-09-05 16:28:24 -04:00
## What you need
2016-09-05 15:35:25 -04:00
2016-09-05 16:28:24 -04:00
### Arduino board
2016-09-05 16:29:01 -04:00
ATmega32U4 Arduino Board. There is two versions of ATmega32U4, IO-logic with 5V or 3.3V. Many controllers (like basic Atari-controller) doesn't include any logic, so 5V and 3.3V versions are fine. Most of controllers with some logic needs 5V (NES, SNES, Genesis) and some rare ones needs 3.3V (Gamecube). Make sure that Arduino includes USB-port. There are some versions which doesn't include USB-port and then you have to add USB-connector for it. Arduino Leonardo includes ATmega32U4, but cheapest and smallest ones are named Pro Micro. Arduino Pro Micro and ATmega32U4 are good words to use when searching from Ebay etc.
2016-09-05 15:55:34 -04:00
2016-09-05 16:28:24 -04:00
Example of Arduino Pro Micro:
![Arduino Pro Micro](https://github.com/mcgurk/Arduino-USB-HID-RetroJoystickAdapter/raw/master/Arduino_ProMicro.jpg)
### Computer with Arduino IDE
2016-09-05 16:29:44 -04:00
Arduino IDE works with Windows, OS X and Linux and ARM (beta). If you use small card computer like Rasperry Pi or OrangePi, you can program adapter even with them (tested with Orange Pi PC and RetrOrangePi 2.0). That way you don't even have to unplug adapter from your emulator/game-platform if you want reprogram adapter.
2016-09-05 16:17:51 -04:00
2016-09-05 16:28:24 -04:00
### Joystick library for Arduino IDE
2016-09-05 15:55:34 -04:00
Install joystick library (instructions for installing library: todo)
2016-09-05 15:35:25 -04:00
https://github.com/MHeironimus/ArduinoJoystickLibrary
2016-09-05 15:48:48 -04:00
2016-09-05 16:28:24 -04:00
### Joystick(s) or gamepad(s) and way to connect them to Arduino
2016-09-05 16:31:45 -04:00
Some joystick/gamepads uses their own connectors and original connectors can be very pricey. Sometimes you can find extension cord cheaper than plain connector and you can take cable and plug from that.
2016-09-05 15:48:48 -04:00
2016-09-05 16:28:24 -04:00
## Setup
Download and install Arduino IDE:
https://www.arduino.cc/en/Main/Software
2016-09-05 16:44:57 -04:00
- Tools->Board->Arduino Leonardo
In Arduino IDE you have to select board. On my case some reason "Arduino Leonardo" selections works better than "Arduino/Genuino Micro". With Leonardo-setting RX and TX leds are normally off and blinks when data is transfered to/from USB. With Micro-setting LED's are normally on and they blinks to off when data is transferring.
- Tools->Port->COMx
2016-09-05 16:47:35 -04:00
In Windows Arduino IDE shows only available com-ports. In most cases it's biggest numbered COM-port. COM-port number can change when you start to programming first time (COM-port number can be different after joystick-features are enabled). When I tested with RetrOrangePi (Raspbian Linux), port was ttyACM0.
2016-09-05 16:44:57 -04:00
2016-09-05 16:31:45 -04:00
Install joystick library (instructions for installing library: todo):
2016-09-05 16:28:24 -04:00
https://github.com/MHeironimus/ArduinoJoystickLibrary
## Code
This code supports Atari, SMS, NES, SNES and Genesis (3 and 6 button) controllers. Select your controller by commenting and uncommenting stuff from beginning of source code and give your IO-pin numbers.
Every one uses same button numbering, so if you make multiple adapters for different controllers, you have to teach buttons to RetrOrangePi only once. (of course this is also handy with every other emulators and platforms than RetrOrangePi)
You can also enable or disable Konami-code-shortcut (works only with Genesis 6-button controller (X+Y+Z+UP (or DOWN)) and SNES-controller (X+Y+R1+UP (or DOWN)).
2016-09-05 16:06:27 -04:00
2016-09-05 16:06:16 -04:00
2016-09-05 16:20:12 -04:00
Arduino UNO R3 includes ATmega16U2 (along with ATmega328P) and it can be used too, but it needs some extra work:
2016-09-05 15:48:48 -04:00
https://github.com/NicoHood/HoodLoader2