And so a bit more than a year later I stumbled upon this thread and script. I too have grown tired of enabling autofire every time I play raiden, so slogging through ioport.cpp and cheatopt.cpp thinking I'd just hardcode a few things I realised that:
a) Hahahaha, no.
b) I am terrible at c++ (but c++ is terrible so we're even!?)
I'm not very knowledgable about the MAME internals, but I've done my best to read the code and attempt an implementation.
The lua api doesn't have access to the ioports_live bits or we'd be able to flip the 'on' switch for a button. I still have no idea why the .cfg can't just have an autofire='on' in the tag line.
Either way, I tried to use this script and found that at least with current (0.202) it didn't work. So I did what any obsessive compulsive person would do: one trillion print statements.
This is where things got a bit strange. First off, I couldn't get 'map_from' to match so button would be set. I tried multiple games, but none of them worked properly. I ended up hardcoding it just to make it function for my tests.
for tag, port in pairs(manager:machine():ioport().ports) do
--if port.fields[map_from ] then
if port.fields['P1 Button 1'] then
print("Found eet: ",port.fields['P1 Button 1'])
button = port.fields['P1 Button 1']
print ("button is: ",button)
end
end
This worked, but when I tried raiden nothing happened when I pushed button 1. On accident I pushed button 2 and /both/ button 1 and 2 fired (and did autofire).
This lead me to try dumping values while it was running and I ended up with this:
port fields:
tag: :P1_P2
port: sol.ioport_port *: 0x7fca20ef0798
table["P2 Up"] = sol.ioport_field *: 0x7fca20ef2918
table["P1 Right"] = sol.ioport_field *: 0x7fca20ef2858
table["P2 Button 2"] = sol.ioport_field *: 0x7fca20ef2a08
table["P2 Button 1"] = sol.ioport_field *: 0x7fca20ef29d8
table["1 Player Start"] = sol.ioport_field *: 0x7fca20ef28e8
table["P1 Up"] = sol.ioport_field *: 0x7fca20ef27c8
table["P1 Left"] = sol.ioport_field *: 0x7fca20ef2828
table["2 Players Start"] = sol.ioport_field *: 0x7fca20ef2a38
table["P2 Right"] = sol.ioport_field *: 0x7fca20ef29a8
table["P1 Button 1"] = sol.ioport_field *: 0x7fca20ef2888
table["P1 Down"] = sol.ioport_field *: 0x7fca20ef27f8
table["P2 Down"] = sol.ioport_field *: 0x7fca20ef2948
table["P1 Button 2"] = sol.ioport_field *: 0x7fca20ef28b8
table["P2 Left"] = sol.ioport_field *: 0x7fca20ef2978
I then did a 5x loop around the button = port.fields["P1 Button 1"] and... whaaat?
Found eet: sol.ioport_field *: 0x7fca20ef55d8
button is: sol.ioport_field *: 0x7fca20ed8578
Found eet: sol.ioport_field *: 0x7fca26005d48
button is: sol.ioport_field *: 0x7fca26006578
Found eet: sol.ioport_field *: 0x7fca26307e28
button is: sol.ioport_field *: 0x7fca26308628
Found eet: sol.ioport_field *: 0x7fca26309fd8
button is: sol.ioport_field *: 0x7fca2630a7d8
Found eet: sol.ioport_field *: 0x7fca2630c188
button is: sol.ioport_field *: 0x7fca2630c988
Notice that the values not only don't match the first table dump, but they change constantly.
At this point I'm not sure I know how to move forward. The map_from match issue isn't a big deal as I could just hardcode it, but I really have no idea why the autofire works at all because the call to button should fail. Of course, button 2 also doesn't match.
Is this script still functioning for you with 0.202?