Controller Config Files

Controller specific config files are designed so that you can configure the abundance of controllers available on the market to work with Mame. If you consider that you can get up to 14 buttons on a controller, multiple sticks and dpads, you can configure each one to do something in Mame. You can even make specific controller config files that work exclusively on individual games or systems. Mame config files use XML so are not for the beginner but they are incredibly useful if you have special controllers that you want to use.


.

The Easy Way :)

Here's a little shortcut for all of you not brave enough to read the whole section (Head Hurt Already?) O.K. to save time you can load the game you want to remap into Mame, remap the controls in the in-game menu (press tab and go to Input (this game)). Exit the game and Mame will save a config file in the cfg folder in your Mame folder. What you can do is open the config file (named gamename.cfg) and copy / paste the changed keys into your controller config file. This saves trying to work out the names for your controllers function and writing all those lines of code. (Note: make sure that you delete any <counter> and <mixer> commands that may be copied)


.

The Hard Way :(

Open up the C:\Mame\ctrlr folder. It will look something like this...

Ctrlr Folder

You will see the XML files for the controllers which are saved with a .cfg extension . Now a .cfg file doesn't normally have a default application to open it and if you have MS Outlook it'll default to that (which is a pain!). To edit the file you'll need to open it in a text editor such as Notepad. To associate it with a text editor, simply right click it and select the "Open With..." option. Use Notepad if you don't have your own prefered editor. You can now double click the .cfg file and it will open. Here is an example of a controller config file...

You will see that it's quite (OK VERY!) complex at first glance but XML is very structured so once you've worked out the structure its as easy as any other ini file (Still quite complex then!)

OK... the basic structure. First of all the config files are read by Mame from top to bottom so every time you add a system to the config, it overrides the other previous ones. For example a config file with some default commands, some m72 driver commands and say r-type specific commands would need to be set up with default first, m72 second and r-type last as earlier commands will get overwritten as Mame loads them. Confused? You will be... To sum up, the sequence is... default > driver > system. That's it!

Here is a simple controller file....

<mameconfig version="10">
  <system name="default">
   <input>
    <port type="START1">
    <newseq type="standard">KEYCODE_1 OR J1_Button_9</newseq>
    </port>
   </input>
  </system>
</mameconfig>

What it does is use the start button on my controller as the player 1 start button. All you have to do is save it as mycontroller.cfg in the C:\Mame\ctrlr folder and you can use it in Mame either from the command line option -ctrlr mycontroller or from MameUI's Controller config window.

Let's have another look and I'll explain a bit more...

<mameconfig version="10">
 <system name="default">
  <input>
   <port type="START1">
    <newseq type="standard">KEYCODE_1 OR J1_Button_9
    </newseq>
   </port>
  </input>
 </system>
</mameconfig>

If you look you can see that for every command it has a start and an end. For example <input> is always followed later by </input> to close the command (note the backslash / on the close). This is fairly standard format for programming and html too. The trick is to use a single tab for every opening command and a tab back for every closing command as this helps you keep track of the commands.

The first line <mameconfig version="10"> just tells Mame that this is a config file.
The second line <system name="default"> sets which game system or game the config file will affect. Default affects all games but you can use driver or system names too.
The third line <input> tells Mame that an input command will be changed.
The fourth line <port type="START1"> sets the command that will be changed. You can see a list of commands from the input menus in Mame.
The fifth line <newseq type="standard">KEYCODE_1 OR J1_Button_9 gives the key press or controller movement to be used for the previous lines command.
The sixth line </newseq> closes the newseq command. Normally you'd put it at the end of a newseq line but I moved it down to help explain it.
The seventh line </port> closes the port command so that any more lines wont affect that command.
The eighth line </input> closes the input command for the system stated above it.
The ninth line </system> closes the named system off so you can add another system to the cfg file if you want to.
The tenth and final line is </mameconfig> . This is always the final line as Mame wont read any further when it reads this.

There is another command <remap> which is used like this...

<remap origcode="KEYCODE_UP" newcode="KEYCODE_8_PAD" />

From what I can make out it will take the command in origcode and use it for the command used in the newcode too so one change will affect two codes (Though this might be completely wrong!)

Thats about it for XML based cfg files. To find out the names for commands and movements then look in the input menus in Mame.


.

Using Your Config.

To use your config in the command line version of Mame you will need to add the -ctrlr option to your command line e.g.

mame64 puckman -ctrlr xbox

In MameUI go to the "Default Options" and select the "Controllers" tab. You can select your controller from the "Default input layout" option halfway down. Once selected, MameUI will use it and any game specific files you've created by default.

IMPORTANT! There is one last thing you need to remember, If you change a key in the Mame UI itself and not using an ini file, it is stored in the cfg folder. Changing keys in the MameUI does not affect the ini files. With this in mind, If you muck things up by using the in-game menus you will need to delete the default.cfg file and more than likely the gamename.cfg (replace gamename with the name of the game you've shagged up) to correct the error.