Main > Software Forum
How does Mame map input?
2600:
It's been a while since I looked at it, but don't forget a crucial part. Ctrlr mappings don't have to per game. In a Ctrlr file, you can also map per driver(everything using that drive will use that mapping) and/or map by the Master (Master and all clones will use that mapping). IIRC the Ctrlr file is order dependent.
I want to say it goes:
Default -> game.cfg -> Ctrlr
but it's been too long since I looked at it. Only a 1 minute test to prove it or you should be able to find it in the source pretty easily.
u_rebelscum:
I'll go into details, but basically you got it:
Default -> OS specific (coded) -> ctrlr -> cfg/default.cfg -> driver coded non-defaults -> cfg/[game].cfg
Mame has two seperate input mapping lists; I'll call them "general" and "local". They have been this way from before ctrlr files were added, so things might seem not well planned. ;) Each list is seperate and while local overrides general (general -> local in the above format), edits to one list does not change what's in the other list.
General's part of the whole is:
Default -> OS specific (coded) -> ctrlr -> cfg/default.cfg -> ...
To most people, the OS specific part is part of the "default" default, since it is hard coded. However, other OS variants that don't use official mame's src/osd/windows/input.c (or a copy of osd_customize_inputport_list() function therein) can have different "defaults". Both the ctrlr and cfg/default.cfg files change the general input map, the latter overriding the former. The general list is complete with all input ports included.
Local's part of the whole is:
... -> driver coded non-defaults -> cfg/[game].cfg
This list is not complete, and includes only the gaming inputs in the specific game's inputs. The defaults for each input in the list is "default". IOW, this tells mame to "look the the general list". If it's not "default", then mame uses that setting and ignores the general list. You can tell if it's set to "default" by looking into the tab, inputs this game, and seeing if it's highlighted or not: highlighted = not "default", not highlighted = "default".
However, sometimes (examples: rotary joysticks, toobin') the driver is coded to set it something besides "default". This not only makes the vanilla setup (aka default) not set to "default", but also negates any changes in ctrlr file (game specific or not). Since cfg/game.cfg overrides the driver coded inputs, however, you can reassign that input back to "default" by pressing enter, esc [pause], enter, esc in the tab inputs this game menu.
I hope this helps. If I glossed over anything, was unclear, or forgot something, please ask. (I totally skipped the ctrlr file order, for example: it's not order depend anymore, just the order they're put in the ctrlr file.)
edit: added ctrlr file not listed note.
headkaze:
Thanks heaps for the input u_rebelscum, really appreciated :)
Okay, I got around to doing some actual testing in Mame and it does confirm to work the way you described. Here are my test results. (BTW I'm only interested in the way it works in Windows). There were a few times where it didn't act the way I expected. But I think it was because I manually created the config files. It seems you need to have Mame generate them for them to work. The mask/index/defvalue values seem to be important to Mame.
-- MAME Default --
--- Code: ---P1_BUTTON1 : KEYCODE_LCONTROL
--- End code ---
-- cfg\default.cfg --
--- Code: ---<?xml version="1.0"?>
<!-- This file is autogenerated; comments and unknown tags will be stripped -->
<mameconfig version="10">
<system name="default">
<input>
<port type="P1_BUTTON1">
<newseq type="standard">
KEYCODE_A
</newseq>
</port>
</input>
</system>
</mameconfig>
--- End code ---
-- cfg\1942.cfg --
--- Code: ---<?xml version="1.0"?>
<!-- This file is autogenerated; comments and unknown tags will be stripped -->
<mameconfig version="10">
<system name="1942">
<input>
<port type="P1_BUTTON1" mask="16" index="13" defvalue="16">
<newseq type="standard">
KEYCODE_B
</newseq>
</port>
</input>
</system>
</mameconfig>
--- End code ---
-- ctrlr\Test.cfg --
--- Code: ---<mameconfig version="10">
<system name="default">
<input>
<port type="P1_BUTTON1">
<newseq type="standard">KEYCODE_C</newseq>
</port>
</input>
</system>
<system name="1942">
<input>
<port type="P1_BUTTON1">
<newseq type="standard">KEYCODE_D</newseq>
</port>
</input>
</system>
</mameconfig>
--- End code ---
These are all tests running 1942
1. No config files
P1_BUTTON1 : KEYCODE_LCONTROL
2. With cfg\default.cfg only
P1_BUTTON1 : KEYCODE_A
3. With cfg\1942.cfg only
P1_BUTTON1 : KEYCODE_B
4. With cfg\default.cfg and cfg\1942.cfg
P1_BUTTON1 : KEYCODE_B
5. With cfg\default.cfg and cfg\1942.cfg and ctrlr\Test.cfg
P1_BUTTON1 : KEYCODE_B
6. With cfg\default.cfg and ctrlr\Test.cfg
P1_BUTTON1 : KEYCODE_A
7. With ctrlr\Test.cfg only
P1_BUTTON1 : KEYCODE_D
8. ctrlr\Test.cfg with 1942 config removed
P1_BUTTON1 : KEYCODE_C
So is that all I need to know to get the right key mapping? Can you please verify my results?
Howard_Casto:
That looks about right to me.... there's one thing, I dunno if it's been fixed yet or not, that you need to be aware of though. (And it's a real pain!) The ctrlr file, which should work in a hierarchy, actually works from top to bottom.... so if the 1942 entry was above the default entry, the default would be used. I ignore it myself because most people are aware of the glitch and organize their files accordingly (my ctrlr converter does this as well) but it's worth mentioning.
The main thing to remember is those stupid cfg files override everything! I really wish there was code in mame to optionally re-direct in-game remappings to the current ctrlr file (hint! hint! hint!).
Also as rebel explained, unfortunately some games have their keys hard-coded other than the default. For a brief period (maybe 2 mame versions) cfg files printed out the default mappings when a game was launched, and thus we could get 100% accuracy, but as of now they don't, so there is no way of knowing. I really wish somebody would add code to have only hard-coded changes print in the cfg file when the game starts (again hint! hint!).
headkaze:
Thanks Howard, I think that's about all I need to know.
--- Quote from: Howard_Casto on June 12, 2007, 01:51:17 am ---The ctrlr file, which should work in a hierarchy, actually works from top to bottom.... so if the 1942 entry was above the default entry, the default would be used.
--- End quote ---
That is really annoying! I don't think I'll bother supporting that either. It's quite amazing how mind bending all this is really. So many little nuances and checks to make. But I guess thats all part of the challenge.
Cheers guys :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version