Enable a controller:
Ok, so first of all, if you want to use a controller with your mame, you must do the following:
Fire up your mame.
Click on the options in the commands menu.
Then on the drop down menu, select "Default game options"
Click on the Controllers tab, and tick the "Enable joystick input"
We're not done yet...
Go to the options command again, and select "Interface".
Now check the box "Allow game selection using a joystick"
Ok, once that is done, fire up a game... any game will do for now, so you can access the key configuration.
Once the game is fully active, press the "Tab" key on your keyboard.
That should bring up the In-Game menu.
Select "Input general"
From this menu you can now change the keys for the system it self, and game controls.
How to assign commands?
Press Return (Enter) once on the desired command to activate it, and then press the key or button on your controller that you wish to assign to automatically assign it.
To assign another key or button to the same command, simply press it again, and press the other key.
NOTE: You can have both, the controller and the keyboard assigned.
The commands are self explanatory... so left is left, right is right, etc...
I recommend you leave the dial commands alone for now, as they are only for rarely played games, and you wont really need them.
However, the steering wheel commands can be assigned using a steering wheel that you can purchase in any good games shops.
If you change your mind, you must select another command, before you assign that one again. as it will just keep adding more buttons to that command.
Alternatively, select it and quickly press right twice on the keyboard to cancel all assigned buttons to that command.
I advise beginners not to mess with the general input, and just modify the "Input this game" until you are used to modifying the commands.
And please do NOT modify the tab command, as you no longer be able to access the menus.
However, if you make a mistake, don't panic.
Simply select the command and double tap right in your keyboard to blank out that command.
All assigned game keys will be the default for all games.
Meaning if you assign jump on the key "Space" or button A/1 on the controller... all games will have that one setting, so you may have to modify a few game's keys, as games command vary.
As a last resort, if you make a mistake and can't change it.
Go to mame folder and find the Configuration.ini file.
Open it, and from here you can change the commands.