Just a quick test to show i have mame starting on boot and that i have GPIO pin 7 setup to enter KEY_5 on the keyboard. The default coin button in MAME. This is cool because if you are doing a 1 player setup in mame you dont need any other add on USB HID boards. So basically you need a $25 raspberry pi, $15 joystick, and a couple cheap buttons.
This is running mame4all, installed from the raspberry pi store gui.
Instructions for getting GPIO pins to work: