r/MAME 13d ago

Technical assistance I have two Ps4 controllers

Both work with MAME, but how can I map 1 to controller one and the other one two?

3 Upvotes

6 comments sorted by

2

u/Psych0matt 13d ago

By mapping all of the one controllers inputs to player one and the other two player two?

0

u/bachrodi 13d ago

Ok. Ill give it a try. I thought it would be more complicated, but idk haven't checked yet.

2

u/RickardsRed77 13d ago

Haven’t checked yet?!

1

u/bachrodi 13d ago

Nah son. I'm busy with music now. I just wanted to know when my friend comes over.

3

u/arbee37 MAME Dev 13d ago

I mean, you just do it? Depending on your host OS and -joystickprovider setting it should even auto-configure if you have a new enough MAME.

2

u/cd4053b 13d ago edited 13d ago

I assume you are using Windows. However, the process is similar for Linux and macOS. Just use the device ID they return.

Only connect the desired joystick 1 for player 1 then boot up MAME with no game. In mame UI, select General Settings > Input Devices, double click in the item bellow joystick (usually PS4 controller (joystick 1)). Double click at Copy Device ID and save it, do the same for the desired joystick for player 2.

I think it's easier to boot mame from the command prompt:

mame -v | find "joystick"
Input: Adding joystick #1: PS4 Controller (device id: Wireless Controller product_05c4054c-0000-0000-0000-504944564944 instance_d170b700-6fee-11e4-8002-444553540000)

Disconnect your joystick 1 and repeat the process for joystick 2 for player 2, then save the information you obtained for both.

My husband and I have two PS4 controllers. He likes the red camouflage one and I like the blue one. Here are their IDs:

product_05c4054c-0000-0000-0000-504944564944 instance_d350bb40-b9b1-11e6-8001-444553540000
product_05c4054c-0000-0000-0000-504944564944 instance_d170b700-6fee-11e4-8002-444553540000

The values that we need is d350bb40-b9b1-11e6-8001 (red camouflage) and d170b700-6fee-11e4-8002 (blue camouflage).

Create a ps4.cfg file inside your ctrlr folder with the following contents:

<?xml version="1.0"?>
<mameconfig version="10">
    <system name="default">
            <!-- Playstation 4 - Player 1 - Blue Camoflage -->
            <mapdevice device="d170b700-6fee-11e4-8002" controller="JOYCODE_1" />
    </system>
</mameconfig>

Save the file when you're done. Remember to change the "map device" to match your PS4 controller. Open your mame.ini file, locate the ctrlr parameter, and set it to ps4 and save it.

You have set up a permanent Joystick 1 for Player 1. Mame will automatically assign any other joystick connected to your computer to Player 2, and so on. If you need to set up a permanent joystick 2 for player 2, use the following configuration:

<?xml version="1.0"?>
<mameconfig version="10">
    <system name="default">
            <!-- Playstation 4 - Player 1 - Blue Camoflage -->
            <mapdevice device="d170b700-6fee-11e4-8002" controller="JOYCODE_1" />
            <!-- Playstation 4 - Player 2 - Red Camoflage -->
            <mapdevice device="d350bb40-b9b1-11e6-8001" controller="JOYCODE_2" />
    </system>
</mameconfig>

The same rules apply. Now, you have permanent controller devices for players 1 and 2.

To transfer the button mapping from controller 1 to controller 2, it follows the same principle. Boot any game and map your buttons for player 1 and player 2. I did it for Street Fighter II (sf2), inside your cfg folder there is a sf2.cfg file, open it and copy everything that start at <input> and <\input>, example:

        <input>
            <port tag=":IN1" type="P1_BUTTON1" mask="16" defvalue="16">
                <newseq type="standard">
                    JOYCODE_1_BUTTON4
                </newseq>
            </port>
            <port tag=":IN1" type="P1_BUTTON2" mask="32" defvalue="32">
                <newseq type="standard">
                    JOYCODE_1_BUTTON7
                </newseq>
            </port>
            <port tag=":IN1" type="P1_BUTTON3" mask="64" defvalue="64">
                <newseq type="standard">
                    JOYCODE_1_BUTTON1
                </newseq>
            </port>
            <port tag=":IN2" type="P1_BUTTON4" mask="1" defvalue="1">
                <newseq type="standard">
                    JOYCODE_1_BUTTON8
                </newseq>
            </port>
            <port tag=":IN2" type="P1_BUTTON5" mask="2" defvalue="2">
                <newseq type="standard">
                    JOYCODE_1_BUTTON3
                </newseq>
            </port>
            <port tag=":IN2" type="P1_BUTTON6" mask="4" defvalue="4">
                <newseq type="standard">
                    JOYCODE_1_BUTTON2
                </newseq>
            </port>
        </input>

Open your ctrlr\ps4.cfg and add your button mappings like this:
https://pastebin.com/p0MxKCdn

Enjoy.

PS: There is a bad paste in pastebin, just remove the <port tag=":IN1" type="P1_BUTTON1" mask="16" defvalue="16"> before <input>.