joystick.h mame controller, p1 / p2 / insert coin buttons

Hey guys

Arduino Leonardo
joystick.h library
Cheapo joysticks
Momentary switches

So I've made myself a pair of controllers using a Leonardo, joystick.h library and momentary switches.

Try to use joystick.setButton(arg, arg) to map the player 1, player 1, insert coin buttons but no documents as to how to map this using mame.

Should looke something like this...

button_value = digitalRead(button_player1);
Joystick.setButton([what pin to map??],button_value);

I've tried using the Keyboard.h library and sending a "1" when the button is pressed but doesn't work, not sure why.

According to mame, keyboard #1-4 is to select player's #1-4
Keyboard #5-8 is to insert coin to players #1-4

Trying to map a momentary switch to select players 1 and 2

Thanks in advance guys~!

BTW I see a number of people asking this question when researching my own. To play TWO controllers on mame, simply load the SAME sketch on two Leonardos and plug them in to your computer. They will get different COM ports and one will be designed as the second player. :slight_smile: