So, as it stands with the September 2013 build of MAME4All-Pi, the code supported 16 joystick buttons. Now, under normal conditions, this would be just fine. However, I’m trying to get two players on the one GP-Wiz40 board — using all digital pins (no “joystick ports”).
After messing with the joystick stuff, I could get Linux to recognize and calibrate the sticks (which are actually digital – LOW=0, CENTER=127, HIGH=255). But no luck with MAME.
So, I fell back to the Source Code. Luckily, in the Google repository, I was able to find the changes needed (when they changed the code to support 16 buttons). So, if I could find all those changes, I could add more (with any luck).
And I ended up lucky!
Go to /opt/retropie/emulators/mame4all-pi/src
These files need to be updated:
I added 4 new buttons, bringing the total to 20.
One thing I just noticed: in inptport.h and inptport.cpp there is a READ_HANDLER that does up to 20 ports (boy, was I lucky). If I add more buttons, I’m probably going to mess with that. Not sure why that was already there — maybe they are using 4 for directions and 16 for buttons? Not sure. I’m just hacking the code, so don’t have a proper understanding of it. Either way, I didn’t touch that part, yet my new buttons are working. Go figure.
Once the source is updated, go to /opt/retropie/emulators/mame4all-pi/ and make clean and then make.
(Note that I was sick of permissions issues, so was a bad boy and just granted all users full access to the directory. You may need to do this, or try sudo. I was sick of getting stopped by “security” that I don’t need, so used the brute force approach.)
So, now I can have P1 and P2 have 8 control buttons each (U/D/L/R/A/B/X/Y) and I have four more lines for COIN, P1 Start, P2 Start (?), and probably ESC (close emulator). I’ll stick with 20 for now, since I’m sick of this little hornets nest and want to get to building the hardware!