Main > Software Forum
How does Mame map input?
u_rebelscum:
--- Quote from: headkaze on June 15, 2007, 04:51:12 am ---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.
--- End quote ---
You found one of the games with inputs hardcoded in the driver that are different from default that howard and I were talking about. :) The driver hardcodes the dial inputs to something different than default because the defaults would cause the input conflict you are seeing. (Actually, if left to defaults, pressing left would move the player left and spin the player counterclockwise.)
--- Quote ---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....
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?
--- End quote ---
The problem is the game hardcoded different inputs for dial and dial_ext (the digital - and + of an analog input). Currently you can't look in the cfg files to see what the hardcoded inputs were changed to. Basically, you need ctrlr file that duplicates the hardcoded inputs, or cfg files that change the hardcoded values to something else. Which require you to know which are hardcoded.
You're using the defaults for player 1, right? Just use mames defaults for player 2. Or am I missing what you're talking about
Maybe you might not be visioning "keycodes on the CP" correctly for what you are trying to do. Your controls are keycodes (or joycodes if you use gpwiz or gamepad hack). That button you think of as P1B1 sends the computer the keycode 'G' for example, not P1B1. Mame does not know the upper left most button in the left set of buttons is supposed to be P1B1, mame knows what keycodes are mapped to P1B1 and if those keycodes are pressed or not. If that keycode is at that location, then it's P1B1 for those games that mapped like that.
CP (keycode) --> mame input map (including ctrlr cfg and hardcode) --> control type in game (P1B1)
controls.xml (P1B1) --> mame input map --> keycode --> which button on your CP that should have that label
I see two solutions for your problem. First is let a keycode have more than one label, since that's fine with mame. It might help people figure why spyhunter shoots and goes faster when "P1B1" is pressed and other conflicting mappings. Second is to fix mame so it outputs the hardcoded maps, or add to your app a way to read such hardcoded remaps.
Howard_Casto:
Exactly.
The beauty of using keycodes is your parser doesn't know (or care) what mame constant it's binded to. When you come up with a game that has a label for p1_joystick_up, you run that mame constant through all the mapping heirarchy (default.cfg, ctrlr, ect.....) to determine which is which and then it takes that label and pastes it over that keycode. By reading the analog settings (if joystick/mouse is enabled, and which auto-enablers are active via the new "_device" settings) you can make the layout prettier by turning off disabled keycodes for said game, but you really don't know which to display so you display all with a valid match. So if your 8 way joystick and 4 way joystick are using the same keycodes then they both get the labels, which is why johnny5 supports layouts based on control type. I *think* that was part of what you were asking. Now on to the other parts:
See what rebel said, that game is hard-coded so there isn't much we can do about it.
To get the defaults that are NOT remapped I wrote a little program that reads the mame source and gets the defaults that way. Seeing how mame changes it's source so often anymore, it might not work. I probably still have it if you want it though. It basically reads the source and makes a old ini-style ctrlr file of the defaults. I include the file with j5 and update it once in a while. But to answer your question, yes I do read the default.cfg and ctrlr files as well, along with individual game cfgs and individual game inis (to get analog settings changed by ini files) as well as driver and clone-based inis.
People wonder why j5 takes a sec to display controls, I have to check and parse about a dozen files before I even get to the displaying part. ;)
headkaze:
Thanks guys I really appreciate your help, and will be putting a thanks in the credits.
--- Quote from: u_rebelscum on June 15, 2007, 03:03:57 pm ---You're using the defaults for player 1, right? Just use mames defaults for player 2. Or am I missing what you're talking about?
--- End quote ---
Yes, I was obviously not realising the obvious there. It was getting late when I posted that. It works fine now.
--- Quote from: Howard_Casto on June 15, 2007, 10:28:55 pm ---By reading the analog settings (if joystick/mouse is enabled, and which auto-enablers are active via the new "_device" settings) you can make the layout prettier by turning off disabled keycodes for said game, but you really don't know which to display so you display all with a valid match. So if your 8 way joystick and 4 way joystick are using the same keycodes then they both get the labels, which is why johnny5 supports layouts based on control type. I *think* that was part of what you were asking. Now on to the other parts:
--- End quote ---
Hmm not sure what you mean by the new "_device" settings. Maybe I will release my program first and then people can request "can you add support for".. and then I can figure it out as I go. Also with joystick mouse enabled do you mean by the -joystick -mouse command line options? Are these stored in ini\Mamexx.ini too?
--- Quote from: Howard_Casto on June 15, 2007, 10:28:55 pm ---To get the defaults that are NOT remapped I wrote a little program that reads the mame source and gets the defaults that way. Seeing how mame changes it's source so often anymore, it might not work. I probably still have it if you want it though. It basically reads the source and makes a old ini-style ctrlr file of the defaults. I include the file with j5 and update it once in a while. But to answer your question, yes I do read the default.cfg and ctrlr files as well, along with individual game cfgs and individual game inis (to get analog settings changed by ini files) as well as driver and clone-based inis.
--- End quote ---
I would like to see this program if thats okay. Also if you could explain to me where is the Mame source these custom mappings are located?
EDIT: Also forgot to ask what is "DIAL_EXT"? There is no default mapping for this in mame so how do I handle the label for it?
Howard_Casto:
I'm not talking about custom mappings, I'm talking about the mame default. You know p1 up is the up key, ect...? It'll take me a while to hunt up that app.
By device i mean the paddle_device joystick_device, whatever that are at the bottom of the mame.ini file. This act as auto-switches to turn on and off -mouse, -joystick and -lightgun depending upon the control.
Yes the ini files can do this, amoung other things. You can put anything from the mame.ini into a game/clone/driver based ini file in your ini folder.
You do know that you have to parse the mame ini file and all of it's settings (particularly ctrlr, and all the previously mentioned analog settings) to accurately get the data right? And then you have to check for the driver/clone/parent versions because those can totally change the value yet again.
Dial_ext is basically dial+
In your controls.ini kit on the homepage, there should be a translation file, basically you keep running things through this file and eventually you get the constant. It's a little to technical to get into on this thread. (dial and dial_ext are the internal names used in game drivers btw). I have like three pages of code to handle analog mappings in j5 because it can either be an analog axis mapped to both directions (so you have to manually duplicate the keycode for both labels) or individual axis/buttons. Or for even more confusion, it can be both at the same time! UGH!
Howard_Casto:
STOP THE PRESSES!!!! LITERALLY IF YOU ARE WORKING ON A VIEWER YOU MIGHT AS WELL STOP NOW AND WAIT UNTIL THE SMOKE FROM .116U1 CLEARS!!!
To quote from the latest whatsnew.txt:
"Added support for multiple keyboards: [Andrew Kuruhin]
- added multikeyboard input support through RAWINPUT mechanism
(up to 8 simultaneous keyboard inputs
- fixed RAWINPUT device registry enumeration bugs
"
Now I haven't seen the code yet, so I might be overreacting, but I don't see how this could cause anything but pure chaos! The keycode constants will have to be diferent now right? The keycode constants that have been the same since almost the initial release of mame, those are null and void? Surely, hopefully they had the sense to keep the current constants and just add to them, because if not this will be like that horrible multiple mouse de-backle except you'll have to manually change every single input on your mame cab! Not only that but now you can't use your keyaord for testing because it'll be keyboard 1 and your encoder will be keyboard 2.
I'll check it out to see and report back here. Even best case scenario, we have a whole new batch of constants to add, worst case all the current ones are null and void.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version