Friday Post: Arduino Keyboard Joystick

Hey all,

It’s been a long week, and I am really glad I have a long weekend to sleep in.

When the Arduino Leonardo was announced I was really excited to see it have built in USB HID support and could act as a keyboard, mouse, or joystick.  I was even more excited to find out that my year old Teensy++ (Arduino compatible board) was based on the same chipset that the Leonardo now uses, and is able to act as a keyboard as well!

This is a new feature that was introduced in the Arduino 1.0 IDE.  You can now send keyboard presses with this simple line of code: Keyboard.write(‘a’);  If I wanted the Up joystick to be the up arrow on the keyboard, I would just use: Keyboard.write(0x0E); .

.

My goal is to use my Neo Geo AES controllers as an input for MAME.  The Neo Geo pads don’t have any control boards built into the unit.  The console itself interprets each pin individually, just like an actual arcade board.  The pad uses a standard midi gameport (DA-15) connector, with each pin representing one button.

My idea is to make a Neo Geo pad to usb adapter using the Teensy++ as go-between.  The Neo Geo pins will be wired up to the digital pins on the Teensy, and the Teensy Arduino sketch will interpret each button press as a keyboard press.

I’m looking forward to working on this project.  I hope everyone has a great weekend and a restful Labor Day.

3 thoughts on “Friday Post: Arduino Keyboard Joystick

  1. I almost went the USB keyboard emulation route myself when I was working on my MAME cab, but it was pointed out to me that USB keyboards only allow 6 simultaneous keypresses by default (unless you’re very careful about which keys are being mapped…), so I changed gears and went with another Arduino-based method that directly emulates joypads. It’s actually super easy to emulate X number of joypads with Y buttons with some of these projects out there. Check out my page for how I went about it if you’re curious, but basically I used a small AVR with a bunch of shift registers, and it works great.

  2. Do you have any code samples ? I have tried using my Leonardo as a arcade joystick -> USB keyboard and while it works in notepad and i can see the key presses, MAME does not like it. I may get the odd response to the fire button but that’s about it.
    Thanks Matt.

Leave a Reply to Matthew Cancel reply

Your email address will not be published. Required fields are marked *