SkillAgentSearch skills...

Configgenerator

Mame Config Generator Plugin

Install / Use

/learn @Jakobud/Configgenerator
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

MAME Config Generator LUA Plugin

This is a LUA plugin for MAME. It automatically generates verbose input configuration files (.cfg) for MAME games.

Installation and Usage

  1. Download the configgenerator.zip from the latest Release
  2. Unzip the file
  3. Copy the configgenerator directory to the mame/plugins/ directory:
    • Example: /path/to/mame/plugins/configgenerator/
  4. The plugin is set to automatically be enabled when starting MAME
  5. If not, the plugin can be enabled in one of the follow ways:
    • Enable Config Generator in MAME's Plugin Menu
    • Add configgenerator to the plugin option in mame.ini
    • Run MAME with the command-line option -plugin configgenerator
    • Add configgenerator 1 to plugin.ini

Doesn't MAME already generate .cfg files?

MAME generates a .cfg file in the cfg directory for a game when the game exits. While these are important and useful, they do not include input or dipswitch configurations that are using the system default values.

For example if you run pacman using default MAME controls, this is the pacman.cfg that is generated:

<?xml version="1.0"?>
<!-- This file is autogenerated; comments and unknown tags will be stripped -->
<mameconfig version="10">
    <system name="pacman" />
</mameconfig>

Because all the input controls and dipswitches are set to default values, MAME does not include them in the configuration file.

This plugin will generate a similar .cfg but will include all input controls and dipswitches values, whether or not they are set to default values. It will even (optionally) include comments. Here is the generated pacman.cfg:

<?xml version="1.0"?>
<!-- This file is autogenerated; comments and unknown tags will be stripped -->
<mameconfig version="10">
    <system name="pacman">
        <input>
            <!-- Bonus Life -->
            <!-- Value: 0 = 10000 -->
            <!-- Value: 16 = 15000 -->
            <!-- Value: 32 = 20000 -->
            <!-- Value: 48 = None -->
            <port tag=":DSW1" type="DIPSWITCH" mask="48" defvalue="0" value="0"/>

            <!-- Coinage -->
            <!-- Value: 1 = 1 Coin/1 Credit -->
            <!-- Value: 2 = 1 Coin/2 Credits -->
            <!-- Value: 3 = 2 Coins/1 Credit -->
            <!-- Value: 0 = Free Play -->
            <port tag=":DSW1" type="DIPSWITCH" mask="3" defvalue="1" value="1"/>

            <!-- Difficulty -->
            <!-- Value: 64 = Normal -->
            <!-- Value: 0 = Hard -->
            <port tag=":DSW1" type="CONFIG" mask="64" defvalue="64" value="64"/>

            <!-- Ghost Names -->
            <!-- Value: 128 = Normal -->
            <!-- Value: 0 = Alternate -->
            <port tag=":DSW1" type="CONFIG" mask="128" defvalue="128" value="128"/>

            <!-- Lives -->
            <!-- Value: 0 = 1 -->
            <!-- Value: 4 = 2 -->
            <!-- Value: 8 = 3 -->
            <!-- Value: 12 = 5 -->
            <port tag=":DSW1" type="DIPSWITCH" mask="12" defvalue="8" value="8"/>

            <!-- Coin 1 -->
            <port tag=":IN0" type="COIN1" mask="32" defvalue="32">
                <newseq type="standard">
                    KEYCODE_5
                </newseq>
            </port>

            <!-- Coin 2 -->
            <port tag=":IN0" type="COIN2" mask="64" defvalue="64">
                <newseq type="standard">
                    KEYCODE_6
                </newseq>
            </port>

            <!-- P1 Down -->
            <port tag=":IN0" type="P1_JOYSTICK_DOWN" mask="8" defvalue="8">
                <newseq type="standard">
                    KEYCODE_DOWN
                </newseq>
            </port>
etc...

Why is this useful?

This plugin is useful mostly for 3rd party MAME tools that would benefit from automatically generated config files.

For MAME, it is notoriously difficult to set consistent input controls for large numbers of games at the same time, which is why invaluable tools like CFG Magician were created long ago. CFG Magician however relies on generated configuration files for each game in order to make new ones with new input assignments. This plugin makes it easy to generate new config files for modern versions of MAME.

CTRLR files and MAME command-line options

You can alter MAME's input control assignements using ctrlr files or pointing to different config files using command-line options like -cfg_directory or -ctrlrpath. The great thing about this plugin is that it will take these into account when generating the config files. Whatever input assignments you see in MAME is what it will generate.

Settings

This plugin includes a settings.json with various values you can adjust

{
  "comments": true,
  "output": "cfg_generated",
  "run_at_start": false,
  "run_at_end": true,
  "overwrite": true
}
  • comments - boolean

    • Whether or not to include control input comments in the config file
    • Default: true
    <!-- Difficulty -->
    <!-- Value: 64 = Normal -->
    <!-- Value: 0 = Hard -->
    <port tag=":DSW1" type="CONFIG" mask="64" defvalue="64" value="64"/>
    
  • output - string

    • Output directory for the generated .cfg files, relative to the MAME directory
    • Default: cfg_generated
    • You could change this to cfg and the plugin would overwrite MAME's own generated config files but this would not be recommended as MAME also includes bookkeeping statistics and debugger information in it's config files.
  • run_at_start - boolean

    • Whether or not to generate the config file when a game loads (emulation starts)
    • Default: false
  • run_at_end - boolean

    • Whether or not to generate the config file you exit a game (emulation ends)
    • Default: true
  • overwrite - boolean

    • Whether or not to overwrite existing .cfg files
    • Default: true
View on GitHub
GitHub Stars6
CategoryDevelopment
Updated3mo ago
Forks0

Languages

Lua

Security Score

72/100

Audited on Dec 16, 2025

No findings