Kxmame

If you have a joystick plugged in, the default is /dev/js. If that doesn't work, you might want to try:

$ ls -la /dev/input/js*

to see if yours is in /dev/input. Once you've found it your joystick, change the setting in kxmame:

Settings --> Configure kxmame --> Controllers

Saving state
If your game supports saved states, you can press SHIFT+F7 to save your game. There you will be prompted to put it in a memory bank of your choice from a to z.

Press F7 later to reload the saved state.