Main > Software Forum
How does Mame map input?
Howard_Casto:
Oh... also don't forget that the ctrlr file can have a driver entry (in this case cps1). That is VERY useful and needs to be supported. Again, I assume that the driver entries are above the rom entries. And parent roms too.... If you have a sf2 entry it should work for sf2ce as well. Just remember that this is the case for ctrlr entries and NOT cfg files.... modifying sf2 in-game does NOT effect sf2ce.
u_rebelscum:
--- Quote from: Howard_Casto on June 12, 2007, 01:51:17 am ---... 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.
--- End quote ---
Still there. Start at first system in the file, check if it should be read, go to next, check, repeat till end of file. Requires the user to do the hierarchy in the order the systems are put in the file, which can be lots of work if the ctrlr file gets big. [shrug]
--- Quote ---... 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!).
--- End quote ---
This is the way it is ATM. Since the hardcoded is not "default", mame prints it out in the cfg.
--- Quote from: headkaze on June 12, 2007, 06:00:13 am ---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.
--- End quote ---
It actually is fairly logical if you know the history and order features were added. Not that it's easy, just that there's reasons why it's the way it is.
As for input changes in mame in general, Aaron hinted that it needs a major rewrite at some point. He was talking about internally moving much of the code into the core and out of the OS specific area, and not about redesigning, but maybe that will be done too. :dunno
Howard_Casto:
--- Quote from: u_rebelscum on June 12, 2007, 01:47:51 pm ---
--- Quote ---... 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!).
--- End quote ---
This is the way it is ATM. Since the hardcoded is not "default", mame prints it out in the cfg.
......
.....
.....
It actually is fairly logical if you know the history and order features were added. Not that it's easy, just that there's reasons why it's the way it is.
As for input changes in mame in general, Aaron hinted that it needs a major rewrite at some point. He was talking about internally moving much of the code into the core and out of the OS specific area, and not about redesigning, but maybe that will be done too. :dunno
--- End quote ---
Can you give me an example (I lost all my notes in a hd crash some months back) because the last time I checked it didn't. We might be talking about different things. I left the code in there for it in j5 because, well it's already done and I assumed it'd be fixed eventually.
....
....
Moving it into the core would make sense. I mean the files are all ascii, so it's not like it couldn't be read in any os. Xml is fairly non-os-specific as well. I agree with you in that it actually makes a lot of sense, the only issues I've ever had is the ones we just brought up (although I'm still not fond of the xml, but I'll let that go).
Imho all that needs done is to fix the hierarchy in the ctrlr file, add some method of editing them inside mame (solves a lot of newbie problems) and do something with the hardcoded inputs, and oddities like games that only have buttons 3-5 instead of the more sensical 1-3. Probably what would be good for the hardcoded inputs would be to keep them all defaults instead and put a function in mame (similar to listxml) to print custom cfg files for said games. Then people who like em can use em and those who don't aren't stuck with the chore of manually editing all of those games.
u_rebelscum:
--- Quote from: Howard_Casto on June 12, 2007, 06:33:35 pm ---
--- Quote from: u_rebelscum on June 12, 2007, 01:47:51 pm ---
--- Quote ---... 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!).
--- End quote ---
This is the way it is ATM. Since the hardcoded is not "default", mame prints it out in the cfg.
--- End quote ---
Can you give me an example (I lost all my notes in a hd crash some months back) because the last time I checked it didn't.
--- End quote ---
You're right, I'm wrong. :-[ Mame puts it in the cfg if it's different from the hardcoded default, which is "default" normally, unless driver hardcoded, which makes that the default.
--- Quote ---...and oddities like games that only have buttons 3-5 instead of the more sensical 1-3...
--- End quote ---
Yes, and buttons 1-3 + 7, where buttons 1-3 are used, and that out lying button is not AFAICT. And that mame outputs in list.xml the wrong number of buttons in both cases, 5 in yours and 7 in mine.
headkaze:
I've already hit my first hurdle in the magical world of Mame control mapping. I am quite happy to figure this one out myself, but I thought I'd post about it here and see what experience others have had.
So basically my goal is to get labels from controls.xml mapped to the right controls even if you have custom ctrlr, or cfg files. Lets for now just forget about ctrlr and cfg files for a minute. Lets assume the user is using the default keys.
I've taken Howards suggestion to use KEYCODE's to define controls on the CP, rather than P1_BUTTON1 etc. so that mapping is more accurate.
So my first problem comes to light when getting the labels for tnk3. The output looks like this:
--- Code: ---KEYCODE_LCONTROL: Fire
KEYCODE_LALT: Cannon
KEYCODE_UP: Up
KEYCODE_DOWN: Down
KEYCODE_LEFT: Left
KEYCODE_RIGHT: Right
KEYCODE_LEFT: Aim Left
KEYCODE_RIGHT: Aim Left
--- End code ---
So KEYCODE_LEFT and KEYCODE_RIGHT (by default is P1_JOYSTICK_LEFT and P1_JOYSTICK_RIGHT). Why does it end up being assigned to "Aim Left" and "Aim Right" instead of "Left" and "Right"?
Okay lets take a look at the controls.xml entry for tnk3...
--- Code: ---<game romname="tnk3" gamename="T.N.K. III (US)" numPlayers="2" alternating="1" mirrored="1" usesService="0" tilt="0" cocktail="1">
<miscDetails>
This rotary is a unique one. It almost looks like a dial at first glance, but the dial can also be shifted in 8 directions, just like a rotary 8-way.
</miscDetails>
<player number="1" numButtons="2">
<controls>
<control name="8-way Rotary Joystick(Optical)">
<constant name="joy8way"/>
<constant name="dial"/>
</control>
<control name="Misc">
<constant name="other"/>
</control>
</controls>
<labels>
<label name="P1_BUTTON1" value="Fire"/>
<label name="P1_BUTTON2" value="Cannon"/>
<label name="P1_JOYSTICK_UP" value="Up"/>
<label name="P1_JOYSTICK_DOWN" value="Down"/>
<label name="P1_JOYSTICK_LEFT" value="Left"/>
<label name="P1_JOYSTICK_RIGHT" value="Right"/>
<label name="P1_DIAL" value="Aim Left"/>
<label name="P1_DIAL_EXT" value="Aim Right"/>
</labels>
</player>
</game>
--- End code ---
If we take a look at P1_DIAL and P1_DIAL_EXT (not sure why it's called that, there is no P1_DIAL_EXT in Mame), you will set it's mapped to "Aim Left". Now if we take a look at the Mame defaults we will understand why it ends up being mapped the wrong way.
--- Code: ---INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_LEFT, "P1 Left",
SEQ_DEF_3(KEYCODE_LEFT, CODE_OR, JOYCODE_1_LEFT) )
INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1 JOYSTICK_RIGHT, "P1 Right",
SEQ_DEF_3(KEYCODE_RIGHT, CODE_OR, JOYCODE_1_RIGHT) )
INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, DIAL, "Dial",
SEQ_DEF_3(MOUSECODE_1_ANALOG_X, CODE_OR, JOYCODE_1_ANALOG_X),
SEQ_DEF_3(KEYCODE_LEFT, CODE_OR, JOYCODE_1_LEFT),
SEQ_DEF_3(KEYCODE_RIGHT, CODE_OR, JOYCODE_1_RIGHT) )
--- End code ---
Now it becomes at bit more obvious whats going wrong here. Both KEYCODE_LEFT and KEYCODE_RIGHT are assigned to P1_DIAL, so that is overriding P1_JOYSTICK_LEFT and P1_JOYSTICK_RIGHT.
Now here comes the question, if you use keycodes to define the controls on your panel, how do you know which keycodes to remap when there is multiple mappings like this? Also how do you know which keycodes are supposed to be for player 1 or player 2 for mirroring controls? I can only assume that Johnny 5 does this by requiring a ctrlr file that defines what controls are what. Is that correct?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version