Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
07200 DIP/Input Minor Always Jan 6, 2019, 15:25 7 days ago
Tester illando View Status Public Platform
Assigned To Resolution Open OS
Status [?] Acknowledged Driver
Version 0.204 Fixed in Version Build 64-bit
Summary 07200: Stable Controller IDs for 2 controllers of the same brand.
Description The Stable Controller IDs configuration ( https://docs.mamedev.org/advanced/devicemap.html ) is not working using 2 controllers of the same brand.
This configuration is based on the device ID, but if the controllers that have generic names like "PS4Controller" MAME can not disambiguate between these devices.
I.e.
<mapdevice device="PS4Controller" controller="JOYCODE_1" />
<mapdevice device="PS4Controller" controller="JOYCODE_2" />

A solution to this problem can be found at this link (reply #12 by tverona)
http://forum.arcadecontrols.com/index.php?topic=151710.0#3
In his private build he made MAME able to recognise also the "Instance" for each device, so it's possible to write it in the .config file.
I.e.
<mapdevice device="instance_f1641160-a808-11e5-8006-444553540000" controller="JOYCODE_1" />
<mapdevice device="instance_f1641160-a808-11e5-8002-444553540000" controller="JOYCODE_2" />
Steps To Reproduce
Additional Information
Flags
Regression Version
Affected Sets / Systems
Attached Files
 
Relationships
There are no relationship linked to this issue.
Notes
5
User avatar
No.16017
Tafoid
Administrator
Jan 8, 2019, 01:18
To my knowledge, such information can be added to the mapdevice entry already:
https://github.com/mamedev/mame/commit/28dfa7ce84e2a5465a30630f656ec7eda06b42f3

The documents, I fear, are not set up to handle the duplicate controller ID scenario, but it should work.
User avatar
No.16019
illando
Tester
Jan 8, 2019, 17:49
edited on: Jan 8, 2019, 17:56
@Tafoid Yes but this is just for Directinput, so it will work only on Windows. Right?
Is there a way to ask MAME to visualise the instance on MacOs an try adding it to the mapdevice?
Also SDL2 should support InstanceID:
https://wiki.libsdl.org/SDL_JoystickInstanceID
User avatar
No.16022
Tafoid
Administrator
Jan 11, 2019, 10:17
Opened up for some Developer help with this, hopefully
User avatar
No.17904
R. Belmont
Developer
Aug 22, 2020, 19:25
MacOS doesn't let you see the IDs of the controllers at that level of detail. I added the ability to use the SDL2 JoystickInstanceID but it's just a generated number on non-Windows systems. If the stable controller feature is important to you, you need to use Windows, unfortunately.
User avatar
No.18162
thebitmaster
Tester
7 days ago
I've also had a lot of trouble figuring out how to piece together how this works on Mac, so I've written this abbreviated example that I think it would be appropriate to have here to help other MAME users and testers. The truth is that while it *isn't* possible to differentiate two different identical controllers on Mac, it *is* definitely possible to use the mapdevice feature to get stable controllers when using different ones.

I wanted to play Blasteroids on MAME 0.226 for Mac on Catalina 10.15.7. I already had the rom in the "roms" directory.

I plugged in my Logitech RumblePad 2 USB controller. I also use a Sony Dualshock 3 but it's more complicated.

After plugging the controllers in, I ran MAME with the -v option. This outputs a lot of debug info onto the screen, part of which tells me which ID MAME is getting for my Logitech. I’m running MAME from the command line, an:d

 mame0226-64bit$ ./mame64 -v blstroid.zip

In the middle of all that output is this:

 Joystick: Start initialization
 Input: Adding joystick #0: LogitechRumblePad2USB (device id: 030000006d04000018c2000000010000)
 Joystick: Logitech RumblePad 2 USB [GUID 030000006d04000018c2000000010000

The number I want is the device id shown above, “030000006d04000018c2000000010000”

Let’s say I want this device to always be JOYCODE_1 inside MAME. To make this happen, I created my own bitmaster.cfg file in the “ctrlr” directory inside MAME. You can use whatever editor you want, just make sure it ends with .cfg and not .txt as is the default for TextEdit.

I will specify when I run MAME that I want it to load this config file when I run it on the command line later. It’s worth noting that MAME loads a bunch of files for config, and order is matters. The most important thing to keep in mind right now is that MAME will create a config file for each game, in this case “blstroid.cfg” inside the “cfg” directory. THIS FILE IS LOADED *AFTER* our “bitmaster.cfg” and will OVERRIDE ANY CONFLICTING SETTINGS. Also, the “blstroid.cfg” file will be COMPLETELY OVERWRITTEN each time we make changes to the controls while MAME is running. So the reason we put our controller overrides into a separate file in the “ctrlr” directory is so that they don’t get magically overwritten when we change controls inside MAME.

So inside my “ctrlr/thebitmaster.cfg” file I put this:

 <mameconfig version="10">
 <system name="default">
 
 <!-- Scotts attempt to make a custom input configuration file -->
 
         <input>
             <mapdevice device="030000006d04000018c2000000010000" controller="JOYCODE_1" />
          </input>
 </system>
 </mameconfig>

That “<mapdevice>” tag is what tells MAME that “I always want my Logitech controller to be Joystick 1 in MAME.”

Now, to test, I run MAME again, this time telling it I want to use my custom config file:

 mame0226-64bit$ ./mame64 -v blstroid.zip -ctrlr bitmaster
Note that I did *not* put “.cfg” at the end of “thebitmaster.” MAME adds this automatically.

Close to the end of the output, I see this:

 Starting Blasteroids (rev 4) ':'
 Attempting to parse: bitmaster.cfg
 Input: Remapped joystick #1: LogitechRumblePad2USB (device id: 030000006d04000018c2000000010000)
 Attempting to parse: default.cfg
 Attempting to parse: blstroid.cfg
The “Input: Remapped…” line confirms the override worked. MAME will now *always* use my Logitech for Joystick 1 no matter how many other things I plug in.

Also notice the two lines with “Attempting to parse” below that. Changes in those files are made *after* the ones in my customer “thebitmaster.cfg” file and will override them.

Now my controllers stay put. My Logitech will always be JOYCODE_1. This same procedure can be followed with multiple controllers. As long as they don't have the same ID, they will all work correctly.

I have a slightly longer writeup with details about handling the Dualshock 3, which can show up as two identical devices ALL BY ITSELF, here:

https://scottmauer.wordpress.com/2020/11/16/taming-controllers-with-mame-on-mac/

I don't know the markup for this site and I don't see a Preview button, but I'm happy to massage this however people here think is best, including removing the link to my own website.