Ok, I started looking in mame on how the UI labels are displayed. Here's what I got.
look in /src/inptport.h and .c
line 381 (of .61)
struct ik input_keywords[] =
Interesting struct. The ik struct is just name, type, value. Example:
{ "KEYCODE_A", IKT_STD, KEYCODE_A },
{ "KEYCODE_B", IKT_STD, KEYCODE_B },
{ "KEYCODE_C", IKT_STD, KEYCODE_C },
...
{ "P1_JOYSTICK_UP", IKT_IPT, IPF_PLAYER1 | IPT_JOYSTICK_UP },
{ "P1_JOYSTICK_DOWN", IKT_IPT, IPF_PLAYER1 | IPT_JOYSTICK_DOWN },
{ "P1_JOYSTICK_LEFT", IKT_IPT, IPF_PLAYER1 | IPT_JOYSTICK_LEFT },
{ "P1_JOYSTICK_RIGHT", IKT_IPT, IPF_PLAYER1 | IPT_JOYSTICK_RIGHT },
{ "P1_BUTTON1", IKT_IPT, IPF_PLAYER1 | IPT_BUTTON1 },
{ "P1_BUTTON2", IKT_IPT, IPF_PLAYER1 | IPT_BUTTON2 },
This struct is used witht he ctrlr files to match the name, then set the controls based on the value. So in a ctrlr file you will see
P1_BUTTON1 "KEYCODE_A"
What the ctrlr parser will do is look at P1_BUTTON1. It will see that in the srtuct is is of type IKT_IPT (input) and has the value of the TWO constants, IPF_PLAYER1 and IPT_BUTTON1 ORed together.
Note: that's how the driver defined controle, from topspeed driver
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER1 ) /* main accel key */
OK, we know what control to set, now what to set it to. that's the next value in the input, KEYCODE_A. So, we look that up in the struct, It is has a name of "KEYCODE_A", type IPK_STD, value of KEYCODE_A (A constant holding some value). Well, now we can assign the control to the constant:)
Now, you want to know why I bring this up? If we want controls.dat to work in mame UI, It is alot easier to keep witht he ini file format if we use the name and not value. (knobunc, this is why I wouldn;t use IPT_XXXX in the dat file).
If you use the IPT format in the dat file because then we probably would have to nest data, like:
[firetrk]
IPT_PLAYER1:
IPT_BUTTON1=Horn
IPT_PLAYER2:
IPT_BUTTON1=Bell
[end]
Ahh, that won't work with an ini parser:(
However this will
[firetrk]
P1_BUTTON1=Horn
P2_BUTTON2=Bell
[end]
Now, there is issues. We know -listinfo lists "wrong" controls.
That is because in the driver they do this (dotron example)
PORT_START /* fake port to make aiming up & down easier */
PORT_ANALOG( 0xff, 0x00, IPT_TRACKBALL_Y, 100, 10, 0, 0 )
But also in that driver we know dotron uses a dial and joystick
PORT_START /* IN1 */
PORT_ANALOGX( 0xff, 0x00, IPT_DIAL | IPF_REVERSE, 50, 10, 0, 0, KEYCODE_Z, KEYCODE_X, 0, 0 )
PORT_START /* IN2 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_BUTTON3, "Aim Down", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_BUTTON4, "Aim Up", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )
so, if we can make a skeleton file that uses the info from the drivers, it's more correct, but still not 100%. It will still take man power.
Oh, I think I could have mame itself output the skeleton file. Kinda like -listinfo. This might help out too, since, with the dotron and firetrk examples, some of the labels are already.
Actually, MAMe can store the labels!!! That;s what PORT_BITX is. It's an extended version of PORT_BIT.
Someone want to do an experiment for me., I'm a little busy right now with other tasks (this post took me forever to right) Take a game where you know the control labels. Replace PORT_BIT with PORT_BITX in the driver.
Like fine
INPUT_PORTS_START( ddragon )
Ok, this might be a bad example, but do this anyway.
You see in INPUT_PORTS_START(ddragon) there is
COMMON_INPUT_PORTS and
COMMON_PORT4
If you look just above you see that's where the buttons are defined for ddragon. hehe, this won;t work well with the ddragon example since ddragon1 and 2 are slightly different labels. Anyway, do this. Replace
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
with
PORT_BITX( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1, "Punch", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
compile, run ddragon. See if in the UI it says Punch for button 1. If so, hmmmm... I'm not suggesting all the drivers need change, I doubt mamedevs will will allow that. Just curious.